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
|
|
|
{
|
2024-02-23 03:20:54 +00:00
|
|
|
MetDay = 0,
|
|
|
|
MetMonth = 0,
|
|
|
|
MetYear = 0,
|
2022-06-18 18:04:24 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
pk.MetDate.HasValue.Should().BeFalse();
|
|
|
|
}
|
|
|
|
|
|
|
|
[Fact]
|
|
|
|
public void MetDateReturnsCorrectDate()
|
|
|
|
{
|
|
|
|
var pk = new PK7
|
2019-10-26 19:58:55 +00:00
|
|
|
{
|
2024-02-23 03:20:54 +00:00
|
|
|
MetDay = 10,
|
|
|
|
MetMonth = 8,
|
|
|
|
MetYear = 16,
|
2022-06-18 18:04:24 +00:00
|
|
|
};
|
|
|
|
|
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
|
|
|
{
|
2024-02-23 03:20:54 +00:00
|
|
|
MetDay = 1,
|
|
|
|
MetMonth = 1,
|
|
|
|
MetYear = 0,
|
2022-06-18 18:04:24 +00:00
|
|
|
};
|
|
|
|
|
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
|
|
|
{
|
2024-02-23 03:20:54 +00:00
|
|
|
MetDay = 12,
|
|
|
|
MetMonth = 12,
|
|
|
|
MetYear = 12,
|
2022-06-18 18:04:24 +00:00
|
|
|
};
|
|
|
|
|
2024-02-23 03:20:54 +00:00
|
|
|
pk.MetDay.Should().Be(12);
|
|
|
|
pk.MetMonth.Should().Be(12);
|
|
|
|
pk.MetYear.Should().Be(12);
|
2022-06-18 18:04:24 +00:00
|
|
|
|
|
|
|
pk.MetDate = null;
|
|
|
|
|
2024-02-23 03:20:54 +00:00
|
|
|
pk.MetDay.Should().Be(0);
|
|
|
|
pk.MetMonth.Should().Be(0);
|
|
|
|
pk.MetYear.Should().Be(0);
|
2022-06-18 18:04:24 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
[Fact]
|
|
|
|
public void SettingMetDateSetsComponents()
|
|
|
|
{
|
|
|
|
var pk = new PK7
|
2019-10-26 19:58:55 +00:00
|
|
|
{
|
2024-02-23 03:20:54 +00:00
|
|
|
MetDay = 12,
|
|
|
|
MetMonth = 12,
|
|
|
|
MetYear = 12,
|
2022-06-18 18:04:24 +00:00
|
|
|
};
|
|
|
|
|
2024-02-23 03:20:54 +00:00
|
|
|
pk.MetDay.Should().Be(12);
|
|
|
|
pk.MetMonth.Should().Be(12);
|
|
|
|
pk.MetYear.Should().Be(12);
|
2022-06-18 18:04:24 +00:00
|
|
|
|
2023-01-22 04:02:33 +00:00
|
|
|
pk.MetDate = new DateOnly(2005, 5, 5);
|
2022-06-18 18:04:24 +00:00
|
|
|
|
2024-02-23 03:20:54 +00:00
|
|
|
pk.MetDay.Should().Be(5);
|
|
|
|
pk.MetMonth.Should().Be(5);
|
|
|
|
pk.MetYear.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
|
|
|
{
|
2024-02-23 03:20:54 +00:00
|
|
|
EggDay = 0,
|
|
|
|
EggMonth = 0,
|
|
|
|
EggYear = 0,
|
2022-06-18 18:04:24 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
pk.EggMetDate.HasValue.Should().BeFalse();
|
|
|
|
}
|
|
|
|
|
|
|
|
[Fact]
|
|
|
|
public void EggMetDateReturnsCorrectDate()
|
|
|
|
{
|
|
|
|
var pk = new PK7
|
2019-10-26 19:58:55 +00:00
|
|
|
{
|
2024-02-23 03:20:54 +00:00
|
|
|
EggDay = 10,
|
|
|
|
EggMonth = 8,
|
|
|
|
EggYear = 16,
|
2022-06-18 18:04:24 +00:00
|
|
|
};
|
|
|
|
|
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
|
|
|
{
|
2024-02-23 03:20:54 +00:00
|
|
|
EggDay = 1,
|
|
|
|
EggMonth = 1,
|
|
|
|
EggYear = 0,
|
2022-06-18 18:04:24 +00:00
|
|
|
};
|
|
|
|
|
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
|
|
|
{
|
2024-02-23 03:20:54 +00:00
|
|
|
EggDay = 12,
|
|
|
|
EggMonth = 12,
|
|
|
|
EggYear = 12,
|
2022-06-18 18:04:24 +00:00
|
|
|
};
|
|
|
|
|
2024-02-23 03:20:54 +00:00
|
|
|
pk.EggDay.Should().Be(12);
|
|
|
|
pk.EggMonth.Should().Be(12);
|
|
|
|
pk.EggYear.Should().Be(12);
|
2022-06-18 18:04:24 +00:00
|
|
|
|
|
|
|
pk.EggMetDate = null;
|
|
|
|
|
2024-02-23 03:20:54 +00:00
|
|
|
pk.EggDay.Should().Be(0);
|
|
|
|
pk.EggMonth.Should().Be(0);
|
|
|
|
pk.EggYear.Should().Be(0);
|
2022-06-18 18:04:24 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
[Fact]
|
|
|
|
public void SettingEggMetDateSetsComponents()
|
|
|
|
{
|
|
|
|
var pk = new PK7
|
2019-10-26 19:58:55 +00:00
|
|
|
{
|
2024-02-23 03:20:54 +00:00
|
|
|
EggDay = 12,
|
|
|
|
EggMonth = 12,
|
|
|
|
EggYear = 12,
|
2022-06-18 18:04:24 +00:00
|
|
|
};
|
|
|
|
|
2024-02-23 03:20:54 +00:00
|
|
|
pk.EggDay.Should().Be(12);
|
|
|
|
pk.EggMonth.Should().Be(12);
|
|
|
|
pk.EggYear.Should().Be(12);
|
2022-06-18 18:04:24 +00:00
|
|
|
|
2023-01-22 04:02:33 +00:00
|
|
|
pk.EggMetDate = new DateOnly(2005, 5, 5);
|
2022-06-18 18:04:24 +00:00
|
|
|
|
2024-02-23 03:20:54 +00:00
|
|
|
pk.EggDay.Should().Be(5);
|
|
|
|
pk.EggMonth.Should().Be(5);
|
|
|
|
pk.EggYear.Should().Be(5);
|
2018-11-06 23:25:35 +00:00
|
|
|
}
|
|
|
|
}
|