Esempio n. 1
0
        public void Can_Add_Ingredient_To_Pantry()
        {
            var mockIngredientsRepos = new Moq.Mock <IIngredientsRepository>();
            var ingredients          = new System.Collections.Generic.List <Ingredient>
            {
                new Ingredient {
                    IngredientID = 14, Name = "Milk"
                },
                new Ingredient {
                    IngredientID = 27, Name = "Eggs"
                }
            };

            mockIngredientsRepos.Setup(x => x.Ingredients)
            .Returns(ingredients.AsQueryable());

            var pantry     = new Pantry();
            var controller = new PantryController(mockIngredientsRepos.Object);


            RedirectToRouteResult result =
                controller.AddToPantry(pantry, 27, "someReturnUrl");

            Assert.AreEqual(1, pantry.Lines.Count);
            Assert.AreEqual("Eggs", pantry.Lines[0].Ingredient.Name);
            Assert.AreEqual(1, pantry.Lines[0].Quantity);

            // Проверить, что посетитель перенаправлен на экран отображения кладовой
            Assert.AreEqual("Index", result.RouteValues["action"]);
            Assert.AreEqual("someReturnUrl", result.RouteValues["returnUrl"]);
        }
Esempio n. 2
0
        public void Can_Add_Items_To_Pantry()
        {
            Ingredient i1 = new Ingredient {
                IngredientID = 1
            };
            Ingredient i2 = new Ingredient {
                IngredientID = 2
            };

            //Добавить 3 ингредиента, из них два одинаковы
            Pantry pantry = new Pantry();

            pantry.AddItem(i1, 1);
            pantry.AddItem(i1, 2);
            pantry.AddItem(i2, 10);

            Assert.AreEqual(2, pantry.Lines.Count,
                            "Wrong number of lines in the pantry");

            var i1Line = pantry.Lines.Where(l => l.Ingredient.IngredientID == 1).First();
            var i2Line = pantry.Lines.Where(l => l.Ingredient.IngredientID == 2).First();

            Assert.AreEqual(3, i1Line.Quantity);
            Assert.AreEqual(10, i2Line.Quantity);
        }
        public void IngredientNameSearchTest()
        {
            Pantry.Ingredients = new ObservableCollection <Ingredient>()
            {
                new Ingredient("Milk", new Measurement(1f, Unit.Gallon)),
                new Ingredient("Bleu Cheese Dressing", new Measurement(16.7f, Unit.Ounce)),
                new Ingredient("Sugar", new Measurement(1f, Unit.Pound)),
                new Ingredient("Baking Powder", new Measurement(24f, Unit.Tablespoon)),
                new Ingredient("Shredded Cheese", new Measurement(12f, Unit.Cup)),
                new Ingredient("Cheese", new Measurement(4.5f, Unit.Cup)),
                new Ingredient("Salt", new Measurement(243.67f, Unit.Kilogram))
            };

            string query = "cheese";
            ObservableCollection <Ingredient> results = Pantry.IngredientNameSearch(query);

            ObservableCollection <Ingredient> expectedResults = new ObservableCollection <Ingredient>()
            {
                new Ingredient("Bleu Cheese Dressing", new Measurement(16.7f, Unit.Ounce)),
                new Ingredient("Shredded Cheese", new Measurement(12f, Unit.Cup)),
                new Ingredient("Cheese", new Measurement(4.5f, Unit.Cup)),
            };

            Assert.AreEqual(expectedResults.Count, results.Count);
            for (int i = 0; i < results.Count; i++)
            {
                Assert.AreEqual(expectedResults[i].ToString(), results[i].ToString());
            }
        }
Esempio n. 4
0
        public ActionResult update(int id)
        {
            Pantry pantry = pantryRepository.Pantrys.Where(x => x.PantryID == id).First();

            Session["PantryID"] = id;
            return(View(pantry));
        }
