public async Task given_invalid_location_should_throw_an_exception ([Frozen] Mock <IContactRepository> contactRepositoy, entity.Contact contact, AddContactInfoHandler handler) { var id = Guid.NewGuid(); contactRepositoy.Setup(r => r.GetAsync(id)).ReturnsAsync(contact); string location = "10"; var exception = await Record.ExceptionAsync(async() => await handler.HandleAsync(new AddContactInfo(id, "Location", location))); exception.Should().NotBeNull(); exception.Should().BeOfType <InvalidLocationException>(); }
public async Task given_invalid_contact_should_throw_an_exception ([Frozen] Mock <IContactRepository> contactRepositoy, AddContactInfoHandler handler) { var id = Guid.NewGuid(); entity.Contact contact = null; contactRepositoy.Setup(r => r.GetAsync(id)).ReturnsAsync(contact); var exception = await Record.ExceptionAsync(async() => await handler.HandleAsync(new AddContactInfo(id, "", ""))); exception.Should().NotBeNull(); exception.Should().BeOfType <ContactNotFoundException>(); }