public async Task ValidateAsync_haircutExists_DoesNothing() { // Arrange var haircutContainer = new Mock <IHaircutContainer>(); var haircut = new Haircut(); var haircutDAL = new Mock <IHaircutDAL>(); var haircutIdentity = new Mock <IHaircutIdentity>(); haircutDAL.Setup(x => x.GetAsync(haircutIdentity.Object)).ReturnsAsync(haircut); var haircutGetService = new HaircutService(haircutDAL.Object); // Act var action = new Func <Task>(() => haircutGetService.ValidateAsync(haircutContainer.Object)); // Assert await action.Should().NotThrowAsync <Exception>(); }
public async Task ValidateAsync_haircutNotExists_ThrowsError() { // Arrange var fixture = new Fixture(); var id = fixture.Create <int>(); var haircutContainer = new Mock <IHaircutContainer>(); haircutContainer.Setup(x => x.HaircutId).Returns(id); var haircutIdentity = new Mock <IHaircutIdentity>(); var haircut = new Haircut(); var haircutDAL = new Mock <IHaircutDAL>(); haircutDAL.Setup(x => x.GetAsync(haircutIdentity.Object)).ReturnsAsync((Haircut)null); var haircutGetService = new HaircutService(haircutDAL.Object); // Act var action = new Func <Task>(() => haircutGetService.ValidateAsync(haircutContainer.Object)); // Assert await action.Should().ThrowAsync <InvalidOperationException>($"Haircut not found by id {id}"); }