public void EggMetDateSetterTest() { var pk = new DateTestPKM(); // Ensure setting to null zeros the components // -- Set to something else first pk.EggMetDay = 12; pk.EggMetMonth = 12; pk.EggMetYear = 12; // -- Act pk.EggMetDate = null; // -- Assert Assert.AreEqual(0, pk.EggMetDay, "Egg_Day was not zeroed when EggMetDate is set to null"); Assert.AreEqual(0, pk.EggMetMonth, "Egg_Month was not zeroed when EggMetDate is set to null"); Assert.AreEqual(0, pk.EggMetYear, "Egg_Year was not zeroed when EggMetDate is set to null"); // Ensure setting to a date sets the components var now = DateTime.Now; // -- Set to something else first pk.EggMetDay = 12; pk.EggMetMonth = 12; pk.EggMetYear = 12; if (now.Month == 12) { // We don't want the test to work just because it's 12/12 right now. pk.EggMetMonth = 11; } // -- Act pk.EggMetDate = now; // -- Assert Assert.AreEqual(now.Day, pk.EggMetDay, "Egg_Day was not correctly set"); Assert.AreEqual(now.Month, pk.EggMetMonth, "Egg_Month was not correctly set"); Assert.AreEqual(now.Year - 2000, pk.EggMetYear, "Egg_Year was not correctly set"); }
public void EggMetDateSetterTest() { var pk = new DateTestPKM(); // Ensure setting to null zeros the components // -- Set to something else first pk.EggMetDay = 12; pk.EggMetMonth = 12; pk.EggMetYear = 12; // -- Act pk.EggMetDate = null; // -- Assert Assert.AreEqual(0, pk.EggMetDay, "Egg_Day was not zeroed when EggMetDate is set to null"); Assert.AreEqual(0, pk.EggMetMonth, "Egg_Month was not zeroed when EggMetDate is set to null"); Assert.AreEqual(0, pk.EggMetYear, "Egg_Year was not zeroed when EggMetDate is set to null"); // Ensure setting to a date sets the components var now = DateTime.Now; // -- Set to something else first pk.EggMetDay = 12; pk.EggMetMonth = 12; pk.EggMetYear = 12; if (now.Month == 12) { // We don't want the test to work just because it's 12/12 right now. pk.EggMetMonth = 11; } // -- Act pk.EggMetDate = now; // -- Assert Assert.AreEqual(now.Day, pk.EggMetDay, "Egg_Day was not correctly set"); Assert.AreEqual(now.Month, pk.EggMetMonth, "Egg_Month was not correctly set"); Assert.AreEqual(now.Year - 2000, pk.EggMetYear, "Egg_Year was not correctly set"); }
public void EggMetDateGetterTest() { var pk = new DateTestPKM(); // Ensure MetDate is null when components are all 0 pk.EggMetDay = 0; pk.EggMetMonth = 0; pk.EggMetYear = 0; Assert.IsFalse(pk.MetDate.HasValue, "EggMetDate should be null when date components are all 0."); // Ensure MetDate gives correct date pk.EggMetDay = 10; pk.EggMetMonth = 8; pk.EggMetYear = 16; Assert.AreEqual(new DateTime(2016, 8, 10).Date, pk.EggMetDate.Value.Date, "Egg met date does not return correct date."); }
public void EggMetDateGetterTest() { var pk = new DateTestPKM(); // Ensure MetDate is null when components are all 0 pk.EggMetDay = 0; pk.EggMetMonth = 0; pk.EggMetYear = 0; Assert.IsFalse(pk.MetDate.HasValue, "EggMetDate should be null when date components are all 0."); // Ensure MetDate gives correct date pk.EggMetDay = 10; pk.EggMetMonth = 8; pk.EggMetYear = 16; Assert.AreEqual(new DateTime(2016, 8, 10).Date, pk.EggMetDate.Value.Date, "Egg met date does not return correct date."); }