Exemple #1
0
        public void Destroy_ReturnsCorrectView_True()
        {
            //Arrange
            BagItemsController controller = new BagItemsController();

            //Act
            ActionResult destroyView = controller.Destroy();

            //Assert
            Assert.IsInstanceOfType(destroyView, typeof(ViewResult));
        }
Exemple #2
0
        public void New_ReturnsCorrectView_True()
        {
            //Arrange
            BagItemsController controller = new BagItemsController();

            //Act
            ActionResult newView = controller.New();

            //Assert
            Assert.IsInstanceOfType(newView, typeof(ViewResult));
        }
Exemple #3
0
        public void Index_HasCorrectModelType_BagItemList()
        {
            //Arrange
            BagItemsController controller = new BagItemsController();
            ViewResult         indexView  = controller.Index() as ViewResult;

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

            //Assert
            Assert.IsInstanceOfType(result, typeof(List <BagItem>));
        }
Exemple #4
0
        public void Show_HasCorrectModelType_BagItem()
        {
            //Arrange
            BagItemsController controller  = new BagItemsController();
            BagItem            testBagItem = new BagItem("camera", 1, 2, true);
            ViewResult         findView    = controller.Show(testBagItem.GetId()) as ViewResult;

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

            //Assert
            Assert.IsInstanceOfType(result, typeof(BagItem));
        }
Exemple #5
0
        public void Create_ReturnsCorrectView_True()
        {
            //Arrange
            BagItemsController controller = new BagItemsController();

            //Act
            string       nameOfItem = "camera";
            int          price      = 1000;
            int          weight     = 5;
            bool         packed     = true;
            ActionResult indexView  = controller.Create(nameOfItem, price, weight, packed);

            //Assert
            Assert.IsInstanceOfType(indexView, typeof(RedirectToActionResult));
        }
Exemple #6
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));
        }
Exemple #7
0
        public void Create_RedirectsToCorrectAction_Index()
        {
            //Arrange
            BagItemsController controller = new BagItemsController();
            string             nameOfItem = "camera";
            int  price  = 1000;
            int  weight = 5;
            bool packed = true;
            RedirectToActionResult actionResult = controller.Create(nameOfItem, price, weight, packed) as RedirectToActionResult;

            //Act
            string result = actionResult.ActionName;

            //Assert
            Assert.AreEqual(result, "Index");
        }
Exemple #8
0
        public void Show_HasCorrectModelType_Dictionary()
        {
            //Arrange
            BagItemsController controller = new BagItemsController();
            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(), testBagItem.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>));
        }