예제 #1
0
        public void build_invoice_with_nested_builders()
        {
            Invoice invoice = InvoiceBuilder.AnInvoice()
                              .WithRecipient(RecipientBuilder.ARecipient().WithAddress(AddressBuilder.AnAddress().WithCity("London")))
                              .WithInvoiceLines(InvoiceLineBuilder.AnInvoiceLine().WithProduct("Boots"),
                                                InvoiceLineBuilder.AnInvoiceLine().WithProduct("Cape"))
                              .Build();

            Assert.That(invoice.recipient.address.city, Is.EqualTo("London"));
            Assert.That(invoice.lines.invoiceLines[1].product, Is.EqualTo("Cape"));
        }
예제 #2
0
 public InvoiceBuilder WithRecipient(RecipientBuilder recipientBuilder)
 {
     recipient = recipientBuilder.Build();
     return(this);
 }