public void Controller_KioskSettings_Instantiate_Default_Should_Pass()
        {
            // Arrange
            var controller = new KioskSettingsController();

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

            // Assert
            Assert.AreEqual(result, new KioskSettingsController().GetType(), TestContext.TestName);
        }
        public void Controller_KioskSettings_Read_No_Id_Should_Return_Default_Model()
        {
            // Arrange
            var controller = new KioskSettingsController();

            var context = CreateMoqSetupForCookie();

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

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

            // Assert
            Assert.IsNotNull(result, TestContext.TestName);
        }
        public void Controller_KioskSettings_Post_Update_Null_Data_Should_Return_Error()
        {
            // Arrange
            var controller = new KioskSettingsController();

            var context = CreateMoqSetupForCookie();

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

            // Act
            var result = (RedirectToRouteResult)controller.Update((KioskSettingsModel)null);

            // Assert
            Assert.AreEqual("Error", result.RouteValues["action"], TestContext.TestName);
        }
        public void Controller_KioskSettings_Read_Invalid_Id_Should_Return_Error_Page()
        {
            // Arrange
            var    controller = new KioskSettingsController();
            string id         = "bogus";

            var context = CreateMoqSetupForCookie();

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

            // Act
            var result = (RedirectToRouteResult)controller.Read(id);

            // Assert
            Assert.AreEqual("Error", result.RouteValues["action"], TestContext.TestName);
            Assert.AreEqual("Home", result.RouteValues["controller"], TestContext.TestName);
        }
        public void Controller_KioskSettings_Update_Get_Default_Should_Pass()
        {
            // Arrange
            var controller = new KioskSettingsController();

            string id = DataSourceBackend.Instance.KioskSettingsBackend.GetDefault().Id;

            var context = CreateMoqSetupForCookie();

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

            // Act
            var result = (ViewResult)controller.Update(id);

            // Assert
            Assert.IsNotNull(result, TestContext.TestName);
        }
        public void Controller_KioskSettings_Post_Update_Default_Should_Return_Admin_Settings_Page()
        {
            // Arrange
            var controller = new KioskSettingsController();

            // Get default KioskSettingsModel
            KioskSettingsModel kioskSettingsModel = DataSourceBackend.Instance.KioskSettingsBackend.GetDefault();

            var context = CreateMoqSetupForCookie();

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

            // Act
            var result = (RedirectToRouteResult)controller.Update(kioskSettingsModel);

            // Assert
            Assert.AreEqual("Settings", result.RouteValues["action"], TestContext.TestName);
            Assert.AreEqual("Admin", result.RouteValues["controller"], TestContext.TestName);
        }
        public void Controller_KioskSettings_Post_Update_Invalid_Model_Should_Send_Back_For_Edit()
        {
            // Arrange
            var controller          = new KioskSettingsController();
            KioskSettingsModel data = new KioskSettingsModel();

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

            var context = CreateMoqSetupForCookie();

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

            // Act
            ViewResult result = (ViewResult)controller.Update(data);

            // Assert
            Assert.IsNotNull(result, TestContext.TestName);
        }
        public void Controller_KioskSettings_Post_Update_Empty_Id_Should_Send_Back_For_Edit()
        {
            // Arrange
            var controller = new KioskSettingsController();
            KioskSettingsModel dataEmpty = new KioskSettingsModel
            {
                // Make data.Id empty
                Id = ""
            };

            var context = CreateMoqSetupForCookie();

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

            // Act
            var resultEmpty = (ViewResult)controller.Update(dataEmpty);

            // Assert
            Assert.IsNotNull(resultEmpty, TestContext.TestName);
        }