public void EditPostLoggedUserTest() { ModelsMocks.CleanUpBeforeTest(); ModelsMocks.AddTestProject(true); ModelsMocks.AddTestTask(true, ModelsMocks.ProjectModelFirst); ModelsMocks.AddTestMeeting(true, ModelsMocks.MeetingModelFirst, ModelsMocks.TaskModelFirst); // Arrange MeetingController controller = ControllersMocks.GetControllerAsLoggedUser <MeetingController>(); // Act JsonResult action = controller.Edit(ModelsMocks.MeetingModelSecond, ModelsMocks.ProjectModelFirst.ID, ModelsMocks.TaskModelFirst.ID, ModelsMocks.MeetingModelFirst.ID) as JsonResult; using (IUnityContainer container = UnityConfig.GetConfiguredContainer()) { var repo = container.Resolve <IMeetingRepository>(); var meeting = repo.GetMeetingByIdWithoutTracking(ModelsMocks.MeetingModelFirst.ID); if (meeting.Description != "1") { Assert.Fail(); } if (meeting.Title != "2") { Assert.Fail(); } Assert.IsNotNull(meeting); } }
public void CreatePostLoggedUserTest() { ModelsMocks.CleanUpBeforeTest(); ModelsMocks.AddTestProject(true); // Arrange TaskController controller = ControllersMocks.GetControllerAsLoggedUser <TaskController>(); // Act JsonResult action = controller.Create(ModelsMocks.ProjectModelFirst.ID, ModelsMocks.TaskModelFirst) as JsonResult; // Assert using (IUnityContainer container = UnityConfig.GetConfiguredContainer()) { var taskRepo = container.Resolve <ITaskRepository>(); var taskAssignmentRepo = container.Resolve <IUserTaskAssignmentRepository>(); var task = taskRepo.GetTaskByIdWithoutTracking(ModelsMocks.TaskModelFirst.ID); var taskAssignment = taskAssignmentRepo.GetTaskAssignmentByTaskId(ModelsMocks.TaskModelFirst.ID).Single(); bool passed = true; if (taskAssignment.ProjectID != ModelsMocks.ProjectModelFirst.ID) { passed = false; } if (taskAssignment.TaskID != ModelsMocks.TaskModelFirst.ID) { passed = false; } Assert.AreEqual(true, passed); } }
public void IndexWithParametersLoggedUserTest() { ModelsMocks.CleanUpBeforeTest(); ModelsMocks.AddTestProject(true); ModelsMocks.AddTestTask(true, ModelsMocks.ProjectModelFirst); ModelsMocks.AddTestMeeting(true, ModelsMocks.MeetingModelFirst, ModelsMocks.TaskModelFirst); // Arrange MeetingController controller = ControllersMocks.GetControllerAsLoggedUser <MeetingController>(); // Act JsonResult action = controller.Index(ModelsMocks.ProjectModelFirst.ID, ModelsMocks.TaskModelFirst.ID) as JsonResult; var data = (Models.MeetingsViewModel)action.Data; // Assert Assert.AreEqual(1, data.Meeting.Count()); // Act action = controller.Index(ModelsMocks.ProjectModelFirst.ID) as JsonResult; data = (Models.MeetingsViewModel)action.Data; // Assert Assert.AreEqual(1, data.Meeting.Count()); // Act action = controller.Index() as JsonResult; data = (Models.MeetingsViewModel)action.Data; // Assert Assert.AreEqual(1, data.Meeting.Count()); }
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 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.AddTestMeeting(true, ModelsMocks.MeetingModelFirst, ModelsMocks.TaskModelFirst); // Arrange MeetingController controller = ControllersMocks.GetControllerAsLoggedUser <MeetingController>(); // Act JsonResult action = controller.Delete(ModelsMocks.MeetingModelFirst, ModelsMocks.ProjectModelFirst.ID, ModelsMocks.TaskModelFirst.ID, ModelsMocks.MeetingModelFirst.ID) as JsonResult; using (IUnityContainer container = UnityConfig.GetConfiguredContainer()) { var repo = container.Resolve <IMeetingRepository>(); var participantsRepo = container.Resolve <IMeetingParticipantsRepository>(); bool passed = false; try { var meeting = repo.GetMeetingByIdWithoutTracking(ModelsMocks.MeetingModelFirst.ID); } catch (Exception) { passed = true; } finally { if (!passed) { Assert.Fail(); } } try { var participants = participantsRepo.GetMeetingParticipantsByMeetingId(ModelsMocks.MeetingModelFirst.ID).SingleOrDefault(); if (participants != null) { throw new Exception("Assert fails"); } } catch (Exception) { Assert.Fail(); } } }
public void CreateGetNotLoggedUserTest() { ModelsMocks.CleanUpBeforeTest(); ModelsMocks.AddTestProject(false); // Arrange TaskController controller = ControllersMocks.GetControllerAsNotLoggedUser <TaskController>(); // Act JsonResult action = controller.Create(ModelsMocks.ProjectModelFirst.ID) as JsonResult; var forbidden = (TaskVlopper.Models.JsonHttpViewModel)action.Data; // Assert Assert.AreEqual(403, forbidden.HttpCode); }
public void DeleteGetLoggedUserTest() { ModelsMocks.CleanUpBeforeTest(); ModelsMocks.AddTestProject(true); ModelsMocks.AddTestTask(true, ModelsMocks.ProjectModelFirst); // Arrange TaskController controller = ControllersMocks.GetControllerAsLoggedUser <TaskController>(); // Act JsonResult action = controller.Delete(ModelsMocks.ProjectModelFirst.ID, ModelsMocks.TaskModelFirst.ID) as JsonResult; var task = (Models.TaskViewModel)action.Data; // Assert Assert.IsNotNull(task); }
public void IndexLoggedUserTest() { ModelsMocks.CleanUpBeforeTest(); ModelsMocks.AddTestProject(true); // Arrange TaskController controller = ControllersMocks.GetControllerAsLoggedUser <TaskController>(); // Act JsonResult action = controller.Index(ModelsMocks.ProjectModelFirst.ID) as JsonResult; var tasks = (TaskVlopper.Models.TasksViewModel)action.Data; // Assert Assert.IsNotNull(tasks); }
public void UsersByProjectLoggedUserTest() { ModelsMocks.CleanUpBeforeTest(); // Arrange AccountController controller = ControllersMocks.CreateAccountControllerAs(ControllersMocks.LoggedUser, true); ModelsMocks.AddTestProject(true); ModelsMocks.AssignUserToProject(ModelsMocks.FirstUser, ModelsMocks.ProjectModelFirst); // Act JsonResult action = controller.UsersByProject(ModelsMocks.ProjectModelFirst.ID) as JsonResult; int count = ((UsersViewModel)action.Data).Users.Count(); // Assert Assert.AreEqual(2, count); }
public void IndexLoggedUserTest() { ModelsMocks.CleanUpBeforeTest(); ModelsMocks.AddTestProject(true); ModelsMocks.AddTestTask(true, ModelsMocks.ProjectModelFirst); // Arrange WorklogController controller = ControllersMocks.GetControllerAsLoggedUser <WorklogController>(); // Act JsonResult action = controller.Index(ModelsMocks.ProjectModelFirst.ID, ModelsMocks.TaskModelFirst.ID) as JsonResult; var worklogs = (Models.WorklogsViewModel)action.Data; // Assert Assert.IsNotNull(worklogs); }
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 DeleteGetLoggedUserTest() { ModelsMocks.CleanUpBeforeTest(); ModelsMocks.AddTestProject(true); ModelsMocks.AddTestTask(true, ModelsMocks.ProjectModelFirst); ModelsMocks.AddTestMeeting(true, ModelsMocks.MeetingModelFirst, ModelsMocks.TaskModelFirst); // Arrange MeetingController controller = ControllersMocks.GetControllerAsLoggedUser <MeetingController>(); // Act JsonResult action = controller.Delete(ModelsMocks.ProjectModelFirst.ID, ModelsMocks.TaskModelFirst.ID, ModelsMocks.MeetingModelFirst.ID) as JsonResult; var meeting = (Models.MeetingViewModel)action.Data; Assert.IsNotNull(meeting); }
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); }
public void DeletePostLoggedUserTest() { ModelsMocks.CleanUpBeforeTest(); ModelsMocks.AddTestProject(true); ModelsMocks.AddTestTask(true, ModelsMocks.ProjectModelFirst); // Arrange TaskController controller = ControllersMocks.GetControllerAsLoggedUser <TaskController>(); // Act JsonResult action = controller.Delete(ModelsMocks.ProjectModelFirst.ID, ModelsMocks.TaskModelFirst.ID, ModelsMocks.TaskModelFirst) as JsonResult; using (IUnityContainer container = UnityConfig.GetConfiguredContainer()) { var taskRepo = container.Resolve <ITaskRepository>(); var taskAssignmentRepo = container.Resolve <IUserTaskAssignmentRepository>(); // Assert Assert.AreEqual(0, taskRepo.GetAll().Count() + taskAssignmentRepo.GetAll().Count()); } }
public void CreatePostLoggedUserTest() { ModelsMocks.CleanUpBeforeTest(); ModelsMocks.AddTestProject(true); ModelsMocks.AddTestTask(true, ModelsMocks.ProjectModelFirst); // Arrange MeetingController controller = ControllersMocks.GetControllerAsLoggedUser <MeetingController>(); // Act JsonResult action = controller.Create(ModelsMocks.MeetingModelFirst, ModelsMocks.ProjectModelFirst.ID, ModelsMocks.TaskModelFirst.ID) as JsonResult; using (IUnityContainer container = UnityConfig.GetConfiguredContainer()) { var repo = container.Resolve <IMeetingRepository>(); var participantsRepo = container.Resolve <IMeetingParticipantsRepository>(); var meeting = repo.GetMeetingByProjectIdAndTaskId(ModelsMocks.ProjectModelFirst.ID, ModelsMocks.TaskModelFirst.ID).Single(); var meetingParticipants = participantsRepo.GetMeetingParticipantsByMeetingId(meeting.ID).SingleOrDefault(); // Assert Assert.IsNotNull(meeting); Assert.IsNotNull(meetingParticipants); } }