Exemple #1
0
        public async Task DeleteConfirmed_Post_ModelIsValid_RedirectToIndex()
        {
            Mock <LeaveScheduleService> mock       = new Mock <LeaveScheduleService>();
            LeaveScheduleController     controller = GetNewLeaveScheduleController(mock.Object);

            RedirectToRouteResult result = (await controller.DeleteConfirmed(7)) as RedirectToRouteResult;

            Assert.AreEqual("Index", result.RouteValues["action"]);
        }
Exemple #2
0
        public async Task DeleteConfirmed_Post_DeleteAsyncMethodThrowsException_AsksForErrorView()
        {
            Mock <LeaveScheduleService> mock = new Mock <LeaveScheduleService>();

            mock.Setup(m => m.DeleteAsync(It.IsAny <int>())).Throws(new ValidationException("DeleteAsync method throws Exception", ""));
            LeaveScheduleController controller = GetNewLeaveScheduleController(mock.Object);

            ViewResult result = (await controller.DeleteConfirmed(7)) as ViewResult;

            Assert.AreEqual("Error", result.ViewName);
        }
Exemple #3
0
        public async Task DeleteConfirmed_Post_DeleteAsyncMethodThrowsException_RetrievesExceptionMessageFromModel()
        {
            Mock <LeaveScheduleService> mock = new Mock <LeaveScheduleService>();

            mock.Setup(m => m.DeleteAsync(It.IsAny <int>())).Throws(new ValidationException("DeleteAsync method throws Exception", ""));
            LeaveScheduleController controller = GetNewLeaveScheduleController(mock.Object);

            ViewResult result = (await controller.DeleteConfirmed(7)) as ViewResult;

            string[] model = result.ViewData.Model as string[];
            Assert.AreEqual("DeleteAsync method throws Exception", model[0]);
        }