public void UpdatePet() { DbContextOptions <LoveThemBackAPIDbContext> options = new DbContextOptionsBuilder <LoveThemBackAPIDbContext>().UseInMemoryDatabase("UpdatePet") .Options; using (LoveThemBackAPIDbContext context = new LoveThemBackAPIDbContext(options)) { Pet TestPet = new Pet(); TestPet.PetID = 1; TestPet.Name = "Snooky"; var ServicesCreate = new PetsService(context); ServicesCreate.AddPet(TestPet); Pet UpdatePet = new Pet(); UpdatePet.PetID = 1; UpdatePet.Name = "Coolio"; ServicesCreate.UpdatePet(1, UpdatePet); var getPet = ServicesCreate.GetById(1); Assert.Equal("Coolio", getPet.Value.Name); } }
public void DeletePet() { DbContextOptions <LoveThemBackAPIDbContext> options = new DbContextOptionsBuilder <LoveThemBackAPIDbContext>().UseInMemoryDatabase("DeletePet") .Options; using (LoveThemBackAPIDbContext context = new LoveThemBackAPIDbContext(options)) { Pet TestPet = new Pet(); TestPet.PetID = 1; TestPet.Name = "Snooky"; var ServicesCreate = new PetsService(context); ServicesCreate.AddPet(TestPet); ServicesCreate.DeletePet(1, 8675309); var getPet = context.Pets.FirstOrDefault(x => x.PetID == 1); Assert.Null(getPet); } }