Esempio n. 5
0
 public RedirectToRouteResult update(Pantry pantry)
 {
     pantry.PantryID = (int)Session["PantryID"];
     pantryRepository.updatePantry(pantry);
     pantryRepository.save();
     return(RedirectToAction("Index", "Food"));
 }
        private async Task <PantryViewModel> CreatePantryViewModelFromPantryAsync(Pantry pantry)
        {
            var pantryViewModel = new PantryViewModel
            {
                Id      = pantry.Id,
                OwnerId = pantry.OwnerId
            };

            foreach (var pantryItem in pantry.Items)
            {
                var pantryItemViewModel = new PantryItemViewModel
                {
                    Id            = pantryItem.Id,
                    CatalogItemId = pantryItem.CatalogItemId
                };

                var catalogItem = await _catalogItemRepository.GetAsync(pantryItem.CatalogItemId);

                pantryItemViewModel.ProductId         = catalogItem.ProductId;
                pantryItemViewModel.ProductName       = catalogItem.ProductName;
                pantryItemViewModel.ProductPictureUrl = catalogItem.ProductPictureUrl;
                pantryViewModel.Items.Add(pantryItemViewModel);
            }

            return(pantryViewModel);
        }
Esempio n. 7
0
        public void Pantry_ToDatabaseModel_ShouldMapNullPantry()
        {
            Pantry pantry = null;

            DB.Pantry dbPantry = EntityMapper.ToDatabaseModel(pantry);
            dbPantry.Should().BeNull();
        }
Esempio n. 8
0
        public static void Initialize(ToastCoreContext context)
        {
            //context.Database.EnsureDeleted(); //Execute this command when updating the model
            context.Database.EnsureCreated();


            if (!context.Toasters.Any())
            {
                var toaster = new Toaster
                {
                    Profile    = 0,
                    Status     = Status.Off,
                    NumToasts  = 0,
                    Time       = 0,
                    TimeStart  = new DateTime().ToString(),
                    TimeEnd    = new DateTime().ToString(),
                    ToastsMade = 0
                };

                context.Toasters.Add(toaster);
                context.SaveChanges();
            }

            if (!context.Pantries.Any())
            {
                var pantry = new Pantry
                {
                    NumberOfBreads = 100,
                    Status         = PantryStatus.Full
                };

                context.Pantries.Add(pantry);
                context.SaveChanges();
            }
        }
Esempio n. 9
0
        public void CanUpdatePantry()
        {
            // setup
            MyContext             mc               = new MyContext();
            MockIFoodRepository   foodRepository   = new MockIFoodRepository(mc);
            MockIPantryRepository pantryRepository = new MockIPantryRepository(mc);
            FoodController        controller       = new FoodController(foodRepository, pantryRepository);
            Pantry p = new Pantry {
                PantryID = 0, Units = 35
            };

            // execute food update
            // have to create a new controller context and make the httpcontext equal fakehttpcontext so the controller can
            // use the session when testing
            controller.ControllerContext = new System.Web.Mvc.ControllerContext()
            {
                HttpContext = FakeHttpContext()
            };
            controller.update(0);
            controller.update(p);

            // assert food has been updated
            p = pantryRepository.Pantrys.Select(x => x).Where(x => x.PantryID == 0).First();
            Assert.AreEqual(35, p.Units);
        }
Esempio n. 10
0
            public void delete(int id)
            {
                Pantry p = c.pantrys.Select(x => x).Where(x => x.PantryID == id).First();

                c.pantrys.Remove(p);
                c.pantrys.Select(x => x);
            }
Esempio n. 11
0
        public async Task <IActionResult> PutPantry([FromRoute] int id, [FromBody] Pantry pantry)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            if (id != pantry.Id)
            {
                return(BadRequest());
            }

            _context.Entry(pantry).State = EntityState.Modified;

            try
            {
                await _context.SaveChangesAsync();
            }
            catch (DbUpdateConcurrencyException)
            {
                if (!PantryExists(id))
                {
                    return(NotFound());
                }
                else
                {
                    throw;
                }
            }

            return(NoContent());
        }
Esempio n. 12
0
        public void Pantry_ToDomainModel_ShouldMapNullPantry()
        {
            DB.Pantry dbPantry = null;
            Pantry    pantry   = EntityMapper.ToDomainModel(dbPantry);

            pantry.Should().BeNull();
        }
Esempio n. 13
0
        public bool PrepareRecipe(Recipe selectedRecipe)
        {
            bool haveAllIngredients = true;

            foreach (Ingredients i in selectedRecipe.Ingredients)
            {
                int result;
                Pantry.TryGetValue(i.Name.ToString(), out result);


                if (result == 0)
                {
                    haveAllIngredients = false;
                }
            }

            if (haveAllIngredients == true)
            {
                foreach (Ingredients i in selectedRecipe.Ingredients)
                {
                    Pantry[i.Name.ToString()] -= 1;
                }
                return(true);
            }
            else
            {
                return(false);
            }
        }
