Exemplo n.º 1
0
        public async Task ProjectService_GetProjectRevisions_Success()
        {
            // arrange
            var request = GetProjectRevisionReadListRequest();

            MockProjectRepository.Setup_Select_Returns_OrganizationOneProjectOne();
            MockProjectRepository.Setup_SelectRevisions_Returns_OrganizationOneProjectOneRevisions();

            // act
            var result = await SystemUnderTest.GetProjectRevisions(request);

            // assert
            AssertResponseStatusAndErrorMessages(result, ResponseStatus.Success);
            AssertReturnType <ProjectRevisionReadListResponse>(result);
            MockProjectRepository.Verify_Select();
            MockProjectRepository.Verify_SelectRevisions();
        }
Exemplo n.º 2
0
        public async Task ProjectService_GetPendingTranslations_Success()
        {
            // arrange
            var request = GetProjectPendingTranslationReadListRequest();

            MockProjectRepository.Setup_Select_Returns_OrganizationOneProjectOne();

            // act
            var result = await SystemUnderTest.GetPendingTranslations(request);

            // assert
            result.Status.ShouldBe(ResponseStatus.Success);
            result.ErrorMessages.ShouldNotBeNull();
            result.ErrorMessages.Count.ShouldBe(0);
            AssertReturnType <ProjectPendingTranslationReadListResponse>(result);
            MockProjectRepository.Verify_Select();
        }
Exemplo n.º 3
0
        public async Task ProjectService_RestoreProject_Invalid_ProjectNotFound()
        {
            // arrange
            var request = GetProjectRestoreRequest();

            MockUserRepository.Setup_SelectById_Returns_OrganizationOneUserOne();
            MockProjectRepository.Setup_Select_Returns_InvalidProject();

            // act
            var result = await SystemUnderTest.RestoreProject(request);

            // assert
            AssertResponseStatusAndErrorMessages(result, ResponseStatus.Invalid, ProjectNotFound);
            AssertReturnType <ProjectRestoreResponse>(result);
            MockUserRepository.Verify_SelectById();
            MockProjectRepository.Verify_Select();
        }
Exemplo n.º 4
0
        public async Task ProjectService_ChangeActivationForProject_InvalidProjectEntity()
        {
            // arrange
            var request = GetProjectChangeActivationRequest();

            MockUserRepository.Setup_SelectById_Returns_OrganizationOneAdminUserOne();
            MockProjectRepository.Setup_Select_Returns_InvalidProject();

            // act
            var result = await SystemUnderTest.ChangeActivationForProject(request);

            // assert
            result.ErrorMessages.ShouldNotBeNull();
            result.Status.ShouldBe(ResponseStatus.InvalidBecauseEntityNotFound);
            AssertReturnType <ProjectChangeActivationResponse>(result);
            MockUserRepository.Verify_SelectById();
            MockProjectRepository.Verify_Select();
        }
Exemplo n.º 5
0
        public async Task ProjectService_DeleteProject_Failed()
        {
            // arrange
            var request = GetProjectDeleteRequest();

            MockOrganizationRepository.Setup_Any_Returns_False();
            MockProjectRepository.Setup_Delete_Failed();

            // act
            var result = await SystemUnderTest.DeleteProject(request);

            // assert
            result.ErrorMessages.ShouldNotBeNull();
            result.Status.ShouldBe(ResponseStatus.Failed);
            AssertReturnType <ProjectDeleteResponse>(result);
            MockOrganizationRepository.Verify_Any();
            MockProjectRepository.Verify_Delete();
        }
Exemplo n.º 6
0
        public async Task ProjectService_RestoreProject_InvalidProjectEntity()
        {
            // arrange
            var request = GetProjectRestoreRequest();

            MockUserRepository.Setup_SelectById_Returns_OrganizationOneUserOne();
            MockProjectRepository.Setup_Select_Returns_InvalidProject();

            // act
            var result = await SystemUnderTest.RestoreProject(request);

            // assert
            result.ErrorMessages.ShouldNotBeNull();
            result.Status.ShouldBe(ResponseStatus.InvalidBecauseEntityNotFound);
            result.InfoMessages.Any(x => x == "project_not_found").ShouldBeTrue();
            AssertReturnType <ProjectRestoreResponse>(result);
            MockUserRepository.Verify_SelectById();
            MockProjectRepository.Verify_Select();
        }
