Пример #1
0
        public void TrackPassedCustomerId()
        {
            var customerId = "123";
            var command    = new OpenInvoiceCommand(customerId);

            Assert.Equal(customerId, command.CustomerId);
        }
Пример #2
0
 public void Handle(IInvoice invoice, OpenInvoiceCommand command)
 {
     if (!invoice.IsBlank)
     {
         RiseError(new InvalidOperationException("Only blank invoice can be opened."));
     }
     Publish(new InvoiceOpenedEvent(command.CustomerId));
 }
Пример #3
0
        public void AllowToOpenAnInvoice()
        {
            var customerId  = "123";
            var openCommand = new OpenInvoiceCommand(customerId);

            InvoiceOpenedEvent invoiceEvent = null;

            using (this.invoiceRoot
                   .Where(x => x is InvoiceOpenedEvent)
                   .Select(x => x as InvoiceOpenedEvent)
                   .Subscribe(x => invoiceEvent = x))
            {
                this.invoice.SetupGet(x => x.IsBlank).Returns(true);

                this.invoiceRoot.Execute(this.invoice.Object, openCommand);
                Assert.Equal(customerId, invoiceEvent.CustomerId);
            }
        }