Esempio n. 14
0
        public async Task <IActionResult> Edit(int id, [Bind("ID,Name")] Pantry pantry)
        {
            if (id != pantry.ID)
            {
                return(NotFound());
            }

            if (ModelState.IsValid)
            {
                try
                {
                    _context.Update(pantry);
                    await _context.SaveChangesAsync();
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!PantryExists(pantry.ID))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }
                return(RedirectToAction(nameof(Index)));
            }
            return(View(pantry));
        }
Esempio n. 15
0
 public void Ingredients()
 {
     Pantry s = new Pantry();
     Ingredient mince = s.Find("Prime Beef Mince").Ingredient;
     Ingredient onion = s.Find("Onion").Ingredient.Prepare("Chopped");
     Ingredient beans = s.Find("Mexican Beans", "Can").Ingredient;
 }
Esempio n. 16
0
        public void CreateAndInsertIntoPantryTable()
        {
            var db            = new DatabaseStuff();
            var PantryColumns = new List <string>()
            {
                "Pantry_Id int not null identity(1,1) primary key",
                "Name nvarchar(60) not null",
                "Ounces_Consumed decimal(6,2) not null",
                "Ounces_Remaining decimal(6,2) not null",
                "Expired int not null",
                "Expiring_Soon int not null",
                "Restock_Required int not null"
            };

            using (var context = new RachelsRosesMobileDevelopmentEntities()) {
                db.RecreateDatabase(context, "Pantry", PantryColumns);
                var pan = new Pantry();
                pan.Pantry_Id        = 1;
                pan.Name             = "Bread Flour";
                pan.Ounces_Consumed  = 32.4m;
                pan.Ounces_Remaining = 47.6m;
                pan.Expired          = 0;
                pan.Expiring_Soon    = 0;
                pan.Restock_Required = 0;
                context.Pantry.Add(pan);
                context.SaveChanges();

                var pantryCount =
                    (from p in context.Pantry
                     select p).Count();
                Assert.AreEqual(1, pantryCount);
            }
        }
Esempio n. 17
0
        public async Task <IActionResult> PostPantry([FromBody] Pantry pantry)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            _context.Pantry.Add(pantry);
            try
            {
                await _context.SaveChangesAsync();

                this.stockRepository.InitialPantryStock(pantry.Id);
            }
            catch (DbUpdateException)
            {
                if (PantryExists(pantry.Id))
                {
                    return(new StatusCodeResult(StatusCodes.Status409Conflict));
                }
                else
                {
                    throw;
                }
            }

            return(CreatedAtAction("GetPantry", new { id = pantry.Id }, pantry));
        }
Esempio n. 18
0
        public void PutBreads(int nBreads)
        {
            Pantry pantry = db.Pantries.FirstOrDefault();

            pantry.NumberOfBreads = nBreads;

            db.SaveChanges();
        }
Esempio n. 19
0
        public RedirectToRouteResult RemoveFromPantry(Pantry pantry,
                                                      int ingredientId, string returnUrl)
        {
            Ingredient ingredient = ingredientsRepository.Ingredients
                                    .FirstOrDefault(i => i.IngredientID == ingredientId);

            pantry.RemoveLine(ingredient);
            return(RedirectToAction("Index", new { returnUrl }));
        }
Esempio n. 20
0
        public void Can_Be_Cleared()
        {
            Pantry pantry = new Pantry();

            pantry.AddItem(new Ingredient(), 1);
            Assert.AreEqual(1, pantry.Lines.Count);
            pantry.Clear();
            Assert.AreEqual(0, pantry.Lines.Count);
        }
Esempio n. 21
0
        public RedirectToRouteResult AddToPantry(Pantry pantry,
                                                 int ingredientId, string returnUrl)
        {
            Ingredient ingredient = ingredientsRepository.Ingredients
                                    .FirstOrDefault(i => i.IngredientID == ingredientId);

            pantry.AddItem(ingredient, 1);
            return(RedirectToAction("Index", new { returnUrl }));
        }
Esempio n. 22
0
        public void Summary_Action_Renders_Default_View_With_Pantry()
        {
            Pantry           pantry     = new Pantry();
            PantryController controller = new PantryController(null);

            ViewResult result = controller.Summary(pantry);

            Assert.IsEmpty(result.ViewName);
            Assert.AreSame(pantry, result.ViewData.Model);
        }
