コード例 #1
0
        public void Execute_RemovesFile()
        {
            var existingForm = new ChangeOfCircsBuilder("form123").Insert();

            var cmdA = new AddEvidenceFile
            {
                FormId   = "form123",
                Filename = "test.pdf",
                Content  = Encoding.ASCII.GetBytes("evidence file"),
            };

            cmdA.Execute();

            var updatedForm = Repository.Load <ChangeOfCircs>("form123");

            updatedForm.Evidence.Files.Count.Should().Be(1);

            var cloudName = updatedForm.Evidence.Files[0].CloudName;

            var cmdR = new RemoveEvidenceFile
            {
                FormId    = "form123",
                CloudName = cloudName,
            };

            cmdR.Execute();

            updatedForm = Repository.Load <ChangeOfCircs>("form123");
            updatedForm.Evidence.Files.Count.Should().Be(0);
        }
コード例 #2
0
        public void Execute_StoresDeclaration()
        {
            var existingForm = new ChangeOfCircsBuilder("form123")
                               .Insert();

            existingForm.Declaration.Should().BeNull("no data stored before executing command");

            var cmd = new AddDeclaration
            {
                FormId      = "form123",
                Declaration = DeclarationBuilder.NewValid(),
            };

            cmd.Execute();

            var updatedForm = Repository.Load <ChangeOfCircs>("form123");

            updatedForm.Declaration.Should().NotBeNull();
            updatedForm.Declaration.AgreedToLegalStatement.Should().Be(cmd.Declaration.AgreedToLegalStatement);
        }
コード例 #3
0
        public void Execute_StoresConsent()
        {
            var existingForm = new ChangeOfCircsBuilder("form123")
                               .Insert();

            existingForm.Consent.Should().BeNull("no data stored before executing command");

            var cmd = new AddConsent
            {
                FormId  = "form123",
                Consent = ConsentBuilder.NewValid(),
            };

            cmd.Execute();

            var updatedForm = Repository.Load <ChangeOfCircs>("form123");

            updatedForm.Consent.Should().NotBeNull();
            updatedForm.Consent.AgreedToConsent.Should().Be(cmd.Consent.AgreedToConsent);
        }
コード例 #4
0
        public void Execute_StoresHealthProfessional()
        {
            var existingForm = new ChangeOfCircsBuilder("form123")
                               .Insert();

            existingForm.HealthProfessional.Should().BeNull("no data stored before executing command");

            var cmd = new AddHealthProfessional
            {
                FormId             = "form123",
                HealthProfessional = HealthProfessionalBuilder.NewValid(),
            };

            cmd.Execute();

            var updatedForm = Repository.Load <ChangeOfCircs>("form123");

            updatedForm.HealthProfessional.Should().NotBeNull();
            updatedForm.HealthProfessional.Pin.Should().Be(cmd.HealthProfessional.Pin);
        }
コード例 #5
0
        public void Execute_StoresExpectedChildren()
        {
            var existingForm = new ChangeOfCircsBuilder("form123")
                               .Insert();

            existingForm.ExpectedChildren.Should().BeNull("no data stored before executing command");

            var cmd = new AddExpectedChildren
            {
                FormId           = "form123",
                ExpectedChildren = ExpectedChildrenBuilder.NewValid(),
            };

            cmd.Execute();

            var updatedForm = Repository.Load <ChangeOfCircs>("form123");

            updatedForm.ExpectedChildren.Should().NotBeNull();
            updatedForm.ExpectedChildren.ExpectancyDate.Should().Be(cmd.ExpectedChildren.ExpectancyDate);
        }
コード例 #6
0
        public void Execute_StoresApplicantDetails()
        {
            var existingForm = new ChangeOfCircsBuilder("form123")
                               .Insert();

            existingForm.ApplicantDetails.Should().BeNull("no data stored before executing command");

            var cmd = new AddApplicantDetails
            {
                FormId           = "form123",
                ApplicantDetails = ApplicantDetailsBuilder.NewValid(),
            };

            cmd.Execute();

            var updatedForm = Repository.Load <ChangeOfCircs>("form123");

            updatedForm.ApplicantDetails.Should().NotBeNull();
            updatedForm.ApplicantDetails.FullName.Should().Be(cmd.ApplicantDetails.FullName);
        }
