public async Task <ICommandResult> Handle(CreateCustomerCommand command) { var document = new Document(command.DocumentNumber, DocumentType.CPF); var name = new Name(command.FirstName, command.Surname); var email = new Email(command.Email); var customer = new Customer().Create(document, name, command.Address); var request = new ValidateEmailRequest($"{name}", $"{document}", $"{email}"); await _validateEmailService.Send(request); await _bus.RaiseEvents(customer.PendingEvents); return(new SuccessfulCommandResult("customer was created", command)); }
public async Task GivenThatExistaAListOfEventsThenShouldBeRaisedAllEventsFromList() { var expectedAggregatedId = Guid.NewGuid().ToString(); var events = new Queue <INotifiableCelebrityEvent>(); events.Enqueue(new FakeNotifiableCelebrityEvent(expectedAggregatedId, new { Foo = "Foo", Bar = "Bar" })); events.Enqueue(new FakeNotifiableCelebrityEvent(expectedAggregatedId, new { Foo = "Foo", Bar = "Bar" })); await _eventsBus.RaiseEvents(events); await _eventStore.Received(events.Count).Commit(Arg.Is <INotifiableCelebrityEvent>(e => e.AggregatedId == expectedAggregatedId)); await _mediator.Received(events.Count).Publish(Arg.Is <INotifiableCelebrityEvent>(e => e.AggregatedId == expectedAggregatedId)); }