public void AnimalPropsTest() { //if chip is longer than 5 digits, just add the first 5; cat = new Cat("123456", simpleDate, "testAnimal", "badHabits"); Assert.AreEqual("12345", cat.ChipRegistrationNumber, "Chip failed when more than 5 digits are inserted"); //if chip is shorter than 5, add zeros before the chip until the chip has 5 digits cat = new Cat("1234", simpleDate, "testAnimal", "badHabits"); Assert.AreEqual("01234", cat.ChipRegistrationNumber, "Chip failed when less than 5 digits were inserted"); //Check rest of properties; Assert.AreEqual(simpleDate, cat.DateOfBirth, "Incorrect DateOfBirth"); Assert.AreEqual("testAnimal", cat.Name, "Incorrect Name"); Assert.AreEqual("01234, 06-11-1996, testAnimal, not reserved, badhabits: badHabits", cat.ToString()); //test null birthdate for cat cat = new Cat("1234", null, "testAnimal", "badHabits"); Assert.AreEqual("01234, 00-00-0000, testAnimal, not reserved, badhabits: badHabits", cat.ToString()); //test "" badhabits cat = new Cat("1234", null, "testAnimal", ""); Assert.AreEqual("01234, 00-00-0000, testAnimal, not reserved, badhabits: none", cat.ToString()); //special dog test Assert.AreEqual("12345, 06-11-1996, testdog, not reserved, lastWalkDate: 06-11-1996", dog.ToString()); dog = new Dog("12345", null, null, null); dog.IsReserved = true; Assert.AreEqual("12345, 00-00-0000, noname, reserved, lastWalkDate: 00-00-0000", dog.ToString()); }
public void TestToString() { Cat cat = new Cat("123", new SimpleDate(12, 03, 2015), "Henk", "Pees everywhere"); string catstring = cat.ToString(); Assert.AreEqual(catstring, "00123, 12-03-2015, Henk, not reserved, 45, Pees everywhere"); cat = new Cat("12345", null, "", ""); cat.IsReserved = true; catstring = cat.ToString(); Assert.AreEqual(catstring, "12345, 00-00-0000, noname, reserved, 60, "); }