public void WithNullArrayTest() { var model = new DocumentWithArray { Array = null, NonArray = "StringValue" }; var stringTemplate = new[] { new[] { "", "Template:RootTemplate:A2:D4", "", "" }, new[] { "", "Адреса:", "Имена:", "" }, new[] { "", "Value::Array[].Address", "Value::Array[].Name", "" }, new[] { "Value::NonArray", "", "", "" } }; var template = FakeTable.GenerateFromStringArray(stringTemplate); var target = new FakeTable(100, 100); var tableBuilder = new TableBuilder(target, new TableNavigator(new CellPosition("B2"), logger)); var templateEngine = new SkbKontur.Excel.TemplateEngine.TemplateEngine(template, logger); templateEngine.Render(tableBuilder, model); target.GetCell(new CellPosition("C2")).StringValue.Should().Be("Адреса:"); target.GetCell(new CellPosition("D2")).StringValue.Should().Be("Имена:"); target.GetCell(new CellPosition("C3")).StringValue.Should().BeEmpty(); target.GetCell(new CellPosition("D3")).StringValue.Should().BeEmpty(); target.GetCell(new CellPosition("B4")).StringValue.Should().Be("StringValue"); DebugPrinting(target, new CellPosition(1, 1), new CellPosition(20, 20)); }
public void ObjectWithArrayPrintingTest() { var model = new DocumentWithArray { Array = new[] { new Organization { Address = "Address1", Name = "Name1" }, new Organization { Address = "Address2", Name = "Name2" }, new Organization { Address = "Address3", Name = "Name3" }, new Organization { Address = "Address4", Name = "Name4" } }, NonArray = "StringValue" }; var stringTemplate = new[] { new[] { "", "Template:RootTemplate:A2:D4", "", "" }, new[] { "", "Адреса:", "Имена:", "" }, new[] { "", "Value::Array[].Address", "Value::Array[].Name", "" }, new[] { "Value::NonArray", "", "", "" } }; var template = FakeTable.GenerateFromStringArray(stringTemplate); var target = new FakeTable(100, 100); var tableBuilder = new TableBuilder(target, new TableNavigator(new CellPosition("B2"), logger)); var templateEngine = new SkbKontur.Excel.TemplateEngine.TemplateEngine(template, logger); templateEngine.Render(tableBuilder, model); target.GetCell(new CellPosition("C2")).StringValue.Should().Be("Адреса:"); target.GetCell(new CellPosition("D2")).StringValue.Should().Be("Имена:"); target.GetCell(new CellPosition("C3")).StringValue.Should().Be("Address1"); target.GetCell(new CellPosition("C4")).StringValue.Should().Be("Address2"); target.GetCell(new CellPosition("C5")).StringValue.Should().Be("Address3"); target.GetCell(new CellPosition("C6")).StringValue.Should().Be("Address4"); target.GetCell(new CellPosition("D3")).StringValue.Should().Be("Name1"); target.GetCell(new CellPosition("D4")).StringValue.Should().Be("Name2"); target.GetCell(new CellPosition("D5")).StringValue.Should().Be("Name3"); target.GetCell(new CellPosition("D6")).StringValue.Should().Be("Name4"); target.GetCell(new CellPosition("B7")).StringValue.Should().Be("StringValue"); DebugPrinting(target, new CellPosition(1, 1), new CellPosition(20, 20)); }