public async Task VacationDelete() { VacationController controller = DependencyResolver.Current.GetService <VacationController>(); ViewResult getResult = await controller.Delete(3) as ViewResult; VacationDto model = getResult.Model as VacationDto; ActionResult postResult = await controller.Delete(model); Assert.IsTrue(postResult is RedirectToRouteResult); }
public void PostDeleteVacationNotNullEmployeeUnpaidVacation_true() { //Arrange VacationController controller = new VacationController(mock.Object); DateTime fromDate = DateTime.ParseExact("12.03.2014", "dd.MM.yyyy", null); DateTime toDate = DateTime.ParseExact("28.03.2014", "dd.MM.yyyy", null); Vacation vacation = (from vac in mock.Object.Vacations where vac.EmployeeID == 2 && vac.Type == VacationType.UnpaidVacation && vac.From == fromDate && vac.To == toDate select vac).FirstOrDefault(); //Act int id = 2; string type = "UnpaidVacation"; bool result = controller.Delete(id, "12.03.2014", "28.03.2014", type); //Assert Assert.IsTrue(result); mock.Verify(m => m.DeleteVacation(vacation.VacationID), Times.Once); }
public void PostDeleteVacationNotNullEmployeeBadTypeCorrectDate_false() { //Arrange VacationController controller = new VacationController(mock.Object); //Act int id = 1; string fromDate = "01.01.2014"; string toDate = "15.01.2014"; string type = "Bad Type"; bool result = controller.Delete(id, fromDate, toDate, type); //Assert Assert.IsFalse(result); }
public void PostDeleteVacationNotNullEmployeeBadTypeBadDate_false() { //Arrange VacationController controller = new VacationController(mock.Object); //Act int id = 1; string fromDate = ""; string toDate = ""; string type = "Bad Type"; bool result = controller.Delete(id, fromDate, toDate, type); //Assert Assert.IsFalse(result); mock.Verify(m => m.DeleteVacation(0), Times.Never); }
public void DeleteAction_ReturnsViewResult() { var mockDataAccessor = new Mock <IVacationPlannerDataAccessor>(); var httpContext = new DefaultHttpContext(); var tempData = new TempDataDictionary(httpContext, Mock.Of <ITempDataProvider>()); var httpCtx = new Mock <IHttpContextAccessor>(); mockDataAccessor.Setup(m => m.Locations).Returns(new Mock <IRepository <Location> >().Object); mockDataAccessor.Setup(m => m.Accommodations).Returns(new Mock <IRepository <Accommodation> >().Object); mockDataAccessor.Setup(m => m.Activities).Returns(new Mock <IRepository <Activity> >().Object); mockDataAccessor.Setup(m => m.Vacations).Returns(new Mock <IRepository <Vacation> >().Object); var controller = new VacationController(mockDataAccessor.Object, httpCtx.Object) { TempData = tempData }; var result = controller.Delete(1); Assert.IsType <ViewResult>(result); }