public void UsersInProjectsApplication_IsValid_ShouldReturnTrue() { // Arrange var UserFixture = new UsersTestsFixture(); var ProjectFixture = new ProjectsTestsFixture(); var userApp = Fixture.GetUsersInProjectsAppService(); var user = Fixture.GenerateValidUsersInProjects(); Fixture.UserAppServiceMock.Setup(c => c.GetById(2)).Returns(UserFixture.GenerateValidUserToQuery()); Fixture.ProjectAppServiceMock.Setup(c => c.GetById(1)).Returns(ProjectFixture.GenerateValidProjectToQuery()); // Act EntityValidationResult validation = userApp.IsValid(user); // Assert Fluent Assertions validation.Status.Should().BeTrue(); validation.ValidationMessages.Should().HaveCount(c => c == 0); }
public void TestPlanApplication_IsValid_ShouldReturnFalseAndMessageInvalidOwner() { var ProjectFixture = new ProjectsTestsFixture(); var UserFixture = new UsersTestsFixture(); // Arrange var testPlanApp = Fixture.GetTestPlanAppService(); var testPlan = Fixture.GenerateTestPlanWithInvalidOwner(); Fixture.ProjectAppServiceMock.Setup(c => c.GetById(1)).Returns(ProjectFixture.GenerateValidProjectToQuery()); Fixture.UserAppServiceMock.Setup(c => c.GetById(1)).Returns(UserFixture.GenerateValidUserToQuery()); // Act EntityValidationResult validation = testPlanApp.IsValid(testPlan); // Assert Fluent Assertions validation.Status.Should().BeFalse(); validation.ValidationMessages.Should().HaveCount(c => c == 1); validation.ValidationMessages[0].Should().Be("Owner Not Found"); }
public void ProjectsController_GetByProjectId_ShouldReturnUserInProject() { // Arrange var userFixture = new UsersTestsFixture(); var projectFixture = new ProjectsTestsFixture(); var controller = Fixture.GetUsersInProjectsController(); Fixture.UsersInProjectsAppServiceMock.Setup(c => c.GetByProject(1)).Returns(Fixture.GenerateUsersInProjects(50)); Fixture.UserAppServiceMock.Setup(c => c.GetById(1)).Returns(userFixture.GenerateValidUserToQuery()); Fixture.ProjectAppServiceMock.Setup(c => c.GetById(1)).Returns(projectFixture.GenerateValidProjectToQuery()); // Act var response = controller.GetByProject(1) as ObjectResult; var data = response.Value as ApiResponse; // Assert Fluent Assertions data.State.Should().Be(ApiResponseState.Success); var projects = data.Data as IEnumerable <UsersInProjectsToQueryViewModel>; projects.Should().HaveCount(c => c == 50); }
public void UsersInProjectsApplication_IsValid_Duplicated_ShouldReturnFalse() { // Arrange var UserFixture = new UsersTestsFixture(); var ProjectFixture = new ProjectsTestsFixture(); var userApp = Fixture.GetUsersInProjectsAppService(); var user = Fixture.GenerateValidUsersInProjects(); Fixture.UsersInProjectsRepositoryMock.Setup(c => c.GetByUserAndProject(2, 1)).Returns(Fixture.GenerateValidUsersInProjectsToQuery()); Fixture.UserAppServiceMock.Setup(c => c.GetById(2)).Returns(UserFixture.GenerateValidUserToQuery()); Fixture.ProjectAppServiceMock.Setup(c => c.GetById(1)).Returns(ProjectFixture.GenerateValidProjectToQuery()); // Act EntityValidationResult validation = userApp.IsValid(user); // Assert Fluent Assertions validation.Status.Should().BeFalse(); validation.ValidationMessages.Should().HaveCount(c => c == 1); validation.ValidationMessages[0].Should().Be("User already associate to project"); }