public async Task GenerateReportAsync_gives_excel_with_data_from_hotel_rates_repository() { var hotelRatesRepoMock = new Mock <IHotelRateRepository>(); hotelRatesRepoMock.Setup(m => m.GetAllAsync()) .Returns(GetTestAsyncEnumerable()); const string excelFilePath = "./testexcel.xlsx"; var excelOptions = new ExcelSettingsOptions { OutputLocation = excelFilePath, SheetName = "test" }; var excelOptionsMock = new Mock <IOptions <ExcelSettingsOptions> >(); excelOptionsMock.Setup(m => m.Value) .Returns(excelOptions); var excelReportGenerator = new ExcelReportGenerator(hotelRatesRepoMock.Object, new HotelRateMapper(), excelOptionsMock.Object); await excelReportGenerator.GenerateReportAsync(); hotelRatesRepoMock.Verify(m => m.GetAllAsync(), Times.Once); File.Exists(excelFilePath).Should().Be(true); AssertExcelFile(excelFilePath); }
public ExcelReportGenerator(IHotelRateRepository hotelRateRepo, HotelRateMapper mapper, IOptions <ExcelSettingsOptions> excelOptions) { _hotelRateRepo = hotelRateRepo; _hotelRateMapper = mapper; _excelSettings = excelOptions.Value; }