コード例 #7
0
        public void Execute_StoresOptions()
        {
            var existingForm = new ChangeOfCircsBuilder("form123")
                               .Insert();

            existingForm.Options.Should().BeNull("no data stored before executing command");

            var cmd = new AddOptions
            {
                FormId  = "form123",
                Options = OptionsBuilder.NewValid(),
            };

            cmd.Execute();

            var updatedForm = Repository.Load <ChangeOfCircs>("form123");

            updatedForm.Options.Should().NotBeNull();
            updatedForm.Options.ChangePersonalDetails.Should().Be(cmd.Options.ChangePersonalDetails);
        }
コード例 #8
0
        public void Execute_StoresPaymentDetails()
        {
            var existingForm = new ChangeOfCircsBuilder("form123")
                               .With(f => f.ExistingPaymentDetails, PaymentDetailsBuilder.NewValid())
                               .Insert();

            existingForm.PaymentDetails.Should().BeNull("no data stored before executing command");

            var cmd = new AddPaymentDetails
            {
                FormId         = "form123",
                PaymentDetails = PaymentDetailsBuilder.NewValid(),
            };

            cmd.Execute();

            var updatedForm = Repository.Load <ChangeOfCircs>("form123");

            updatedForm.PaymentDetails.Should().NotBeNull();
            updatedForm.PaymentDetails.AccountNumber.Should().Be(cmd.PaymentDetails.AccountNumber);
        }
コード例 #9
0
        public void Find_PopulatesExistingDetail_IfCurrentDetailDoesNotExist()
        {
            var existingForm = new ChangeOfCircsBuilder("form123")
                               .WithCompletedSections(excludeOptionalSections: true)
                               .Insert();

            var query = new FindCocSection
            {
                FormId  = "form123",
                Section = Sections.Consent,
            };

            var details = query.Find();

            var expectedDetail = new CocDetail {
                PreviousSection = null
            };

            ChangeOfCircsBuilder.CopySectionsFrom(existingForm, expectedDetail, useExisting: true);

            details.ShouldBeEquivalentTo(expectedDetail);
        }
コード例 #10
0
        public void Find_PopulatesDetail()
        {
            var existingForm = new ChangeOfCircsBuilder("form123")
                               .WithCompletedSections(markAsCompleted: false)
                               .Insert();

            var query = new FindCocSection
            {
                FormId  = "form123",
                Section = Sections.Consent,
            };

            var detail = query.Find();

            var expectedDetail = new CocDetail {
                PreviousSection = null
            };

            ChangeOfCircsBuilder.CopySectionsFrom(existingForm, expectedDetail);

            detail.ShouldBeEquivalentTo(expectedDetail);
        }
コード例 #11
0
        public void Execute_StoresConsent()
        {
            new BestStartGrantBuilder("form").PreviousApplicationFor("*****@*****.**").Insert();

            var existingForm = new ChangeOfCircsBuilder("form123")
                               .Insert();

            existingForm.UserId.Should().BeNull("no data stored before executing command");

            var cmd = new AddIdentity
            {
                FormId   = "form123",
                Identity = "*****@*****.**",
            };

            cmd.Execute();

            var updatedForm = Repository.Load <ChangeOfCircs>("form123");

            updatedForm.UserId.Should().NotBeNull();
            updatedForm.UserId.Should().Be(cmd.Identity);
        }
コード例 #12
0
        public void Execute_StoresEvidence()
        {
            var existingForm = new ChangeOfCircsBuilder("form123")
                               .With(f => f.Evidence, EvidenceBuilder.NewValid(e => e.SendingByPost = false))
                               .Insert(f => f.Evidence.AddFiles(f, 2));

            existingForm.Evidence.SendingByPost.Should().BeFalse("not set before executing command");
            existingForm.Evidence.Files.Count.Should().Be(2, "should have existing uploaded files");

            var cmd = new AddEvidence
            {
                FormId   = "form123",
                Evidence = EvidenceBuilder.NewValid(),
            };

            cmd.Execute();

            var updatedForm = Repository.Load <ChangeOfCircs>("form123");

            updatedForm.Evidence.SendingByPost.Should().Be(cmd.Evidence.SendingByPost);
            updatedForm.Evidence.Files.Count.Should().Be(2, "files should not be overwritten");
        }