Ploeh.Samples.Loan.AdditionalApplicantsMortgageApplicationProcessor.ProduceOffer C# (CSharp) Method

ProduceOffer() public method

public ProduceOffer ( MortgageApplication application ) : IEnumerable
application Ploeh.Samples.Loan.DataCollection.MortgageApplication
return IEnumerable
        public IEnumerable<IRendering> ProduceOffer(MortgageApplication application)
        {
            yield return new BoldRendering("Additional applicants:");
            yield return new LineBreakRendering();

            var p = new ApplicantProcessor();

            foreach (var a in application.AdditionalApplicants)
            {
                yield return new BulletRendering("");
                foreach (var r in p.ProduceRenderings(a))
                    yield return r;
            }
        }

Usage Example

        public void ProduceOfferReturnsCorrectResultWithOneAdditionalApplicant(
            string name,
            string street,
            string postalCode,
            string country,
            int yearlyIncome,
            string taxAuthority)
        {
            var applicant = new Applicant
            {
                Contact = new Contact
                {
                    Name = name,
                    Address = new Address
                    {
                        Street = street,
                        PostalCode = postalCode,
                        Country = country
                    }
                },
                YearlyIncome = yearlyIncome,
                TaxationAuthority = taxAuthority
            };
            var application = new MortgageApplication();
            application.AdditionalApplicants.Add(applicant);
            var sut = new AdditionalApplicantsMortgageApplicationProcessor();

            var actual = sut.ProduceOffer(application);

            var expected = new IRendering[]
            {
                new BoldRendering("Additional applicants:"),
                new LineBreakRendering(),
                new BulletRendering("")
            }
            .Concat(new ApplicantProcessor().ProduceRenderings(applicant));
            Assert.Equal(expected, actual);
        }
AdditionalApplicantsMortgageApplicationProcessor