public void TestDB_SeedDelete_Deletes() { //Arrange OffersController offerController = new OffersController(dbOffers); SeedsController controller = new SeedsController(db); Offer newOffer = new Offer { OfferId = 20, Name = "HFBW" }; Seed newSeed = new Seed { SeedId = 20, Name = "Amaranht", Amount = 40, Description = "A plant", OfferId = 20 }; //Act offerController.Create(newOffer); controller.Create(newSeed); controller.DeleteConfirmed(newSeed.SeedId); var seedOutput = (controller.Index() as ViewResult).ViewData.Model as List <Seed>; //Assert CollectionAssert.DoesNotContain(seedOutput, newSeed); db.DeleteAll(); }
public void TestDB_SeedEdit_Updates() { //Arrange OffersController offerController = new OffersController(dbOffers); SeedsController controller = new SeedsController(db); Offer newOffer = new Offer { OfferId = 10, Name = "HFBW" }; Seed newSeed = new Seed { SeedId = 10, Name = "Amaranht", Amount = 40, Description = "A plant", OfferId = 10 }; //Act offerController.Create(newOffer); controller.Create(newSeed); newSeed.Name = "Amaranth"; controller.Edit(newSeed); var seedOutput = (controller.Details(10) as ViewResult).ViewData.Model as Seed; //Assert Assert.AreEqual(seedOutput.Name, "Amaranth"); db.DeleteAll(); }
public void TestDB_CreateSeed_Adds() { //Arrange OffersController offerController = new OffersController(dbOffers); SeedsController controller = new SeedsController(db); Offer newOffer = new Offer { OfferId = 1, Name = "HFBW" }; Seed newSeed = new Seed { SeedId = 100, Name = "Amaranth", Amount = 40, Description = "A plant", OfferId = 1 }; //Act offerController.Create(newOffer); controller.Create(newSeed); var newList = (controller.Index() as ViewResult).ViewData.Model as List <Seed>; //Assert CollectionAssert.Contains(newList, newSeed); db.DeleteAll(); }