public async Task ThrowException_WhenLogBookAlreadyExists() { var logbookName = "logbook"; var businessId = 1; var mappingProviderMocked = new Mock <IMappingProvider>(); var dateTimeWrapperMocked = new Mock <IDateTimeWrapper>(); var paginatedListMocked = new Mock <IPaginatedList <BusinessShortInfoDTO> >(); BusinessTestUtils.GetContextWithBusinessAndLogBook(nameof(ThrowException_WhenLogBookAlreadyExists), businessId, logbookName); using (var assertContext = new AlphaHotelDbContext(BusinessTestUtils.GetOptions(nameof(ThrowException_WhenLogBookAlreadyExists)))) { var businessService = new BusinessService(assertContext, mappingProviderMocked.Object, dateTimeWrapperMocked.Object, paginatedListMocked.Object); await Assert.ThrowsExceptionAsync <ArgumentException>( async() => await businessService.AddLogBookToBusinessAsync(logbookName, businessId)); } }
public async Task ListBusinessLogbooksAsync_ReturnLogBooks() { var businessId = 1; var logbookName = "logbook"; var mappingProviderMocked = new Mock <IMappingProvider>(); var dateTimeWrapperMocked = new Mock <IDateTimeWrapper>(); var paginatedListMocked = new Mock <IPaginatedList <BusinessShortInfoDTO> >(); BusinessTestUtils.ResetAutoMapper(); BusinessTestUtils.InitializeAutoMapper(); BusinessTestUtils.GetContextWithBusinessAndLogBook(nameof(ListBusinessLogbooksAsync_ReturnLogBooks), businessId, logbookName); using (var assertContext = new AlphaHotelDbContext(BusinessTestUtils.GetOptions(nameof(ListBusinessLogbooksAsync_ReturnLogBooks)))) { var businessService = new BusinessService(assertContext, mappingProviderMocked.Object, dateTimeWrapperMocked.Object, paginatedListMocked.Object); var logbooks = await businessService.ListBusinessLogbooksAsync(businessId); Assert.AreEqual(1, logbooks.Count); } }