Example #1
0
        public void ConfigureIocContainer()
        {
            Container.Register(Component.For <CryptoHelper>());

            #region Factory

            Container.Register(Component.For <IntegrationClientFactory>());
            Container.Register(Component.For <IntegrationFactory>());
            Container.Register(Component.For <JournalFactory>());
            Container.Register(Component.For <LabelFactory>());
            Container.Register(Component.For <LabelTranslationFactory>());
            Container.Register(Component.For <LanguageFactory>());
            Container.Register(Component.For <OrganizationFactory>());
            Container.Register(Component.For <ProjectFactory>());
            Container.Register(Component.For <SendEmailLogFactory>());
            Container.Register(Component.For <TokenFactory>());
            Container.Register(Component.For <TokenRequestLogFactory>());
            Container.Register(Component.For <UserFactory>());
            Container.Register(Component.For <UserLoginLogFactory>());

            #endregion

            #region Repository

            Container.Register(Component.For <IIntegrationClientRepository>().Instance(MockIntegrationClientRepository.Object));
            Container.Register(Component.For <IIntegrationRepository>().Instance(MockIntegrationRepository.Object));
            Container.Register(Component.For <IJournalRepository>().Instance(MockJournalRepository.Object));
            Container.Register(Component.For <ILabelRepository>().Instance(MockLabelRepository.Object));
            Container.Register(Component.For <ILabelTranslationRepository>().Instance(MockLabelTranslationRepository.Object));
            Container.Register(Component.For <ILanguageRepository>().Instance(MockLanguageRepository.Object));
            Container.Register(Component.For <IOrganizationRepository>().Instance(MockOrganizationRepository.Object));
            Container.Register(Component.For <IProjectRepository>().Instance(MockProjectRepository.Object));
            Container.Register(Component.For <ISendEmailLogRepository>().Instance(MockSendEmailLogRepository.Object));
            Container.Register(Component.For <ITokenRepository>().Instance(MockTokenRepository.Object));
            Container.Register(Component.For <ITokenRequestLogRepository>().Instance(MockTokenRequestLogRepository.Object));
            Container.Register(Component.For <IUserLoginLogRepository>().Instance(MockUserLoginLogRepository.Object));
            Container.Register(Component.For <IUserRepository>().Instance(MockUserRepository.Object));

            #endregion

            #region UnitOfWork

            Container.Register(Component.For <ILabelUnitOfWork>().Instance(MockLabelUnitOfWork.Object));
            Container.Register(Component.For <ILogOnUnitOfWork>().Instance(MockLogOnUnitOfWork.Object));
            Container.Register(Component.For <IProjectUnitOfWork>().Instance(MockProjectUnitOfWork.Object));
            Container.Register(Component.For <ISignUpUnitOfWork>().Instance(MockSignUpUnitOfWork.Object));

            #endregion

            #region Setup For Cache
            MockUserRepository.Setup_SelectById_Returns_OrganizationOneUserOne();
            MockUserRepository.Setup_Select_Returns_OrganizationOneUserOne();
            MockOrganizationRepository.Setup_SelectById_Returns_OrganizationOne();
            MockOrganizationRepository.Setup_Select_Returns_OrganizationOne();
            #endregion
        }
        public async Task JournalService_GetJournalsOfOrganization_Invalid_OrganizationNotFound()
        {
            // arrange
            var request = GetOrganizationJournalReadListRequest();

            MockOrganizationRepository.Setup_Select_Returns_NotExistOrganization();

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

            // assert
            AssertResponseStatusAndErrorMessages(result, ResponseStatus.Invalid, OrganizationNotFound);
            AssertReturnType <JournalReadListResponse>(result);
            MockOrganizationRepository.Verify_Select();
        }
Example #3
0
        public async Task AdminService_AcceptSuperAdminUserInvite_Failed()
        {
            // arrange
            var request = GetAdminAcceptInviteRequest();

            MockUserRepository.Setup_Select_Returns_OrganizationOneSuperAdminUserInvitedAtOneWeekBefore();
            MockOrganizationRepository.Setup_Any_Returns_False();

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

            // assert
            AssertResponseStatusAndErrorMessages(result, ResponseStatus.Failed);
            AssertReturnType <AdminAcceptInviteResponse>(result);
            MockUserRepository.Verify_Select();
            MockOrganizationRepository.Verify_Any();
        }
