public async Task Then_Handler_Returns_True_If_Allowed_To_Submit()
        {
            ApplyRepository.Setup(r => r.CanSubmitApplication(It.IsAny <Guid>())).ReturnsAsync(true);

            var request = new SubmitApplicationRequest
            {
                ApplicationId       = Guid.NewGuid(),
                SubmittingContactId = Guid.NewGuid(),
                ApplyData           = new ApplyData
                {
                    ApplyDetails = new ApplyDetails(),
                    Sequences    = new List <ApplySequence>
                    {
                        new ApplySequence
                        {
                            SequenceNo = 1,
                            Sections   = new List <ApplySection>
                            {
                                new ApplySection
                                {
                                    SectionNo = 1
                                }
                            }
                        }
                    }
                }
            };

            var result = await Handler.Handle(request, new CancellationToken());

            Assert.IsTrue(result);
            ApplyRepository.Verify(r => r.SubmitApplication(It.IsAny <Guid>(), It.IsAny <ApplyData>(), It.IsAny <FinancialData>(), It.IsAny <Guid>()), Times.Once);
        }
        public void Then_prevent_submission_if_another_user_has_already_submitted()
        {
            var request = new SubmitApplicationRequest {
                ApplicationId = differentAppGuid, SubmittingContactId = differentAppGuid
            };

            Handler.Handle(request, new CancellationToken()).Wait();

            ApplyRepository.Verify(r => r.SubmitApplication(It.IsAny <Guid>(), It.IsAny <ApplyData>(), It.IsAny <FinancialData>(), It.IsAny <Guid>()), Times.Never);
        }
Exemple #3
0
        public void Then_section_is_not_saved_with_those_answers()
        {
            Handler.Handle(new UpdatePageAnswersRequest(ApplicationId, UserId, 1, 1, "5",
                                                        new List <Answer>()
            {
                /* no answers are provided */
            },
                                                        true), new CancellationToken()).Wait();

            ApplyRepository.Verify(r => r.SaveSection(It.IsAny <ApplicationSection>(), UserId), Times.Never);
        }
Exemple #4
0
        public void Then_RequestedFeedbackAnswered_IsFalse()
        {
            Handler.Handle(new UpdatePageAnswersRequest(ApplicationId, UserId, 1, 1, "1",
                                                        new List <Answer>()
            {
                AnswerQ1
            },
                                                        true), new CancellationToken()).Wait();


            ApplyRepository.Verify(r => r.SaveSection(It.Is <ApplicationSection>(section => !section.QnAData.RequestedFeedbackAnswered.Value), UserId));
        }
        public async Task Then_Handler_Returns_False_If_Not_Allowed_To_Submit()
        {
            ApplyRepository.Setup(r => r.CanSubmitApplication(It.IsAny <Guid>())).ReturnsAsync(false);

            var request = new SubmitApplicationRequest {
                ApplicationId = Guid.NewGuid(), SubmittingContactId = Guid.NewGuid()
            };

            var result = await Handler.Handle(request, new CancellationToken());

            Assert.IsFalse(result);
            ApplyRepository.Verify(r => r.SubmitApplication(It.IsAny <Guid>(), It.IsAny <ApplyData>(), It.IsAny <FinancialData>(), It.IsAny <Guid>()), Times.Never);
        }
        public void Then_allow_submission_if_user_is_the_one_whom_already_submitted()
        {
            var request = new SubmitApplicationRequest
            {
                ApplicationId = sameAppGuid, SubmittingContactId = sameAppGuid,
                ApplyData     = new ApplyData
                {
                    ApplyDetails = new ApplyDetails(),
                    Sequences    = new List <ApplySequence>()
                }
            };

            Handler.Handle(request, new CancellationToken()).Wait();

            ApplyRepository.Verify(r => r.SubmitApplication(It.IsAny <Guid>(), It.IsAny <ApplyData>(), It.IsAny <FinancialData>(), It.IsAny <Guid>()), Times.Once);
        }
        public void Then_section_is_saved_with_the_existing_answers()
        {
            Handler.Handle(new UpdatePageAnswersRequest(ApplicationId, UserId, 1, 1, "3",
                                                        new List <Answer>()
            {
                AnswerQ4,
                AnswerQ5
            },
                                                        false), new CancellationToken()).Wait();

            ApplyRepository.Verify(r => r.SaveSection(It.Is <ApplicationSection>(
                                                          section =>
                                                          section.QnAData.Pages.First(p => p.PageId == "3").PageOfAnswers[0].Answers[0].QuestionId == _existingAnswerQ4.QuestionId &&
                                                          section.QnAData.Pages.First(p => p.PageId == "3").PageOfAnswers[0].Answers[0].Value == _existingAnswerQ4.Value), UserId), Times.Once());

            ApplyRepository.Verify(r => r.SaveSection(It.Is <ApplicationSection>(
                                                          section =>
                                                          section.QnAData.Pages.First(p => p.PageId == "3").PageOfAnswers[0].Answers[1].QuestionId == _existingAnswerQ5.QuestionId &&
                                                          section.QnAData.Pages.First(p => p.PageId == "3").PageOfAnswers[0].Answers[1].Value == _existingAnswerQ5.Value), UserId), Times.Once());
        }
        public void Then_section_is_saved_with_those_answers()
        {
            Handler.Handle(new UpdatePageAnswersRequest(ApplicationId, UserId, 1, 1, "1",
                                                        new List <Answer>()
            {
                AnswerQ1,
                AnswerQ1Dot1
            },
                                                        true), new CancellationToken()).Wait();

            ApplyRepository.Verify(r => r.SaveSection(It.Is <ApplicationSection>(
                                                          section =>
                                                          section.QnAData.Pages.First(p => p.PageId == "1").PageOfAnswers[0].Answers[0].QuestionId == AnswerQ1.QuestionId &&
                                                          (string)section.QnAData.Pages.First(p => p.PageId == "1").PageOfAnswers[0].Answers[0].Value == AnswerQ1.Value), UserId));

            ApplyRepository.Verify(r => r.SaveSection(It.Is <ApplicationSection>(
                                                          section =>
                                                          section.QnAData.Pages.First(p => p.PageId == "1").PageOfAnswers[0].Answers[1].QuestionId == AnswerQ1Dot1.QuestionId &&
                                                          section.QnAData.Pages.First(p => p.PageId == "1").PageOfAnswers[0].Answers[1].Value == AnswerQ1Dot1.Value), UserId));
        }
        public async Task Then_application_created_by_orgainisation_are_returned()
        {
            await Handler.Handle(new GetApplicationsRequest(Guid.NewGuid(), false), new CancellationToken());

            ApplyRepository.Verify(r => r.GetOrganisationApplications(It.IsAny <Guid>()), Times.Once);
        }
