diff --git a/Tests/PKHeX.Tests/PKHeX.Tests.csproj b/Tests/PKHeX.Tests/PKHeX.Tests.csproj index 88f9d09a7..374291b32 100644 --- a/Tests/PKHeX.Tests/PKHeX.Tests.csproj +++ b/Tests/PKHeX.Tests/PKHeX.Tests.csproj @@ -50,6 +50,8 @@ + + diff --git a/Tests/PKHeX.Tests/PKM/DateTestPKM.cs b/Tests/PKHeX.Tests/PKM/DateTestPKM.cs new file mode 100644 index 000000000..1195e7e4e --- /dev/null +++ b/Tests/PKHeX.Tests/PKM/DateTestPKM.cs @@ -0,0 +1,1063 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace PKHeX.Tests.PKM +{ + /// + /// A implementation designed to test and . + /// + class DateTestPKM : PKHeX.PKM + { + public int MetYear { get; set; } + public int MetMonth { get; set; } + public int MetDay { get; set; } + public int EggMetYear { get; set; } + public int EggMetMonth { get; set; } + public int EggMetDay { get; set; } + + protected override int Met_Year + { + get + { + return MetYear; + } + + set + { + MetYear = value; + } + } + + protected override int Met_Month + { + get + { + return MetMonth; + } + + set + { + MetMonth = value; + } + } + + protected override int Met_Day + { + get + { + return MetDay; + } + + set + { + MetDay = value; + } + } + + protected override int Egg_Year + { + get + { + return EggMetYear; + } + + set + { + EggMetYear = value; + } + } + + protected override int Egg_Month + { + get + { + return EggMetMonth; + } + + set + { + EggMetMonth = value; + } + } + + protected override int Egg_Day + { + get + { + return EggMetDay; + } + + set + { + EggMetDay = value; + } + } + + + #region NotImplemented Properties + + public override int Ability + { + get + { + throw new NotImplementedException(); + } + + set + { + throw new NotImplementedException(); + } + } + + public override int AltForm + { + get + { + throw new NotImplementedException(); + } + + set + { + throw new NotImplementedException(); + } + } + + public override int Ball + { + get + { + throw new NotImplementedException(); + } + + set + { + throw new NotImplementedException(); + } + } + + public override int Characteristic + { + get + { + throw new NotImplementedException(); + } + } + + public override ushort Checksum + { + get + { + throw new NotImplementedException(); + } + + set + { + throw new NotImplementedException(); + } + } + + public override int CNT_Beauty + { + get + { + throw new NotImplementedException(); + } + + set + { + throw new NotImplementedException(); + } + } + + public override int CNT_Cool + { + get + { + throw new NotImplementedException(); + } + + set + { + throw new NotImplementedException(); + } + } + + public override int CNT_Cute + { + get + { + throw new NotImplementedException(); + } + + set + { + throw new NotImplementedException(); + } + } + + public override int CNT_Sheen + { + get + { + throw new NotImplementedException(); + } + + set + { + throw new NotImplementedException(); + } + } + + public override int CNT_Smart + { + get + { + throw new NotImplementedException(); + } + + set + { + throw new NotImplementedException(); + } + } + + public override int CNT_Tough + { + get + { + throw new NotImplementedException(); + } + + set + { + throw new NotImplementedException(); + } + } + + public override int CurrentFriendship + { + get + { + throw new NotImplementedException(); + } + + set + { + throw new NotImplementedException(); + } + } + + public override int CurrentHandler + { + get + { + throw new NotImplementedException(); + } + + set + { + throw new NotImplementedException(); + } + } + + public override int Egg_Location + { + get + { + throw new NotImplementedException(); + } + + set + { + throw new NotImplementedException(); + } + } + + public override uint EncryptionConstant + { + get + { + throw new NotImplementedException(); + } + + set + { + throw new NotImplementedException(); + } + } + + public override int EV_ATK + { + get + { + throw new NotImplementedException(); + } + + set + { + throw new NotImplementedException(); + } + } + + public override int EV_DEF + { + get + { + throw new NotImplementedException(); + } + + set + { + throw new NotImplementedException(); + } + } + + public override int EV_HP + { + get + { + throw new NotImplementedException(); + } + + set + { + throw new NotImplementedException(); + } + } + + public override int EV_SPA + { + get + { + throw new NotImplementedException(); + } + + set + { + throw new NotImplementedException(); + } + } + + public override int EV_SPD + { + get + { + throw new NotImplementedException(); + } + + set + { + throw new NotImplementedException(); + } + } + + public override int EV_SPE + { + get + { + throw new NotImplementedException(); + } + + set + { + throw new NotImplementedException(); + } + } + + public override uint EXP + { + get + { + throw new NotImplementedException(); + } + + set + { + throw new NotImplementedException(); + } + } + + public override bool FatefulEncounter + { + get + { + throw new NotImplementedException(); + } + + set + { + throw new NotImplementedException(); + } + } + + public override int Format + { + get + { + throw new NotImplementedException(); + } + } + + public override int Gender + { + get + { + throw new NotImplementedException(); + } + + set + { + throw new NotImplementedException(); + } + } + + public override int HeldItem + { + get + { + throw new NotImplementedException(); + } + + set + { + throw new NotImplementedException(); + } + } + + public override bool IsEgg + { + get + { + throw new NotImplementedException(); + } + + set + { + throw new NotImplementedException(); + } + } + + public override bool IsNicknamed + { + get + { + throw new NotImplementedException(); + } + + set + { + throw new NotImplementedException(); + } + } + + public override int IV_ATK + { + get + { + throw new NotImplementedException(); + } + + set + { + throw new NotImplementedException(); + } + } + + public override int IV_DEF + { + get + { + throw new NotImplementedException(); + } + + set + { + throw new NotImplementedException(); + } + } + + public override int IV_HP + { + get + { + throw new NotImplementedException(); + } + + set + { + throw new NotImplementedException(); + } + } + + public override int IV_SPA + { + get + { + throw new NotImplementedException(); + } + + set + { + throw new NotImplementedException(); + } + } + + public override int IV_SPD + { + get + { + throw new NotImplementedException(); + } + + set + { + throw new NotImplementedException(); + } + } + + public override int IV_SPE + { + get + { + throw new NotImplementedException(); + } + + set + { + throw new NotImplementedException(); + } + } + + public override int Language + { + get + { + throw new NotImplementedException(); + } + + set + { + throw new NotImplementedException(); + } + } + + public override byte MarkByte + { + get + { + throw new NotImplementedException(); + } + + protected set + { + throw new NotImplementedException(); + } + } + + public override int Met_Level + { + get + { + throw new NotImplementedException(); + } + + set + { + throw new NotImplementedException(); + } + } + + public override int Met_Location + { + get + { + throw new NotImplementedException(); + } + + set + { + throw new NotImplementedException(); + } + } + + public override int Move1 + { + get + { + throw new NotImplementedException(); + } + + set + { + throw new NotImplementedException(); + } + } + + public override int Move1_PP + { + get + { + throw new NotImplementedException(); + } + + set + { + throw new NotImplementedException(); + } + } + + public override int Move1_PPUps + { + get + { + throw new NotImplementedException(); + } + + set + { + throw new NotImplementedException(); + } + } + + public override int Move2 + { + get + { + throw new NotImplementedException(); + } + + set + { + throw new NotImplementedException(); + } + } + + public override int Move2_PP + { + get + { + throw new NotImplementedException(); + } + + set + { + throw new NotImplementedException(); + } + } + + public override int Move2_PPUps + { + get + { + throw new NotImplementedException(); + } + + set + { + throw new NotImplementedException(); + } + } + + public override int Move3 + { + get + { + throw new NotImplementedException(); + } + + set + { + throw new NotImplementedException(); + } + } + + public override int Move3_PP + { + get + { + throw new NotImplementedException(); + } + + set + { + throw new NotImplementedException(); + } + } + + public override int Move3_PPUps + { + get + { + throw new NotImplementedException(); + } + + set + { + throw new NotImplementedException(); + } + } + + public override int Move4 + { + get + { + throw new NotImplementedException(); + } + + set + { + throw new NotImplementedException(); + } + } + + public override int Move4_PP + { + get + { + throw new NotImplementedException(); + } + + set + { + throw new NotImplementedException(); + } + } + + public override int Move4_PPUps + { + get + { + throw new NotImplementedException(); + } + + set + { + throw new NotImplementedException(); + } + } + + public override int Nature + { + get + { + throw new NotImplementedException(); + } + + set + { + throw new NotImplementedException(); + } + } + + public override string Nickname + { + get + { + throw new NotImplementedException(); + } + + set + { + throw new NotImplementedException(); + } + } + + public override int OT_Friendship + { + get + { + throw new NotImplementedException(); + } + + set + { + throw new NotImplementedException(); + } + } + + public override int OT_Gender + { + get + { + throw new NotImplementedException(); + } + + set + { + throw new NotImplementedException(); + } + } + + public override string OT_Name + { + get + { + throw new NotImplementedException(); + } + + set + { + throw new NotImplementedException(); + } + } + + public override uint PID + { + get + { + throw new NotImplementedException(); + } + + set + { + throw new NotImplementedException(); + } + } + + public override int PKRS_Days + { + get + { + throw new NotImplementedException(); + } + + set + { + throw new NotImplementedException(); + } + } + + public override int PKRS_Strain + { + get + { + throw new NotImplementedException(); + } + + set + { + throw new NotImplementedException(); + } + } + + public override int PSV + { + get + { + throw new NotImplementedException(); + } + } + + public override ushort Sanity + { + get + { + throw new NotImplementedException(); + } + + set + { + throw new NotImplementedException(); + } + } + + public override int SID + { + get + { + throw new NotImplementedException(); + } + + set + { + throw new NotImplementedException(); + } + } + + public override int SIZE_PARTY + { + get + { + throw new NotImplementedException(); + } + } + + public override int SIZE_STORED + { + get + { + throw new NotImplementedException(); + } + } + + public override int Species + { + get + { + throw new NotImplementedException(); + } + + set + { + throw new NotImplementedException(); + } + } + + public override int Stat_ATK + { + get + { + throw new NotImplementedException(); + } + + set + { + throw new NotImplementedException(); + } + } + + public override int Stat_DEF + { + get + { + throw new NotImplementedException(); + } + + set + { + throw new NotImplementedException(); + } + } + + public override int Stat_HPCurrent + { + get + { + throw new NotImplementedException(); + } + + set + { + throw new NotImplementedException(); + } + } + + public override int Stat_HPMax + { + get + { + throw new NotImplementedException(); + } + + set + { + throw new NotImplementedException(); + } + } + + public override int Stat_Level + { + get + { + throw new NotImplementedException(); + } + + set + { + throw new NotImplementedException(); + } + } + + public override int Stat_SPA + { + get + { + throw new NotImplementedException(); + } + + set + { + throw new NotImplementedException(); + } + } + + public override int Stat_SPD + { + get + { + throw new NotImplementedException(); + } + + set + { + throw new NotImplementedException(); + } + } + + public override int Stat_SPE + { + get + { + throw new NotImplementedException(); + } + + set + { + throw new NotImplementedException(); + } + } + + public override int TID + { + get + { + throw new NotImplementedException(); + } + + set + { + throw new NotImplementedException(); + } + } + + public override int TSV + { + get + { + throw new NotImplementedException(); + } + } + + public override int Version + { + get + { + throw new NotImplementedException(); + } + + set + { + throw new NotImplementedException(); + } + } + + public override PKHeX.PKM Clone() + { + throw new NotImplementedException(); + } + + public override byte[] Encrypt() + { + throw new NotImplementedException(); + } + + public override bool getGenderIsValid() + { + throw new NotImplementedException(); + } + #endregion + } +} diff --git a/Tests/PKHeX.Tests/PKM/PKMTests.cs b/Tests/PKHeX.Tests/PKM/PKMTests.cs new file mode 100644 index 000000000..885780303 --- /dev/null +++ b/Tests/PKHeX.Tests/PKM/PKMTests.cs @@ -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"); + } + } +}