mirror of
https://github.com/kwsch/PKHeX
synced 2024-11-26 22:10:21 +00:00
Added test for PKM.MetDate
This commit is contained in:
parent
9852c42ca1
commit
17078c8d28
3 changed files with 1136 additions and 0 deletions
|
@ -50,6 +50,8 @@
|
|||
</Otherwise>
|
||||
</Choose>
|
||||
<ItemGroup>
|
||||
<Compile Include="PKM\DateTestPKM.cs" />
|
||||
<Compile Include="PKM\PKMTests.cs" />
|
||||
<Compile Include="Properties\AssemblyInfo.cs" />
|
||||
<Compile Include="Util\DateUtilTests.cs" />
|
||||
</ItemGroup>
|
||||
|
|
1063
Tests/PKHeX.Tests/PKM/DateTestPKM.cs
Normal file
1063
Tests/PKHeX.Tests/PKM/DateTestPKM.cs
Normal file
File diff suppressed because it is too large
Load diff
71
Tests/PKHeX.Tests/PKM/PKMTests.cs
Normal file
71
Tests/PKHeX.Tests/PKM/PKMTests.cs
Normal file
|
@ -0,0 +1,71 @@
|
|||
using Microsoft.VisualStudio.TestTools.UnitTesting;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace PKHeX.Tests.PKM
|
||||
{
|
||||
[TestClass]
|
||||
public class PKMTests
|
||||
{
|
||||
const string DateTestCategory = "PKM Date Tests";
|
||||
|
||||
[TestMethod]
|
||||
[TestCategory(DateTestCategory)]
|
||||
public void MetDateGetterTest()
|
||||
{
|
||||
var pk = new DateTestPKM();
|
||||
|
||||
// Ensure MetDate is null when components are all 0
|
||||
pk.MetDay = 0;
|
||||
pk.MetMonth = 0;
|
||||
pk.MetYear = 0;
|
||||
Assert.IsFalse(pk.MetDate.HasValue, "MetDate should be null when date components are all 0.");
|
||||
|
||||
// Ensure MetDate gives correct date
|
||||
pk.MetDay = 10;
|
||||
pk.MetMonth = 8;
|
||||
pk.MetYear = 16;
|
||||
Assert.AreEqual(new DateTime(2016, 8, 10).Date, pk.MetDate.Value.Date, "Met date does not return correct date.");
|
||||
}
|
||||
|
||||
[TestMethod]
|
||||
[TestCategory(DateTestCategory)]
|
||||
public void MetDateSetterTest()
|
||||
{
|
||||
var pk = new DateTestPKM();
|
||||
|
||||
// Ensure setting to null zeros the components
|
||||
// -- Set to something else first
|
||||
pk.MetDay = 12;
|
||||
pk.MetMonth = 12;
|
||||
pk.MetYear = 12;
|
||||
// -- Act
|
||||
pk.MetDate = null;
|
||||
// -- Assert
|
||||
Assert.AreEqual(0, pk.MetDay, "Met_Day was not zeroed when MetDate is set to null");
|
||||
Assert.AreEqual(0, pk.MetMonth, "Met_Month was not zeroed when MetDate is set to null");
|
||||
Assert.AreEqual(0, pk.MetYear, "Met_Year was not zeroed when MetDate is set to null");
|
||||
|
||||
// Ensure setting to a date sets the components
|
||||
var now = DateTime.Now;
|
||||
// -- Set to something else first
|
||||
pk.MetDay = 12;
|
||||
pk.MetMonth = 12;
|
||||
pk.MetYear = 12;
|
||||
if (now.Month == 12)
|
||||
{
|
||||
// We don't want the test to work just because it's 12/12 right now.
|
||||
pk.MetMonth = 11;
|
||||
}
|
||||
// -- Act
|
||||
pk.MetDate = now;
|
||||
// -- Assert
|
||||
Assert.AreEqual(now.Day, pk.MetDay, "Met_Day was not correctly set");
|
||||
Assert.AreEqual(now.Month, pk.MetMonth, "Met_Month was not correctly set");
|
||||
Assert.AreEqual(now.Year - 2000, pk.MetYear, "Met_Year was not correctly set");
|
||||
}
|
||||
}
|
||||
}
|
Loading…
Reference in a new issue