public void TestCreateSampleExcelFileFromDictionary() { var input = new string[] { "A,B,C,D", "1,2,3,4", "5,6,7,8", "1,2,3,4" }; ExcelSerialization.CSVToExcel(input, "test.xlsx", true); }
public void TestStringEnumerableWithHeaderToDictionary() { var input = new string[] { "A,B,C,D", "1,2,3,4", "5,6,7,8", "1,2,3,4" }; var expected = new List <Dictionary <string, object> >() { new Dictionary <string, object>() { { "A", "1" }, { "B", "2" }, { "C", "3" }, { "D", "4" } }, new Dictionary <string, object>() { { "A", "5" }, { "B", "6" }, { "C", "7" }, { "D", "8" } }, new Dictionary <string, object>() { { "A", "1" }, { "B", "2" }, { "C", "3" }, { "D", "4" } }, }; var actual = ExcelSerialization.ToTableDictionary(input, ',').ToList(); Assert.AreEqual(expected.Count, actual.Count()); Assert.AreEqual(expected.Count(x => x.ContainsKey("A")), actual.Count(x => x.ContainsKey("A"))); Assert.AreEqual(expected.Count(x => x.ContainsKey("B")), actual.Count(x => x.ContainsKey("B"))); Assert.AreEqual(expected.Count(x => x.ContainsKey("C")), actual.Count(x => x.ContainsKey("C"))); Assert.AreEqual(expected.Count(x => x.ContainsKey("D")), actual.Count(x => x.ContainsKey("D"))); for (int i = 0; i < actual.Count(); i++) { Assert.AreEqual(expected[i].Keys, actual[i].Keys); Assert.AreEqual(expected[i].Values, actual[i].Values); } }