public async Task <IActionResult> CreateAsync([FromBody] CreatePhoneBookDto createPhoneBookDto) { var command = new CreatePhoneBookCommand { Name = createPhoneBookDto.Name }; await _mediator.DispatchAsync(command); return(Ok()); }
public async System.Threading.Tasks.Task CreatePhoneBookCommandHandler_Fail() { //Given var createPhoneBookCommandHandler = new CreatePhoneBookCommandHandler(_phoneBookRepositoryMock); await _phoneBookRepositoryMock.AddAsync(new PhoneBookAggregateRoot { Name = _phoneBookName }); var createPhoneBookCommand = new CreatePhoneBookCommand { Name = _phoneBookName }; //When await Assert.ThrowsAsync <ValidateException>(() => createPhoneBookCommandHandler.HandleAsync(createPhoneBookCommand)); }
public async System.Threading.Tasks.Task CreatePhoneBookCommandHandler_Success() { //Given var createPhoneBookCommandHandler = new CreatePhoneBookCommandHandler(_phoneBookRepositoryMock); var createPhoneBookCommand = new CreatePhoneBookCommand { Name = _phoneBookName }; //When await createPhoneBookCommandHandler.HandleAsync(createPhoneBookCommand); //Then Assert.Contains(((PhoneBookRepositoryMock)_phoneBookRepositoryMock).phoneBookAggregates, a => a.Name == _phoneBookName); }