2023-01-22 04:02:33 +00:00
|
|
|
using System;
|
2018-11-06 23:25:35 +00:00
|
|
|
using FluentAssertions;
|
|
|
|
using Xunit;
|
|
|
|
|
2023-01-22 04:02:33 +00:00
|
|
|
namespace PKHeX.Core.Tests.PKM;
|
2022-06-18 18:04:24 +00:00
|
|
|
|
|
|
|
public class MetDateTests
|
2018-11-06 23:25:35 +00:00
|
|
|
{
|
2022-06-18 18:04:24 +00:00
|
|
|
[Fact]
|
|
|
|
public void MetDateNullWhenDateComponentsAreAllZero()
|
2019-10-26 19:58:55 +00:00
|
|
|
{
|
2022-06-18 18:04:24 +00:00
|
|
|
var pk = new PK7
|
2018-11-06 23:25:35 +00:00
|
|
|
{
|
2022-06-18 18:04:24 +00:00
|
|
|
Met_Day = 0,
|
|
|
|
Met_Month = 0,
|
|
|
|
Met_Year = 0,
|
|
|
|
};
|
|
|
|
|
|
|
|
pk.MetDate.HasValue.Should().BeFalse();
|
|
|
|
}
|
|
|
|
|
|
|
|
[Fact]
|
|
|
|
public void MetDateReturnsCorrectDate()
|
|
|
|
{
|
|
|
|
var pk = new PK7
|
2019-10-26 19:58:55 +00:00
|
|
|
{
|
2022-06-18 18:04:24 +00:00
|
|
|
Met_Day = 10,
|
|
|
|
Met_Month = 8,
|
|
|
|
Met_Year = 16,
|
|
|
|
};
|
|
|
|
|
2023-01-22 04:02:33 +00:00
|
|
|
pk.MetDate.GetValueOrDefault().Should().Be(new DateOnly(2016, 8, 10));
|
2022-06-18 18:04:24 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
[Fact]
|
|
|
|
public void MetDateCalculatesYear0Correctly()
|
|
|
|
{
|
|
|
|
var pk = new PK7
|
2019-10-26 19:58:55 +00:00
|
|
|
{
|
2022-06-18 18:04:24 +00:00
|
|
|
Met_Day = 1,
|
|
|
|
Met_Month = 1,
|
|
|
|
Met_Year = 0,
|
|
|
|
};
|
|
|
|
|
2023-01-22 04:02:33 +00:00
|
|
|
pk.MetDate.GetValueOrDefault().Year.Should().Be(2000);
|
2022-06-18 18:04:24 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
[Fact]
|
|
|
|
public void SettingToNullZerosComponents()
|
|
|
|
{
|
|
|
|
var pk = new PK7
|
2019-10-26 19:58:55 +00:00
|
|
|
{
|
2022-06-18 18:04:24 +00:00
|
|
|
Met_Day = 12,
|
|
|
|
Met_Month = 12,
|
|
|
|
Met_Year = 12,
|
|
|
|
};
|
|
|
|
|
|
|
|
pk.Met_Day.Should().Be(12);
|
|
|
|
pk.Met_Month.Should().Be(12);
|
|
|
|
pk.Met_Year.Should().Be(12);
|
|
|
|
|
|
|
|
pk.MetDate = null;
|
|
|
|
|
|
|
|
pk.Met_Day.Should().Be(0);
|
|
|
|
pk.Met_Month.Should().Be(0);
|
|
|
|
pk.Met_Year.Should().Be(0);
|
|
|
|
}
|
|
|
|
|
|
|
|
[Fact]
|
|
|
|
public void SettingMetDateSetsComponents()
|
|
|
|
{
|
|
|
|
var pk = new PK7
|
2019-10-26 19:58:55 +00:00
|
|
|
{
|
2022-06-18 18:04:24 +00:00
|
|
|
Met_Day = 12,
|
|
|
|
Met_Month = 12,
|
|
|
|
Met_Year = 12,
|
|
|
|
};
|
|
|
|
|
|
|
|
pk.Met_Day.Should().Be(12);
|
|
|
|
pk.Met_Month.Should().Be(12);
|
|
|
|
pk.Met_Year.Should().Be(12);
|
|
|
|
|
2023-01-22 04:02:33 +00:00
|
|
|
pk.MetDate = new DateOnly(2005, 5, 5);
|
2022-06-18 18:04:24 +00:00
|
|
|
|
|
|
|
pk.Met_Day.Should().Be(5);
|
|
|
|
pk.Met_Month.Should().Be(5);
|
|
|
|
pk.Met_Year.Should().Be(5);
|
2019-10-26 19:58:55 +00:00
|
|
|
}
|
2022-06-18 18:04:24 +00:00
|
|
|
}
|
2018-11-06 23:25:35 +00:00
|
|
|
|
2022-06-18 18:04:24 +00:00
|
|
|
public class EggMetDateTests
|
|
|
|
{
|
|
|
|
[Fact]
|
|
|
|
public void EggMetDateNullWhenDateComponentsAreAllZero()
|
2019-10-26 19:58:55 +00:00
|
|
|
{
|
2022-06-18 18:04:24 +00:00
|
|
|
var pk = new PK7
|
2018-11-06 23:25:35 +00:00
|
|
|
{
|
2022-06-18 18:04:24 +00:00
|
|
|
Egg_Day = 0,
|
|
|
|
Egg_Month = 0,
|
|
|
|
Egg_Year = 0,
|
|
|
|
};
|
|
|
|
|
|
|
|
pk.EggMetDate.HasValue.Should().BeFalse();
|
|
|
|
}
|
|
|
|
|
|
|
|
[Fact]
|
|
|
|
public void EggMetDateReturnsCorrectDate()
|
|
|
|
{
|
|
|
|
var pk = new PK7
|
2019-10-26 19:58:55 +00:00
|
|
|
{
|
2022-06-18 18:04:24 +00:00
|
|
|
Egg_Day = 10,
|
|
|
|
Egg_Month = 8,
|
|
|
|
Egg_Year = 16,
|
|
|
|
};
|
|
|
|
|
2023-01-22 04:02:33 +00:00
|
|
|
pk.EggMetDate.GetValueOrDefault().Should().Be(new DateOnly(2016, 8, 10));
|
2022-06-18 18:04:24 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
[Fact]
|
|
|
|
public void EggMetDateCalculatesYear0Correctly()
|
|
|
|
{
|
|
|
|
var pk = new PK7
|
2019-10-26 19:58:55 +00:00
|
|
|
{
|
2022-06-18 18:04:24 +00:00
|
|
|
Egg_Day = 1,
|
|
|
|
Egg_Month = 1,
|
|
|
|
Egg_Year = 0,
|
|
|
|
};
|
|
|
|
|
2023-01-22 04:02:33 +00:00
|
|
|
pk.EggMetDate.GetValueOrDefault().Year.Should().Be(2000);
|
2022-06-18 18:04:24 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
[Fact]
|
|
|
|
public void SettingEggMetDateToNullZerosComponents()
|
|
|
|
{
|
|
|
|
var pk = new PK7
|
2019-10-26 19:58:55 +00:00
|
|
|
{
|
2022-06-18 18:04:24 +00:00
|
|
|
Egg_Day = 12,
|
|
|
|
Egg_Month = 12,
|
|
|
|
Egg_Year = 12,
|
|
|
|
};
|
|
|
|
|
|
|
|
pk.Egg_Day.Should().Be(12);
|
|
|
|
pk.Egg_Month.Should().Be(12);
|
|
|
|
pk.Egg_Year.Should().Be(12);
|
|
|
|
|
|
|
|
pk.EggMetDate = null;
|
|
|
|
|
|
|
|
pk.Egg_Day.Should().Be(0);
|
|
|
|
pk.Egg_Month.Should().Be(0);
|
|
|
|
pk.Egg_Year.Should().Be(0);
|
|
|
|
}
|
|
|
|
|
|
|
|
[Fact]
|
|
|
|
public void SettingEggMetDateSetsComponents()
|
|
|
|
{
|
|
|
|
var pk = new PK7
|
2019-10-26 19:58:55 +00:00
|
|
|
{
|
2022-06-18 18:04:24 +00:00
|
|
|
Egg_Day = 12,
|
|
|
|
Egg_Month = 12,
|
|
|
|
Egg_Year = 12,
|
|
|
|
};
|
|
|
|
|
|
|
|
pk.Egg_Day.Should().Be(12);
|
|
|
|
pk.Egg_Month.Should().Be(12);
|
|
|
|
pk.Egg_Year.Should().Be(12);
|
|
|
|
|
2023-01-22 04:02:33 +00:00
|
|
|
pk.EggMetDate = new DateOnly(2005, 5, 5);
|
2022-06-18 18:04:24 +00:00
|
|
|
|
|
|
|
pk.Egg_Day.Should().Be(5);
|
|
|
|
pk.Egg_Month.Should().Be(5);
|
|
|
|
pk.Egg_Year.Should().Be(5);
|
2018-11-06 23:25:35 +00:00
|
|
|
}
|
|
|
|
}
|