Esempio n. 23
0
        public void Count2()
        {
            var pantry = new Pantry();

            pantry.Purchase(new Item("sugar"));
            pantry.Purchase(new Item("sugar"));
            pantry.Purchase(new Item("cheerios"));
            pantry.Purchase(new Item("cheerios"));
            Assert.That(pantry.Count(), Is.EqualTo(4), "pantry count not 4");
        }
        public Pantry AddPantryToOffice(Pantry pantry)
        {
            using (var context = _contextScopeFactory.Create(DbContextScopeOption.ForceCreateNew))
            {
                _contextLocator.Get <DataContext>().Pantry.Add(pantry);
                context.SaveChanges();
            }

            return(pantry);
        }
        private async Task <Pantry> CreatePantryForOwnerAsync(string ownerId)
        {
            var pantry = new Pantry {
                OwnerId = ownerId
            };

            await _pantryRepository.AddAsync(pantry);

            return(pantry);
        }
Esempio n. 26
0
        public async Task <IActionResult> OnPostAsync(string returnUrl = null)
        {
            returnUrl      = returnUrl ?? Url.Content("~/");
            ExternalLogins = (await _signInManager.GetExternalAuthenticationSchemesAsync()).ToList();
            if (ModelState.IsValid)
            {
                var user = new ApplicationUser {
                    UserName = Input.Email, Email = Input.Email,
                    Name     = Input.Name
                };
                var pantry = new Pantry();

                _context.Pantries.Add(pantry);

                await _context.SaveChangesAsync();

                user.PantryId = pantry.Id;
                var groceryList = new GroceryList()
                {
                    PantryId = pantry.Id
                };
                _context.GroceryLists.Add(groceryList);

                var result = await _userManager.CreateAsync(user, Input.Password);

                if (result.Succeeded)
                {
                    _logger.LogInformation("User created a new account with password.");

                    var code = await _userManager.GenerateEmailConfirmationTokenAsync(user);

                    code = WebEncoders.Base64UrlEncode(Encoding.UTF8.GetBytes(code));
                    var callbackUrl = Url.Page(
                        "/Account/ConfirmEmail",
                        pageHandler: null,
                        values: new { area = "Identity", userId = user.Id, code = code },
                        protocol: Request.Scheme);

                    await _emailSender.SendEmailAsync(Input.Email, "Confirm your email",
                                                      $"Please confirm your account by <a href='{HtmlEncoder.Default.Encode(callbackUrl)}'>clicking here</a>.");


                    await _signInManager.SignInAsync(user, isPersistent : false);

                    return(LocalRedirect(returnUrl));
                }
                foreach (var error in result.Errors)
                {
                    ModelState.AddModelError(string.Empty, error.Description);
                }
            }

            // If we got this far, something failed, redisplay form
            return(Page());
        }
Esempio n. 27
0
        // to save to database
        public async Task PantrySaveAsync(Pantry pantryItem)
        {
            //do not allow save of invalid data//
            if (!pantryItem.IsValid())
            {
                throw new ApplicationException("Pantry Item is not valid.");
            }

            // insert new or update existing//
            await _database.InsertOrReplaceAsync(pantryItem).ConfigureAwait(false);
        }
Esempio n. 28
0
        /// <summary>
        /// this method adds the food the user selected from the addFood method to the user's pantry
        /// </summary>
        /// <param name="user">The object that holds the logged in user, you don't need to pass this in
        /// it is model binded and passed for you</param>
        /// <param name="id">the id of the food to add to the pantry</param>
        /// <returns>a view of the updated food list</returns>
        public RedirectToRouteResult addFoods(User user, int id)
        {
            Pantry p = new Pantry()
            {
                UserID = (int)user.UserID, FoodID = id
            };

            pantryRepository.add(p);
            pantryRepository.save();
            return(RedirectToAction("Index", "Food"));
        }
Esempio n. 29
0
        public async Task <IActionResult> Create([Bind("ID,Name")] Pantry pantry)
        {
            if (ModelState.IsValid)
            {
                _context.Add(pantry);
                await _context.SaveChangesAsync();

                return(RedirectToAction(nameof(Index)));
            }
            return(View(pantry));
        }
        public void AddNewIngredientTest_IngredientCount()
        {
            Pantry.Ingredients = new ObservableCollection <Ingredient>();

            Pantry.AddNewIngredient("Milk", new Measurement(1f, Unit.Gallon));
            Pantry.AddNewIngredient("Sugar", new Measurement(1f, Unit.Pound));
            Pantry.AddNewIngredient("Baking Powder", new Measurement(24f, Unit.Tablespoon));
            Pantry.AddNewIngredient("Salt", new Measurement(243.67f, Unit.Kilogram));

            Assert.AreEqual(4, Pantry.Ingredients.Count);
        }
