public void EditPostLoggedUserTest() { ModelsMocks.CleanUpBeforeTest(); ModelsMocks.AddTestProject(true); ModelsMocks.AddTestTask(true, ModelsMocks.ProjectModelFirst); ModelsMocks.AddTestWorklog(true, ModelsMocks.TaskModelFirst); // Arrange WorklogController controller = ControllersMocks.GetControllerAsLoggedUser <WorklogController>(); // Act JsonResult action = controller.Edit(ModelsMocks.WorklogModelSecond, ModelsMocks.ProjectModelFirst.ID, ModelsMocks.TaskModelFirst.ID, ModelsMocks.WorklogModelFirst.ID) as JsonResult; using (IUnityContainer container = UnityConfig.GetConfiguredContainer()) { var repo = container.Resolve <IWorklogRepository>(); var worklog = repo.GetWorklogByIdWithoutTracking(ModelsMocks.WorklogModelFirst.ID); if (worklog.Hours != 115) { Assert.Fail(); } Assert.IsNotNull(worklog); } }
public void DeletePostLoggedUserTest() { ModelsMocks.CleanUpBeforeTest(); ModelsMocks.AddTestProject(true); ModelsMocks.AddTestTask(true, ModelsMocks.ProjectModelFirst); ModelsMocks.AddTestWorklog(true, ModelsMocks.TaskModelFirst); // Arrange WorklogController controller = ControllersMocks.GetControllerAsLoggedUser <WorklogController>(); // Act JsonResult action = controller.Delete(ModelsMocks.WorklogModelSecond, ModelsMocks.ProjectModelFirst.ID, ModelsMocks.TaskModelFirst.ID, ModelsMocks.WorklogModelFirst.ID) as JsonResult; using (IUnityContainer container = UnityConfig.GetConfiguredContainer()) { var repo = container.Resolve <IWorklogRepository>(); try { var worklog = repo.GetWorklogByIdWithoutTracking(ModelsMocks.WorklogModelFirst.ID); Assert.Fail(); } #pragma warning disable CS0168 // Variable is declared but never used catch (Exception ex) #pragma warning restore CS0168 // Variable is declared but never used { //Passed } } }
public void DetailsLoggedUserTest() { ModelsMocks.CleanUpBeforeTest(); ModelsMocks.AddTestProject(true); ModelsMocks.AddTestTask(true, ModelsMocks.ProjectModelFirst); ModelsMocks.AddTestWorklog(true, ModelsMocks.TaskModelFirst); // Arrange WorklogController controller = ControllersMocks.GetControllerAsLoggedUser <WorklogController>(); // Act JsonResult action = controller.Details(ModelsMocks.ProjectModelFirst.ID, ModelsMocks.TaskModelFirst.ID, ModelsMocks.WorklogModelFirst.ID) as JsonResult; var worklog = (TaskVlopper.Models.WorklogViewModel)action.Data; Assert.IsNotNull(worklog); }
public void EditGetLoggedUserTest() { ModelsMocks.CleanUpBeforeTest(); ModelsMocks.AddTestProject(true); ModelsMocks.AddTestTask(true, ModelsMocks.ProjectModelFirst); ModelsMocks.AddTestWorklog(true, ModelsMocks.TaskModelFirst); // Arrange WorklogController controller = ControllersMocks.GetControllerAsLoggedUser <WorklogController>(); // Act JsonResult action = controller.Edit(ModelsMocks.WorklogModelSecond, ModelsMocks.ProjectModelFirst.ID, ModelsMocks.TaskModelFirst.ID, ModelsMocks.WorklogModelFirst.ID) as JsonResult; var ok = (TaskVlopper.Models.JsonHttpViewModel)action.Data; Assert.AreEqual(202, ok.HttpCode); }