示例#1
0
        public void TestPetRepository()
        {
            Assert.AreEqual(0, petsRepository.Size());

            Pet pet1 = new Pet()
            {
                ID      = 1,
                Name    = "kiki",
                Age     = 12,
                Gender  = GenderEnum.FEMININ,
                Species = "koala"
            };

            Pet pet2 = new Pet()
            {
                ID      = 2,
                Name    = "mimi",
                Age     = 2,
                Gender  = GenderEnum.FEMININ,
                Species = "cat"
            };

            //test the save function
            petsRepository.Save(pet1);
            petsRepository.Save(pet2);
            Assert.AreEqual(2, petsRepository.Size());

            //test the find all
            List <Pet> allPets = new List <Pet>();

            foreach (Pet pet in petsRepository.FindAll())
            {
                allPets.Add(pet);
            }
            Assert.AreEqual(allPets[0].ID, 1);
            Assert.AreEqual(allPets[1].ID, 2);

            //test the find one
            Pet petFound = petsRepository.FindOne(1);

            Assert.AreEqual(petFound, pet1);
        }
示例#2
0
 public IEnumerable <Pet> findAllPets()
 {
     return(petsRepository.FindAll());
 }