Esempio n. 31
0
        public void Index_Action_Renders_Default_View_With_Pantry_And_Return_Url()
        {
            Pantry           pantry     = new Pantry();
            PantryController controller = new PantryController(null);

            ViewResult result = controller.Index(pantry, "myReturnUrl");

            Assert.IsEmpty(result.ViewName); // Визуализировать представление по умолчанию
            Assert.AreSame(pantry, result.ViewData.Model);
            Assert.AreEqual("myReturnUrl", result.ViewData["returnUrl"]);
            Assert.AreEqual("Pantry", result.ViewData["CurrentCategory"]);
        }
Esempio n. 32
0
        public void Pantry()
        {
            Pantry s = new Pantry();
            Ingredient mince = s.Find("Prime Beef Mince").Ingredient;
            Ingredient onion = s.Find("Onion").Ingredient.Prepare("Chopped");
            Ingredient beans = s.Find("Mexican Beans", "Can").Ingredient;

            Recipe r = new Recipe();
            r.IngredientsRequired.Add(Measure.Weight<Grams>(500), mince);
            r.IngredientsRequired.Add(Measure.Quantity<Units>(0.5), onion);
            r.IngredientsRequired.Add(Measure.Quantity<Units>(1), beans);
        }
Esempio n. 33
0
            public void Item_Is_Not_Added_If_Description_Is_Not_Provided()
            {
                Pantry pantry = new Pantry();

                Item item = new Item();

                CollectionAssert.DoesNotContain(pantry.Items, item, "PRECONDITION FAILURE: item is already in the collection!");

                pantry.AddItem(item);

                CollectionAssert.DoesNotContain(pantry.Items, item);
            }
Esempio n. 34
0
            public void Item_Is_In_Pantry()
            {
                Pantry pantry = new Pantry();

                const string DESCRIPTION = "description";

                Item item = new Item() { Description = DESCRIPTION };

                CollectionAssert.DoesNotContain(pantry.Items, item, "PRECONDITION FAILURE: item is already in the collection!");

                pantry.AddItem(item);

                CollectionAssert.Contains(pantry.Items, item);
            }
Esempio n. 35
0
        public async Task<Pantry> GetPantryByUserIdAsync(string userId)
        {
            var pantryFromDb = await _context.Pantries
                                .Where(pantry => pantry.UserId == userId)
                                .Include(pantry => pantry.PantryItems).FirstOrDefaultAsync();

            if (pantryFromDb != null)
            {
                return pantryFromDb;
            }



            var newPantry = new Pantry
            {
                UserId = userId
            };

            _context.Pantries.Add(newPantry);
            await _context.SaveChangesAsync();
            return newPantry;
        }
Esempio n. 36
0
            public void Can_Increase_Quantity_of_Existing_Item()
            {
                Pantry pantry = new Pantry();

                const string DESCRIPTION = "sugar";

                Item sugar = new Item() { Description = DESCRIPTION };
                sugar.AssignQuantity(3);

                //ensure there aren't already any 'sugar' items in the pantry
                Assert.Throws<InvalidOperationException>(() => pantry.Items.Where(i => i.Description == DESCRIPTION).Single());

                pantry.AddItem(sugar);

                Item moreSugar = new Item() { Description = DESCRIPTION };
                moreSugar.AssignQuantity(4);

                pantry.AddItem(moreSugar);

                var pantrySugar = pantry.Items.Where(i => i.Description == DESCRIPTION).Single();

                Assert.AreEqual(7, pantrySugar.Quantity);
            }
Esempio n. 37
0
            public void Can_Prevent_Name_Collisions()
            {
                const string INITIAL_DESCRIPTION = "sugar";
                const string NEW_DESCRIPTION = "brown sugar";

                Pantry pantry = new Pantry();

                Item sugar = new Item() { Description = INITIAL_DESCRIPTION };

                Item brownSugar = new Item() { Description = NEW_DESCRIPTION };

                pantry.AddItem(sugar);
                pantry.AddItem(brownSugar);

                Assert.IsFalse(pantry.TryUpdateItemDescription(NEW_DESCRIPTION, INITIAL_DESCRIPTION));
            }
