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() { Dog dog = new Dog("51000", new SimpleDate(01, 05, 1997), "Peter", new SimpleDate(02, 06, 2011)); string dogstring = dog.ToString(); Assert.AreEqual("51000, 01-05-1997, Peter, not reserved, 350, 02-06-2011", dogstring); dog.IsReserved = true; dogstring = dog.ToString(); Assert.AreEqual("51000, 01-05-1997, Peter, reserved, 350, 02-06-2011", dogstring); dog = new Dog("51000", new SimpleDate(01, 05, 1997), "", new SimpleDate(02, 06, 2011)); dogstring = dog.ToString(); Assert.AreEqual("51000, 01-05-1997, noname, not reserved, 350, 02-06-2011", dogstring); dog = new Dog("51000", new SimpleDate(01, 05, 1997), null, new SimpleDate(02, 06, 2011)); dogstring = dog.ToString(); Assert.AreEqual("51000, 01-05-1997, noname, not reserved, 350, 02-06-2011", dogstring); }
public void TestDogNoValuesToString() { Dog dog3 = new Dog("12334", null, null, "Reserved", new SimpleDate(6, 10, 2015)); string s = "12334" + ", " + "00-00-0000" + ", " + "noname" + ", " + "Reserved" + ", " + "€ " + "0,00" + ", " + "06-10-2015"; Assert.AreEqual(s, dog3.ToString()); }