Beispiel #1
0
        public void Show_ReturnsCorrectView_True()
        {
            //Arrange
            BagItemsController controller = new BagItemsController();
            Bag     testBag     = new Bag("Purse");
            BagItem testBagItem = new BagItem("camera", 1, 2, true);

            testBag.AddBagItem(testBagItem);

            //Act
            ActionResult showView = controller.Show(testBag.GetId(), testBagItem.GetId());

            //Assert
            Assert.IsInstanceOfType(showView, typeof(ViewResult));
        }
        public void Show_HasCorrectModelType_Dictionary()
        {
            //Arrange
            BagsController controller  = new BagsController();
            Bag            testBag     = new Bag("Purse");
            BagItem        testBagItem = new BagItem("camera", 1, 2, true);

            testBag.AddBagItem(testBagItem);
            Console.WriteLine(testBag.GetId());
            ViewResult showView = controller.Show(testBag.GetId()) as ViewResult;

            //Act
            var result = showView.ViewData.Model;

            Console.WriteLine(result.GetType());
            Console.WriteLine(typeof(Dictionary <string, object>));
            //Assert
            Assert.AreEqual(result.GetType(), typeof(Dictionary <string, object>));
        }
Beispiel #3
0
        public void AddBagItem_AssociatesBagItemWithBag_BagItemList()
        {
            //Arrange
            string         nameOfItem01   = "Camera";
            int            inputPrice01   = 500;
            int            inputWeight01  = 9;
            bool           packed01       = true;
            BagItem        newBagItem     = new BagItem(nameOfItem01, inputPrice01, inputWeight01, packed01);
            List <BagItem> newBagItemList = new List <BagItem> {
                newBagItem
            };                                                         //Expected List

            //Act
            string name   = "Clutch";
            Bag    newBag = new Bag(name);

            newBag.AddBagItem(newBagItem);
            List <BagItem> result = newBag.GetBagItems(); //Actual List

            //Assert
            CollectionAssert.AreEqual(newBagItemList, result);
        }