public void TrackPassedCustomerId() { var customerId = "123"; var command = new OpenInvoiceCommand(customerId); Assert.Equal(customerId, command.CustomerId); }
public void Handle(IInvoice invoice, OpenInvoiceCommand command) { if (!invoice.IsBlank) { RiseError(new InvalidOperationException("Only blank invoice can be opened.")); } Publish(new InvoiceOpenedEvent(command.CustomerId)); }
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); } }