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 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 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 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 UsersByMeetingLoggedUserTest() { ModelsMocks.CleanUpBeforeTest(); // Arrange AccountController controller = ControllersMocks.CreateAccountControllerAs(ControllersMocks.LoggedUser, true); ModelsMocks.AddTestProject(true); ModelsMocks.AddTestTask(true, ModelsMocks.ProjectModelFirst); ModelsMocks.AddTestMeeting(true, ModelsMocks.MeetingModelFirst, ModelsMocks.TaskModelFirst); ModelsMocks.AssignUserToMeeting(ModelsMocks.FirstUser, ModelsMocks.MeetingModelFirst); // Act JsonResult action = controller.UsersByMeeting(ModelsMocks.MeetingModelFirst.ID) as JsonResult; int count = ((UsersViewModel)action.Data).Users.Count(); // Assert Assert.AreEqual(2, count); }