Пример #1
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));
            }
Пример #2
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));
            }
Пример #3
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));
            }