public void WhenAddReminderPostWithNullReminder_ThenReturnsToCreatePage()
        {
            MockDefaultHandlers();

            ReminderController controller = GetTestableReminderController();

            ActionResult result = controller.Add(defaultVehicleId, null);

            Assert.IsType(typeof(ViewResult), result);
        }
        public void WhenAddReminderGetWithValidVehicleId_ThenReturnsView()
        {
            MockDefaultHandlers();

            ReminderController controller = GetTestableReminderController();

            ActionResult result = controller.Add(defaultVehicleId);

            Assert.IsType <ViewResult>(result);
        }
Exemplo n.º 3
0
        public void WhenAddReminderPostWithNullReminder_ThenReturnsToCreatePage()
        {
            MockDefaultHandlers();

            ReminderController controller = GetTestableReminderController();

            ActionResult result = controller.Add(defaultVehicleId, null);

            Assert.IsType(typeof(ContentTypeAwareResult), result);
            Assert.Equal(MileageStats.Web.Properties.Messages.PleaseFixInvalidData, controller.TempData["alert"]);
        }
Exemplo n.º 4
0
        public void WhenAddReminderPostWithInvalidReminder_ThenReturnsToCreatePage()
        {
            MockDefaultHandlers();

            ReminderController controller = GetTestableReminderController();

            controller.ModelState.AddModelError("test", "test error");

            var          reminderForm = new ReminderFormModel();
            ActionResult result       = controller.Add(defaultVehicleId, reminderForm);

            Assert.IsType(typeof(ContentTypeAwareResult), result);
        }
Exemplo n.º 5
0
        public void WhenAddReminderWithValidReminder_ThenReturnsToReminderListView()
        {
            var formModel = new ReminderFormModel();

            MockDefaultHandlers();

            MockHandlerFor <CanAddReminder>(
                x => x
                .Setup(h => h.Execute(_defaultUser.UserId, formModel))
                .Returns(new ValidationResult[] { }));

            MockHandlerFor <AddReminderToVehicle>(
                x => x.Setup(h => h.Execute(_defaultUser.UserId, defaultVehicleId, formModel)));

            ReminderController controller = GetTestableReminderController();
            var result = (RedirectToRouteResult)controller.Add(defaultVehicleId, formModel);

            Assert.NotNull(result);
            Assert.Equal("List", result.RouteValues["action"]);
            Assert.Equal("Reminder", result.RouteValues["controller"]);
        }