public void EverfiExcelTemplate_ImportCSV_ThrowsFileNotFoundIfFileDoesNotExist() { FileInfo existingFilePath = new FileInfo("../../../Utilities/TestData/faketemplate.xlsx"); FileInfo nonExistingCSVFile = new FileInfo("../../../Utilities/TestData/nonexisting.csv"); var mockLogger = new Mock <ILogger>(); using (EverfiExcelTemplate excelTemplate = new EverfiExcelTemplate(existingFilePath, mockLogger.Object)) { ExcelTextFormat format = new ExcelTextFormat(); Assert.Throws <FileNotFoundException>(() => excelTemplate.ImportCsv(format, nonExistingCSVFile)); } }
public void EverfiExcelTemplate_ImportCSV_ReturnsTrueIfDataIsImported() { FileInfo existingFilePath = new FileInfo("../../../Utilities/TestData/faketemplate.xlsx"); FileInfo csvFile = new FileInfo("../../../Utilities/TestData/data.csv"); bool csvDataImported = false; var mockLogger = new Mock <ILogger>(); using (EverfiExcelTemplate excelTemplate = new EverfiExcelTemplate(existingFilePath, mockLogger.Object)) { ExcelTextFormat format = new ExcelTextFormat(); csvDataImported = excelTemplate.ImportCsv(format, csvFile); } Assert.True(csvDataImported); }
public void EverfiExcelTemplate_ImportCSV_ReturnsFalseIfSheetDoesNotExist() { FileInfo existingFilePath = new FileInfo("../../../Utilities/TestData/faketemplate.xlsx"); FileInfo csvFile = new FileInfo("../../../Utilities/TestData/data.csv"); string wrongSheetName = "Does Not Exist"; bool csvDataImported = true; var mockLogger = new Mock <ILogger>(); using (EverfiExcelTemplate excelTemplate = new EverfiExcelTemplate(existingFilePath, mockLogger.Object)) { ExcelTextFormat format = new ExcelTextFormat(); excelTemplate.TEMPLATE_SHEET_NAME = wrongSheetName; csvDataImported = excelTemplate.ImportCsv(format, csvFile); } Assert.False(csvDataImported); }