public void BuyToSupermarket() { var controller = new IToast.Controllers.PantryController(); int breadsToBuy = 20; int howManyBreadsBeforeBuying = controller.HowManyBreads(); controller.BuyToSupermarket(breadsToBuy); int howManyBreadsAfterBuying = controller.HowManyBreads(); Assert.AreEqual(howManyBreadsAfterBuying - howManyBreadsBeforeBuying, breadsToBuy, "Buying " + breadsToBuy + " breads correctly"); }
public void GetBreads_ShouldTwoBreadsMinus() { var controller = new IToast.Controllers.PantryController(); controller.PutBreads(50); int toasts = 2; int howManyBreadsBeforeToasting = controller.HowManyBreads(); controller.GetBreads(toasts); int howManyBreadsAfterToasting = controller.HowManyBreads(); Assert.AreEqual(howManyBreadsBeforeToasting - howManyBreadsAfterToasting, toasts); }
public int SetToasts(int numToasts) { if (numToasts > 2) { throw new Exception("The maximum number of toasts is 2."); } Toaster toaster = db.Toasters.FirstOrDefault(); PantryController pantry = new PantryController(); if (pantry.HowManyBreads() >= 0) { toaster.NumToasts = pantry.GetBreads(numToasts); } db.Entry(toaster).State = EntityState.Modified; try { db.SaveChanges(); } catch (DbUpdateConcurrencyException) { throw; } return(toaster.NumToasts); }
public void PutBreads_ShouldReturn50BreadsInPantry() { var controller = new IToast.Controllers.PantryController(); controller.PutBreads(50); int howmanybreads = controller.HowManyBreads(); Assert.IsTrue(howmanybreads == 50, "There are 50 breads in pantry"); }
public void HowManyBreads_ShouldReturnMoreThanOneBread() { var controller = new IToast.Controllers.PantryController(); Assert.IsTrue(controller.HowManyBreads() > 0, "True, has more almost one bread"); }