Esempio n. 1
0
        public void Controller_FactoryInventory_Instantiate_Default_Should_Pass()
        {
            // Arrange
            var controller = new FactoryInventoryController();

            // Act
            var result = controller.GetType();

            // Assert
            Assert.AreEqual(result, new FactoryInventoryController().GetType(), TestContext.TestName);
        }
Esempio n. 2
0
        public void Controller_FactoryInventory_Read_IDIsNull_Should_Pass()
        {
            // Arrange
            FactoryInventoryController controller = new FactoryInventoryController();
            string id = null;

            var context = CreateMoqSetupForCookie();

            controller.ControllerContext = new ControllerContext(context, new RouteData(), controller);

            // Act
            ViewResult result = controller.Read(id) as ViewResult;

            // Assert
            Assert.AreEqual(null, result.Model, TestContext.TestName);
        }
Esempio n. 3
0
        public void Controller_FactoryInventory_Index_Should_Pass()
        {
            // Arrange
            FactoryInventoryController controller = new FactoryInventoryController();

            var context = CreateMoqSetupForCookie();

            controller.ControllerContext = new ControllerContext(context, new RouteData(), controller);

            // Act
            ViewResult result = controller.Index() as ViewResult;

            var resultFactoryInventoryViewModel = result.Model as FactoryInventoryListViewModel;

            // Assert
            Assert.IsNotNull(resultFactoryInventoryViewModel, TestContext.TestName);
        }
Esempio n. 4
0
        public void Controller_FactoryInventory_Delete_IDIsNull_Should_Pass()
        {
            // Arrange
            FactoryInventoryController controller = new FactoryInventoryController();

            var context = CreateMoqSetupForCookie();

            controller.ControllerContext = new ControllerContext(context, new RouteData(), controller);

            // Act
            ViewResult result = controller.Delete() as ViewResult;

            // Reset FactoryInventoryBackend
            DataSourceBackend.Instance.Reset();

            // Assert
            Assert.AreEqual(null, result.Model, TestContext.TestName);
        }
Esempio n. 5
0
        public void Controller_FactoryInventory_Create_Get_Should_Return_New_Model()
        {
            // Arrange
            FactoryInventoryController controller = new FactoryInventoryController();

            var context = CreateMoqSetupForCookie();

            controller.ControllerContext = new ControllerContext(context, new RouteData(), controller);

            // Act
            ViewResult result = controller.Create() as ViewResult;
            var        resultFactoryInventoryModel = result.Model as FactoryInventoryModel;

            // Reset FactoryInventoryBackend
            DataSourceBackend.Instance.Reset();

            // Assert
            Assert.AreNotEqual(null, resultFactoryInventoryModel.Id, TestContext.TestName);
        }
Esempio n. 6
0
        public void Controller_FactoryInventory_Delete_Post_Valid_Should_Return_IndexPage()
        {
            // Arrange
            FactoryInventoryController controller = new FactoryInventoryController();
            FactoryInventoryModel      data       = new FactoryInventoryModel();

            var context = CreateMoqSetupForCookie();

            controller.ControllerContext = new ControllerContext(context, new RouteData(), controller);

            // Act
            var result = (RedirectToRouteResult)controller.Delete(data);
            var resultFactoryInventoryModel = FactoryInventoryBackend.Instance.Create(data);

            // Reset FactoryInventoryBackend
            DataSourceBackend.Instance.Reset();

            // Assert
            Assert.AreEqual("Index", result.RouteValues["action"], TestContext.TestName);
            Assert.AreEqual(data.Description, resultFactoryInventoryModel.Description, TestContext.TestName);
        }
Esempio n. 7
0
        public void Controller_FactoryInventory_Delete_IDValid_Should_Pass()
        {
            // Arrange
            FactoryInventoryController controller = new FactoryInventoryController();
            FactoryInventoryModel      data       = new FactoryInventoryModel();
            string id = Backend.FactoryInventoryBackend.Instance.Create(data).Id;

            var context = CreateMoqSetupForCookie();

            controller.ControllerContext = new ControllerContext(context, new RouteData(), controller);

            // Act
            ViewResult result = controller.Delete(id) as ViewResult;
            var        resultFactoryInventoryModel = result.Model as FactoryInventoryModel;

            // Reset FactoryInventoryBackend
            DataSourceBackend.Instance.Reset();

            // Assert
            Assert.IsNotNull(resultFactoryInventoryModel, TestContext.TestName);
        }
Esempio n. 8
0
        public void Controller_FactoryInventory_Delete_Post_ModelIsInvalid_Should_Pass()
        {
            // Arrange
            FactoryInventoryController controller = new FactoryInventoryController();
            FactoryInventoryModel      data       = new FactoryInventoryModel();

            // Make ModelState Invalid
            controller.ModelState.AddModelError("test", "test");

            var context = CreateMoqSetupForCookie();

            controller.ControllerContext = new ControllerContext(context, new RouteData(), controller);

            // Act
            ViewResult result = controller.Delete(data) as ViewResult;

            // Reset FactoryInventoryBackend
            DataSourceBackend.Instance.Reset();

            // Assert
            Assert.IsNotNull(result, TestContext.TestName);
        }
Esempio n. 9
0
        public void Controller_FactoryInventory_Delete_Post_Invalid_IDIsNull_Should_Return_Model()
        {
            // Arrange
            FactoryInventoryController controller = new FactoryInventoryController();
            FactoryInventoryModel      data       = new FactoryInventoryModel
            {
                Id = null
            };

            var context = CreateMoqSetupForCookie();

            controller.ControllerContext = new ControllerContext(context, new RouteData(), controller);

            // Act
            ViewResult result = controller.Delete(data) as ViewResult;
            var        resultFactoryInventoryModel = result.Model as FactoryInventoryModel;

            // Reset FactoryInventoryBackend
            DataSourceBackend.Instance.Reset();

            // Assert
            Assert.AreEqual(data.Description, resultFactoryInventoryModel.Description, TestContext.TestName);
        }