Example #4
0
        public async Task AdminService_AcceptSuperAdminUserInvite_Invalid_OrganizationNotFound()
        {
            // arrange
            var request = GetAdminAcceptInviteRequest();

            MockUserRepository.Setup_Select_Returns_OrganizationOneUserOne();
            MockOrganizationRepository.Setup_Any_Returns_True();

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

            // assert
            AssertResponseStatusAndErrorMessages(result, ResponseStatus.Invalid, OrganizationNotFound);
            AssertReturnType <AdminAcceptInviteResponse>(result);
            MockUserRepository.Verify_Select();
            MockOrganizationRepository.Verify_Any();
        }
Example #5
0
        public async Task AdminService_ValidateSuperAdminUserInvitation_Success()
        {
            // arrange
            var request = GetAdminInviteValidateRequest();

            MockUserRepository.Setup_Select_Returns_OrganizationOneSuperAdminUserInvitedAtOneDayBefore();
            MockOrganizationRepository.Setup_Any_Returns_False();

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

            // assert
            AssertResponseStatusAndErrorMessages(result, ResponseStatus.Success);
            AssertReturnType <AdminInviteValidateResponse>(result);
            MockUserRepository.Verify_Select();
            MockOrganizationRepository.Verify_Any();
        }
        public async Task ProjectService_EditProject_Invalid_OrganizationNotActive()
        {
            // arrange
            var request = GetProjectEditRequest();

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

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

            // assert
            AssertResponseStatusAndErrorMessages(result, ResponseStatus.Invalid, OrganizationNotActive);
            AssertReturnType <ProjectEditResponse>(result);
            MockUserRepository.Verify_SelectById();
            MockOrganizationRepository.Verify_Any();
        }
        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();
        }
        public async Task ProjectService_EditProject_OrganizationNotExist()
        {
            // arrange
            var request = GetProjectEditRequest();

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

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

            // assert
            result.ErrorMessages.ShouldNotBeNull();
            result.Status.ShouldBe(ResponseStatus.InvalidBecauseParentNotActive);
            AssertReturnType <ProjectEditResponse>(result);
            MockUserRepository.Verify_SelectById();
            MockOrganizationRepository.Verify_Any();
        }
Example #9
0
        public async Task AdminService_OrganizationChangeActivation_Failed()
        {
            // arrange
            var request = GetOrganizationChangeActivationRequest();

            MockUserRepository.Setup_SelectById_Returns_OrganizationOneSuperAdminUserOne();
            MockOrganizationRepository.Setup_Select_Returns_OrganizationOne();
            MockOrganizationRepository.Setup_Update_Failed();

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

            // assert
            AssertResponseStatusAndErrorMessages(result, ResponseStatus.Failed);
            AssertReturnType <OrganizationChangeActivationResponse>(result);
            MockUserRepository.Verify_SelectById();
            MockOrganizationRepository.Verify_Select();
            MockOrganizationRepository.Verify_Update();
        }
        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();
        }
        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();
        }
Example #12
0
        public async Task AdminService_GetOrganizations_Success_SelectMany()
        {
            // arrange
            var request = GetOrganizationReadListRequestForSelectMany();

            MockUserRepository.Setup_SelectById_Returns_OrganizationOneSuperAdminUserOne();
            MockOrganizationRepository.Setup_SelectMany_Returns_Organizations();
            MockOrganizationRepository.Setup_Count_Returns_Ten();

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

            // assert
            AssertResponseStatusAndErrorMessages(result, ResponseStatus.Success);
            AssertReturnType <OrganizationReadListResponse>(result);
            AssertPagingInfoForSelectMany(request.PagingInfo, Ten);
            MockUserRepository.Verify_SelectById();
            MockOrganizationRepository.Verify_SelectMany();
            MockOrganizationRepository.Verify_Count();
        }
        public async Task JournalService_GetJournalsOfUser_Success_SelectMany()
        {
            // arrange
            var request = GetUserJournalReadListRequestForSelectMany();

            MockOrganizationRepository.Setup_Select_Returns_OrganizationOne();
            MockJournalRepository.Setup_SelectAfter_Returns_Journals();
            MockJournalRepository.Setup_Count_Returns_Ten();

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

            // assert
            AssertResponseStatusAndErrorMessages(result, ResponseStatus.Success);
            AssertReturnType <JournalReadListResponse>(result);
            AssertPagingInfoForSelectMany(request.PagingInfo, Ten);
            MockOrganizationRepository.Verify_Select();
            MockJournalRepository.Verify_SelectMany();
            MockJournalRepository.Verify_Count();
        }
        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();
        }