public void SimpleMappingByPath() { var mapper = new XlsxMapper <TestClass>(new MappingOptions { }); var items = mapper.Map(TestXlsxPath); Assert.IsNotNull(items, "Result is null"); Assert.IsTrue(items.Any(), "items empty"); items.SimpleMappingTrace(TestXlsxPath); }
public void MappingWithRowLimit2() { var mapper = new XlsxMapper <TestClass>(new MappingOptions { HasHeader = true, RowsLimit = 100 }); var items = mapper.Map(TestXlsxPath); Assert.IsNotNull(items, "Result is null"); Assert.IsTrue(items.Any(), "items empty"); items.SimpleMappingTrace(TestXlsxPath); }
public void SimpleMappingByStream() { var mapper = new XlsxMapper <TestClass>(new MappingOptions { }); using (var fs = new FileStream(TestXlsxPath, FileMode.Open)) { var items = mapper.Map(fs); Assert.IsNotNull(items, "Result is null"); Assert.IsTrue(items.Any(), "items empty"); items.SimpleMappingTrace(TestXlsxPath); } }
public void MappingWithRowLimit() { try { var mapper = new XlsxMapper <TestClass>(new MappingOptions { RowsLimit = 99 }); var items = mapper.Map(TestXlsxPath); } catch (TableMappingException ex) { Trace.WriteLine($"{ex.Message}; Row {ex.Row}"); return; } Assert.Fail("TableMappingException has not been thrown"); }
public void MappingWithValidation() { var mapper = new XlsxMapper <ValidationTestClass>(new MappingOptions { EnableValidation = true }); try { var items = mapper.Map(ValidationTestXlsxPath); } catch (TableMappingException ex) { Trace.WriteLine($"{ex.Message}; Row {ex.Row}"); return; } Assert.Fail("TableMappingException has not been thrown"); }
public void MappingWithSuppressConvertTypeErrors() { try { var mapper = new XlsxMapper <TestClass>(new MappingOptions { SuppressConvertTypeErrors = false }); var items = mapper.Map(SuppressConvertTypeErrorsTestXlsxPath); Assert.IsNotNull(items, "Result is null"); Assert.IsTrue(items.Any(), "items empty"); items.SimpleMappingTrace(TestXlsxPath); } catch (TableMappingException ex) { Trace.WriteLine($"{ex.Message}; Row {ex.Row}"); return; } Assert.Fail("TableMappingException has not been thrown"); }