public void CreateExcelReport_When_Multiple_Sheets_Expect_Both_Populated()
        {
            //---------------Arrange------------------
            var configuration = SetupConfiguration();
            var reportData    = File.ReadAllText("ExampleData\\CampaignDetailedReport.json");
            var wordGateway   = new ReportGateway(configuration);

            var input = new RenderExcelInput
            {
                JsonModel    = reportData,
                ReportName   = "test.xslx",
                TemplateName = "CampaignDetailedReport",
                SheetNumbers = new List <int> {
                    1, 2
                }
            };
            //---------------Act----------------------
            var actual = wordGateway.CreateExcelReport(input);

            //---------------Assert-------------------
            File.WriteAllBytes("c:\\tmp\\two-tab.xlsx", actual.FetchDocumentAsByteArray());
            var expected = File.ReadAllText("Expected\\RenderedCampaignDetailedReportBase64.txt");

            Assert.Equal(expected.Substring(0, 50), actual.Base64String.Substring(0, 50));
        }
        public void CreateExcelReport_GivenTemplate_Has_Dynamic_Chart_ShouldReturnRenderedReport()
        {
            //---------------Arrange------------------
            var configuration = SetupConfiguration();
            var reportData    = File.ReadAllText("ExampleData\\dynamic-chart-range.json");
            var wordGateway   = new ReportGateway(configuration);
            var input         = new RenderExcelInput {
                JsonModel = reportData, ReportName = "test.xslx", TemplateName = "dynamic-chart", SheetNumber = 1
            };
            //---------------Act----------------------
            var actual = wordGateway.CreateExcelReport(input);
            //---------------Assert-------------------
            var expected = File.ReadAllText("Expected\\RenderedDynamicChartExcelBase64.txt");

            Assert.Equal(expected.Substring(0, 50), actual.Base64String.Substring(0, 50));
        }
        public void CreateExcelReport_WhenInvalidTemplateName_ShouldReturnTemplateNameError()
        {
            //---------------Arrange------------------
            var configuration = SetupConfiguration();
            var reportGateway = new ReportGateway(configuration);
            var input         = new RenderExcelInput {
                JsonModel = "", ReportName = "test.xslx", TemplateName = "INVALID_NAME"
            };
            //---------------Act----------------------
            var actual = reportGateway.CreateExcelReport(input);

            //---------------Assert-------------------
            Assert.True(actual.HasErrors());
            Assert.Contains("Invalid Report Template", actual.ErrorMessages[0]);
            Assert.Contains("INVALID_NAME.xlsx", actual.ErrorMessages[0]);
        }
        public void CreateExcelReport_WhenValidInput_ShouldReturnRenderedReport()
        {
            //---------------Arrange------------------
            var configuration = SetupConfiguration();
            var reportData    = File.ReadAllText("ExampleData\\ExcelSampleData.json");
            var wordGateway   = new ReportGateway(configuration);
            var input         = new RenderExcelInput {
                JsonModel = reportData, ReportName = "test.xslx", TemplateName = "SimpleReport"
            };
            //---------------Act----------------------
            var actual = wordGateway.CreateExcelReport(input);
            //---------------Assert-------------------
            var expected = File.ReadAllText("Expected\\RenderedExcelBase64.txt");

            Assert.Equal(expected.Substring(0, 50), actual.Base64String.Substring(0, 50));
        }