Exemplo n.º 7
0
        public async Task ProjectService_CloneProject_ProjectAlreadyExist()
        {
            // arrange
            var request = GetProjectCloneRequest();

            MockOrganizationRepository.Setup_Any_Returns_False();
            MockProjectRepository.Setup_Any_Returns_True();

            // act
            var result = await SystemUnderTest.CloneProject(request);

            // assert
            result.ErrorMessages.ShouldNotBeNull();
            result.Status.ShouldBe(ResponseStatus.Failed);
            result.ErrorMessages.Any(x => x == "project_name_must_be_unique").ShouldBeTrue();
            AssertReturnType <ProjectCloneResponse>(result);
            MockOrganizationRepository.Verify_Any();
            MockProjectRepository.Verify_Any();
        }
Exemplo n.º 8
0
        public async Task ProjectService_CreateProject_ProjectAlreadyExist()
        {
            // arrange
            var request = GetProjectCreateRequest();

            MockUserRepository.Setup_SelectById_Returns_OrganizationOneAdminUserOne();
            MockOrganizationRepository.Setup_Any_Returns_False();
            MockProjectRepository.Setup_Any_Returns_True();

            // act
            var result = await SystemUnderTest.CreateProject(request);

            // assert
            AssertResponseStatusAndErrorMessages(result, ResponseStatus.Failed, ProjectNameMustBeUnique);
            AssertReturnType <ProjectCreateResponse>(result);
            MockUserRepository.Verify_SelectById();
            MockOrganizationRepository.Verify_Any();
            MockProjectRepository.Verify_Any();
        }
Exemplo n.º 9
0
        public async Task ProjectService_DeleteProject__OrganizationNotExist()
        {
            // arrange
            var request = GetProjectDeleteRequest();

            MockUserRepository.Setup_SelectById_Returns_OrganizationOneAdminUserOne();
            MockProjectRepository.Setup_Select_Returns_OrganizationOneProjectOne();
            MockOrganizationRepository.Setup_Any_Returns_True();

            // act
            var result = await SystemUnderTest.DeleteProject(request);

            // assert
            result.ErrorMessages.ShouldNotBeNull();
            result.Status.ShouldBe(ResponseStatus.Invalid);
            AssertReturnType <ProjectDeleteResponse>(result);
            MockUserRepository.Verify_SelectById();
            MockProjectRepository.Verify_Select();
            MockOrganizationRepository.Verify_Any();
        }
Exemplo n.º 10
0
        public async Task LabelService_CreateLabel_Success()
        {
            // arrange
            var request = GetLabelCreateRequest();

            MockUserRepository.Setup_SelectById_Returns_OrganizationOneAdminUserOne();
            MockProjectRepository.Setup_Select_Returns_OrganizationOneProjectOne();
            MockLabelRepository.Setup_Any_Returns_False();
            MockLabelUnitOfWork.Setup_DoCreateWork_Returns_True();

            // act
            var result = await SystemUnderTest.CreateLabel(request);

            // assert
            AssertResponseStatusAndErrorMessages(result, ResponseStatus.Success);
            AssertReturnType <LabelCreateResponse>(result);
            MockUserRepository.Verify_SelectById();
            MockProjectRepository.Verify_Select();
            MockLabelRepository.Verify_Any();
            MockLabelUnitOfWork.Verify_DoCreateWork();
        }
Exemplo n.º 11
0
        public async Task ProjectService_RestoreProject_Success()
        {
            // arrange
            var request = GetProjectRestoreRequest();

            MockUserRepository.Setup_SelectById_Returns_OrganizationOneUserOne();
            MockProjectRepository.Setup_Select_Returns_OrganizationOneProjectOne();
            MockProjectRepository.Setup_SelectRevisions_Returns_OrganizationOneProjectOneRevisions();
            MockProjectRepository.Setup_RestoreRevision_Returns_True();

            // act
            var result = await SystemUnderTest.RestoreProject(request);

            // assert
            result.Status.ShouldBe(ResponseStatus.Success);
            result.ErrorMessages.ShouldNotBeNull();
            result.ErrorMessages.Count.ShouldBe(0);
            AssertReturnType <ProjectRestoreResponse>(result);
            MockUserRepository.Verify_SelectById();
            MockProjectRepository.Verify_Select();
            MockProjectRepository.Verify_SelectRevisions();
            MockProjectRepository.Verify_RestoreRevision();
        }
