Ejemplo n.º 1
0
        public void GetPet_ShouldReturnPetWithSameID()
        {
            var demo    = GetDemoPet();
            var context = new TestPetQuestContext();

            context.Pets.Add(demo);

            var controller = new PetsController(context);
            var result     = controller.GetPet(3) as OkNegotiatedContentResult <Pet>;

            Assert.IsNotNull(result);
            Assert.AreEqual(3, result.Content.ID);
        }
Ejemplo n.º 2
0
        public void DeleteProduct_ShouldReturnOK()
        {
            var context = new TestPetQuestContext();
            var item    = GetDemoPet();

            context.Pets.Add(item);

            var controller = new PetsController(context);
            var result     = controller.DeletePet(3) as OkNegotiatedContentResult <Pet>;

            Assert.IsNotNull(result);
            Assert.AreEqual(item.ID, result.Content.ID);
        }
Ejemplo n.º 3
0
        public void GetPets_ShouldReturnAllPets()
        {
            var context = new TestPetQuestContext();

            context.Pets.Add(new Pet {
                Name = "Demo1", Location = "Demo"
            });
            context.Pets.Add(new Pet {
                Name = "Demo2", Location = "Demo"
            });
            context.Pets.Add(new Pet {
                Name = "Demo3", Location = "Demo"
            });

            var controller = new PetsController(context);
            var result     = controller.GetPets() as TestPetDbSet;

            Assert.IsNotNull(result);
            Assert.AreEqual(3, result.Local.Count);
        }