Exemple #10
0
        public async Task Then_organisation_withdrawal_applications_are_retrieved()
        {
            await Handler.Handle(new GetApplicationsRequest(new Guid(), ApplicationTypes.OrganisationWithdrawal), new CancellationToken());

            ApplyRepository.Verify(r => r.GetOrganisationWithdrawalApplications(It.IsAny <Guid>()), Times.Once);
        }
        public async Task Then_FinancialData_Is_Persisted()
        {
            ApplyRepository.Setup(r => r.CanSubmitApplication(It.IsAny <Guid>())).ReturnsAsync(true);

            var request = new SubmitApplicationRequest
            {
                ApplicationId       = Guid.NewGuid(),
                SubmittingContactId = Guid.NewGuid(),
                ApplyData           = new ApplyData
                {
                    ApplyDetails = new ApplyDetails(),
                    Sequences    = new List <ApplySequence>
                    {
                        new ApplySequence
                        {
                            SequenceNo = 1,
                            Sections   = new List <ApplySection>
                            {
                                new ApplySection
                                {
                                    SectionNo = 1
                                }
                            }
                        }
                    }
                },
                FinancialData = new FinancialData
                {
                    TurnOver                    = 1,
                    Depreciation                = 2,
                    ProfitLoss                  = 3,
                    Dividends                   = 4,
                    IntangibleAssets            = 5,
                    Assets                      = 6,
                    Liabilities                 = 7,
                    ShareholderFunds            = 8,
                    Borrowings                  = 9,
                    AccountingReferenceDate     = new DateTime(2021, 1, 1),
                    AccountingPeriod            = 10,
                    AverageNumberofFTEEmployees = 11
                }
            };

            var result = await Handler.Handle(request, new CancellationToken());

            Assert.IsTrue(result);
            ApplyRepository.Verify(r => r.SubmitApplication(It.IsAny <Guid>(), It.IsAny <ApplyData>(), It.Is <FinancialData>(
                                                                x => x.TurnOver == 1 &&
                                                                x.Depreciation == 2 &&
                                                                x.ProfitLoss == 3 &&
                                                                x.Dividends == 4 &&
                                                                x.IntangibleAssets == 5 &&
                                                                x.Assets == 6 &&
                                                                x.Liabilities == 7 &&
                                                                x.ShareholderFunds == 8 &&
                                                                x.Borrowings == 9 &&
                                                                x.AccountingReferenceDate == new DateTime(2021, 1, 1) &&
                                                                x.AccountingPeriod == 10 &&
                                                                x.AverageNumberofFTEEmployees == 11
                                                                ), It.IsAny <Guid>()), Times.Once);
        }
        public async Task Then_standard_applications_are_retrieved()
        {
            await Handler.Handle(new GetApplicationsRequest(new Guid(), ApplicationTypes.Standard), new CancellationToken());

            ApplyRepository.Verify(r => r.GetStandardApplications(It.IsAny <Guid>()), Times.Once);
        }