Exemplo n.º 12
0
        public async Task ProjectService_ChangeActivationForProject_Success()
        {
            // arrange
            var request = GetProjectChangeActivationRequest();

            MockUserRepository.Setup_SelectById_Returns_OrganizationOneAdminUserOne();
            MockProjectRepository.Setup_Select_Returns_OrganizationOneProjectOne();
            MockProjectRepository.Setup_Update_Success();
            MockOrganizationRepository.Setup_Any_Returns_False();

            // act
            var result = await SystemUnderTest.ChangeActivationForProject(request);

            // assert
            result.Status.ShouldBe(ResponseStatus.Success);
            result.ErrorMessages.ShouldNotBeNull();
            result.ErrorMessages.Count.ShouldBe(0);
            AssertReturnType <ProjectChangeActivationResponse>(result);
            MockUserRepository.Verify_SelectById();
            MockProjectRepository.Verify_Select();
            MockProjectRepository.Verify_Update();
            MockOrganizationRepository.Verify_Any();
        }
Exemplo n.º 13
0
 private void SetupMockEmployeeAndProjectRepositories()
 {
     mockEmployeeRepository = new MockEmployeeRepository();
     mockProjectRepository  = new MockProjectRepository(mockEmployeeRepository.Employees);
 }
Exemplo n.º 14
0
        public void TestUpdateResponsiblePersons()
        {
            var unitOfWorkProvider = CreateMockUnitOfWorkProvider();
            var bookData           = new BookData
            {
                Responsibles = new List <ResponsibleData>
                {
                    new ResponsibleData
                    {
                        NameText = "Aaa Bbb",
                        TypeText = "editor",
                    },
                    new ResponsibleData
                    {
                        NameText = "Aaa Bbb",
                        TypeText = "production",
                    },
                    new ResponsibleData
                    {
                        NameText = "Ccc Ddd",
                        TypeText = "editor",
                    },
                }
            };


            var personRepository = new MockPersonRepository(unitOfWorkProvider)
            {
                CanFindAuthorByName = true
            };
            var projectRepository = new MockProjectRepository(unitOfWorkProvider)
            {
                ProjectResponsiblePersons = new List <ProjectResponsiblePerson>
                {
                    new ProjectResponsiblePerson
                    {
                        ResponsiblePerson = new ResponsiblePerson {
                            FirstName = "Eee", LastName = "Fff", Id = 30
                        },
                        ResponsibleType = new ResponsibleType {
                            Text = "editor", Id = 10
                        },
                        Sequence = 1,
                    },
                    new ProjectResponsiblePerson
                    {
                        ResponsiblePerson = new ResponsiblePerson {
                            FirstName = "Aaa", LastName = "Bbb", Id = 31
                        },
                        ResponsibleType = new ResponsibleType {
                            Text = "editor", Id = 10
                        },
                        Sequence = 1,
                    }
                }
            };
            var subtask = new UpdateResponsiblePersonSubtask(projectRepository, personRepository);

            subtask.UpdateResponsiblePersonList(41, bookData);

            Assert.AreEqual(2, projectRepository.CreatedObjects.Count);
            Assert.AreEqual(1, projectRepository.UpdatedObjects.Count);
            Assert.AreEqual(1, projectRepository.DeletedObjects.Count);

            var createdItem2 = projectRepository.CreatedObjects.OfType <ProjectResponsiblePerson>().Single(x => x.ResponsiblePerson.FirstName == "Aaa");
            var createdItem3 = projectRepository.CreatedObjects.OfType <ProjectResponsiblePerson>().Single(x => x.ResponsiblePerson.FirstName == "Ccc");
            var updatedItem  = projectRepository.UpdatedObjects.OfType <ProjectResponsiblePerson>().Single();

            Assert.AreEqual(1, updatedItem.Sequence);
            Assert.AreEqual(2, createdItem2.Sequence);
            Assert.AreEqual(3, createdItem3.Sequence);
        }