public PerformanceTest() { _excelImportService = _excelImportService.Resolve(); _excelExportService = _excelExportService.Resolve(); _rows = DataLib.GetExcelDataRows(rowsCount, 10); var performance = new PerformanceTestDTO(); for (int i = 0; i < rowsCount; i++) { _datas.Add(performance); } }
public void ConvertHadrCode_硬编码转换_n条() { var rows = DataLib.GetExcelDataRows(rowsCount, 10); var result = new List <PerformanceTestDTO>(); foreach (var item in rows) { var data = new PerformanceTestDTO() { p1 = item.DataCols.FirstOrDefault(x => x.PropertyName == "p1")?.ColValue, p2 = item.DataCols.FirstOrDefault(x => x.PropertyName == "p2")?.ColValue, p3 = item.DataCols.FirstOrDefault(x => x.PropertyName == "p3")?.ColValue, p4 = item.DataCols.FirstOrDefault(x => x.PropertyName == "p4")?.ColValue, p5 = item.DataCols.FirstOrDefault(x => x.PropertyName == "p5")?.ColValue, p6 = item.DataCols.FirstOrDefault(x => x.PropertyName == "p6")?.ColValue, p7 = item.DataCols.FirstOrDefault(x => x.PropertyName == "p7")?.ColValue, p8 = item.DataCols.FirstOrDefault(x => x.PropertyName == "p8")?.ColValue, p9 = item.DataCols.FirstOrDefault(x => x.PropertyName == "p9")?.ColValue, p10 = item.DataCols.FirstOrDefault(x => x.PropertyName == "p10")?.ColValue, }; } for (int i = 0; i < result.Count; i++) { Assert.Equal($"r{i + 1}c1", result[i].p1); Assert.Equal($"r{i + 1}c2", result[i].p2); Assert.Equal($"r{i + 1}c3", result[i].p3); Assert.Equal($"r{i + 1}c4", result[i].p4); Assert.Equal($"r{i + 1}c5", result[i].p5); Assert.Equal($"r{i + 1}c6", result[i].p6); Assert.Equal($"r{i + 1}c7", result[i].p7); Assert.Equal($"r{i + 1}c8", result[i].p8); Assert.Equal($"r{i + 1}c9", result[i].p9); Assert.Equal($"r{i + 1}c10", result[i].p10); } }