public async Task ValidateAsync_PatientExists_DoesNothing() { // Arrange var patientContainer = new Mock <IBuyerContainer>(); var patient = new Buyer(); var streetService = new Mock <ICityService>(); var patientDAL = new Mock <IBuyerDAL>(); var patientIdentity = new Mock <IBuyerIdentity>(); patientDAL.Setup(x => x.GetAsync(patientIdentity.Object)).ReturnsAsync(patient); var patientGetService = new BuyerService(patientDAL.Object, streetService.Object); // Act var action = new Func <Task>(() => patientGetService.ValidateAsync(patientContainer.Object)); // Assert await action.Should().NotThrowAsync <Exception>(); }
public async Task ValidateAsync_PatientNotExists_ThrowsError() { // Arrange var fixture = new Fixture(); var id = fixture.Create <int>(); var patientContainer = new Mock <IBuyerContainer>(); patientContainer.Setup(x => x.BuyerId).Returns(id); var patientIdentity = new Mock <IBuyerIdentity>(); var streetService = new Mock <ICityService>(); var patient = new Buyer(); var patientDAL = new Mock <IBuyerDAL>(); patientDAL.Setup(x => x.GetAsync(patientIdentity.Object)).ReturnsAsync((Buyer)null); var patientGetService = new BuyerService(patientDAL.Object, streetService.Object); // Act var action = new Func <Task>(() => patientGetService.ValidateAsync(patientContainer.Object)); // Assert await action.Should().ThrowAsync <InvalidOperationException>($"Buyer not found by id {id}"); }