コード例 #1
0
ファイル: ApplicantProcessor.cs プロジェクト: ploeh/loan
 public IEnumerable<IRendering> ProduceRenderings(Applicant applicant)
 {
     yield return new TextRendering(
         " " +
         applicant.Contact.Name + ", " +
         applicant.Contact.Address.Street + ", " +
         applicant.Contact.Address.PostalCode + ", " +
         applicant.Contact.Address.Country + ". ");
     yield return new BoldRendering("Yearly income:");
     yield return new TextRendering(" " + applicant.YearlyIncome + ". ");
     yield return new BoldRendering("Tax authority:");
     yield return new TextRendering(" " + applicant.TaxationAuthority + ".");
     yield return new LineBreakRendering();
 }
コード例 #2
0
ファイル: ApplicantProcessorTests.cs プロジェクト: ploeh/loan
        public void ProduceRenderingsReturnsCorrectResult(
            string name,
            string street,
            string postalCode,
            string country,
            int yearlyIncome,
            string taxAuthority)
        {
            var sut = new ApplicantProcessor();
            var applicant = new Applicant
            {
                Contact = new Contact
                {
                    Name = name,
                    Address = new Address
                    {
                        Street = street,
                        PostalCode = postalCode,
                        Country = country
                    }
                },
                YearlyIncome = yearlyIncome,
                TaxationAuthority = taxAuthority
            };

            IEnumerable<IRendering> actual = sut.ProduceRenderings(applicant);

            var expected = new IRendering[]
            {
                new TextRendering(
                    " " +
                    name + ", " +
                    street + ", " +
                    postalCode + ", " +
                    country + ". "),
                new BoldRendering("Yearly income:"),
                new TextRendering(" " + yearlyIncome + ". "),
                new BoldRendering("Tax authority:"),
                new TextRendering(" " + taxAuthority + "."),
                new LineBreakRendering()
            };
            Assert.Equal(expected, actual);
        }
        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);
        }