public async Task CreateContact_Command_should_return_new_Contact() { // Arrange var context = DbContextFactory.CreateContext(); var validator = new ContactValidator(); var contactModel = ContactFactory.GetContactModel(0); var command = new CreateContactCommand(contactModel); var handler = new CreateContactCommandHandler(context, validator, _mapper); // Act var result = await handler.Handle(command, new CancellationToken()); // Assert Assert.IsNotNull(result); Assert.IsTrue(result.IsSuccessful); Assert.IsTrue(result.Id > 0); }
public async void Handle_ShouldCallAddAsync() { await _test.Handle(new CreateContactCommand(), default); A.CallTo(() => _contactRepository.AddAsync(A <Contacts> ._)).MustHaveHappenedOnceExactly(); }