public async Task HandleAsync(RegisterNewDeliveryCommand command) { var type = new DeliveryType(command.DeliveryTypeId); var order = new Order(command.OrderId); var address = new Address(command.Recipient, command.Address, command.City, command.PostalCode); var delivery = _factory.Create(type, order, address); await _deliveries.Save(delivery); await EventBus.Current.PublishAsync(new NewDeliveryRegisteredEvent(delivery.Id)); }
public void should_throw_when_arguments_are_null() { // arrange var factory = new DeliveryFactory(); var scheduler = UseTestSchedulers().CurrentThread; var eventObserver = EventBus.Current.Observable <NewDeliveryRegisteredEvent>() .CreateTestObserver(scheduler); // act / assert Assert.Throws <ArgumentException>(() => factory.Create(null, null, null)); eventObserver.AssertNoErrors(); eventObserver.AssertValuesCount(0); }