示例#1
0
        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");
        }
示例#2
0
        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);
        }
示例#3
0
        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);
        }
示例#4
0
        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");
        }
示例#5
0
        public void HowManyBreads_ShouldReturnMoreThanOneBread()
        {
            var controller = new IToast.Controllers.PantryController();

            Assert.IsTrue(controller.HowManyBreads() > 0, "True, has more almost one bread");
        }