public async Task HandleAsync(EmailAccepted @event) { if (@event == null) { throw new ArgumentNullException(nameof(@event)); } var process = await GetProcessOrExceptionAsync(@event.UserId); var user = process.CreateUser(); await _userRepository.SaveAsync(user); }
private void describe_HandleAsync_EmailAccepted() { var emailAccepted = new EmailAccepted(_userId); context["when user registration process is in CreatingUser state"] = () => { before = () => { var process = UserRegistrationProcessMother.InCreatingUserState(_userId); _userRegistrationProcessRepository.SaveAsync(process).Wait(); _sut.HandleAsync(emailAccepted).Wait(); }; it["saves UserCreated event"] = () => _eventStore.LastSavedEvents.Single().should_cast_to <UserCreated>(); it["is idempotent"] = () => { _sut.HandleAsync(emailAccepted).Wait(); _eventStore.LastSavedEvents.should_be_empty(); }; }; }