Esempio n. 38
0
            public void Can_Indicate_Invalid_Action()
            {
                const string NOT_THE_DESCRIPTION = "flour";
                const string INITIAL_DESCRIPTION = "sugar";
                const string NEW_DERSCRIPTION = "brown sugar";

                Pantry pantry = new Pantry();

                Item notTheItem = new Item() { Description = NOT_THE_DESCRIPTION };

                pantry.AddItem(notTheItem);

                Assert.IsFalse(pantry.Items.Any(i => i.Description == INITIAL_DESCRIPTION), "PRECONDITION ASSERT FAILURE: cannot enforce needed pre-test condition re: collection members!");
                Assert.IsFalse(pantry.Items.Any(i => i.Description == NEW_DERSCRIPTION), "PRECONDITION ASSERT FAILURE: cannot enforce needed pre-test condition re: collection members!");

                Assert.IsFalse(pantry.TryUpdateItemDescription(INITIAL_DESCRIPTION, NEW_DERSCRIPTION));
            }
Esempio n. 39
0
            public void Item_Is_Removed_from_the_Pantry()
            {
                const string DESCRIPTION_TO_REMOVE = "sugar";
                const string DESCRIPTION_NOT_TO_REMOVE = "flour";

                Pantry pantry = new Pantry();

                Item sugar = new Item() { Description = DESCRIPTION_TO_REMOVE };
                Item flour = new Item() { Description = DESCRIPTION_NOT_TO_REMOVE };

                pantry.AddItem(sugar);
                pantry.AddItem(flour);

                CollectionAssert.Contains(pantry.Items, sugar, "PRECONDITION ASSERT FAILURE: pantry.Items doesn't contain expected item!");
                CollectionAssert.Contains(pantry.Items, flour, "PRECONDITION ASSERT FAILURE: pantry.Items doesn't contain expected item!");

                pantry.RemoveItem(DESCRIPTION_TO_REMOVE);

                CollectionAssert.DoesNotContain(pantry.Items, sugar);
            }
Esempio n. 40
0
            public void Can_Report_Items_as_Expected()
            {
                const string ITEM1_DESCRIPTION = "sugar";
                const int ITEM1_QUANTITY = 3;

                const string ITEM2_DESCRIPTION = "flour";
                const int ITEM2_QUANTITY = 1;

                Pantry pantry = new Pantry();

                Item sugar = new Item() { Description = ITEM1_DESCRIPTION };
                sugar.AssignQuantity(ITEM1_QUANTITY);

                Item flour = new Item() { Description = ITEM2_DESCRIPTION };
                flour.AssignQuantity(ITEM2_QUANTITY);

                pantry.AddItem(sugar);
                pantry.AddItem(flour);

                string itemsReport = pantry.ReportOnItems();

                Assert.AreEqual(string.Format("{0}: {1}\r\n{2}: {3}\r\n", ITEM1_DESCRIPTION, ITEM1_QUANTITY, ITEM2_DESCRIPTION, ITEM2_QUANTITY), itemsReport);
            }
Esempio n. 41
0
            public void Can_Change_Item_Description()
            {
                const string ITEM_TO_RENAME = "sugar";
                const string ITEM_NOT_TO_RENAME = "flour";
                const string NEW_NAME = "brown sugar";

                Pantry pantry = new Pantry();

                Item theItem = new Item() { Description = ITEM_TO_RENAME };
                Item notTheItem = new Item() { Description = ITEM_NOT_TO_RENAME };

                pantry.AddItem(theItem);
                pantry.AddItem(notTheItem);

                Assert.IsFalse(pantry.Items.Any(i => i.Description == NEW_NAME), "PRECONDITION ASSERT FAILURE: Items collection should not contain item with the new item name!");

                Assert.IsTrue(pantry.TryUpdateItemDescription(ITEM_TO_RENAME, NEW_NAME));
                Assert.IsTrue(pantry.Items.Any(i => i.Description == NEW_NAME));
            }
Esempio n. 42
0
            public void Can_Report_Pantry_Is_Empty()
            {
                const string EMPTY_PANTRY_MESSAGE = "The Pantry is bare!";

                Pantry pantry = new Pantry();

                CollectionAssert.IsEmpty(pantry.Items, "PRECONDITION ASSERT FAILURE: pantry.Items is NOT empty as expected!");

                Assert.AreEqual(EMPTY_PANTRY_MESSAGE.ToUpper(), pantry.ReportOnItems().ToUpper());
            }