public async Task GetReportAsync_ShouldReturnErrorWhenExceptionInQuery2()
        {
            // ARRANGE
            var mockProgressInStudyQuery = new Mock <IProgressInStudyQuery>();

            mockProgressInStudyQuery
            .Setup(p => p.GetByRaspredelenie(It.IsAny <int>()))
            .ReturnsAsync(GetTestProgressInStudy());
            mockProgressInStudyQuery
            .Setup(p => p.GetTotalsByRaspredelenie(It.IsAny <int>()))
            .ThrowsAsync(new Exception("Mock exception"));

            var reportsConfiguration = new ReportsConfiguration {
                BaseDirectory = @"C:\Users\E7450\source\repos\TrainingDivision\TrainingDivisionKedis.BLL.Tests\bin\Debug\netcoreapp2.2\ReportTemplates\", VedomostTemplate = @"VedomostTemplate.docx"
            };
            IOptions <ReportsConfiguration> options = Options.Create(reportsConfiguration);

            var mockContextFactory = SetupContextFactory(mockProgressInStudyQuery.Object);

            _sut = new VedomostReportService(mockContextFactory.Object, options);

            // ACT
            var actual = await _sut.GetReportAsync(1);

            // ASSERT
            Assert.Equal("Mock exception", actual.Error.Message);
        }
        public async Task GetReportAsync_ShouldReturnFileDto()
        {
            // ARRANGE
            var mockProgressInStudyQuery = new Mock <IProgressInStudyQuery>();

            mockProgressInStudyQuery
            .Setup(p => p.GetByRaspredelenie(It.IsAny <int>()))
            .ReturnsAsync(GetTestProgressInStudy());
            mockProgressInStudyQuery
            .Setup(p => p.GetTotalsByRaspredelenie(It.IsAny <int>()))
            .ReturnsAsync(GetTestTotals());

            var reportsConfiguration = new ReportsConfiguration {
                BaseDirectory = @"C:\Users\E7450\source\repos\TrainingDivision\TrainingDivisionKedis.BLL.Tests\bin\Debug\netcoreapp2.2\ReportTemplates\", VedomostTemplate = @"VedomostTemplate.docx"
            };
            IOptions <ReportsConfiguration> options = Options.Create(reportsConfiguration);

            var mockContextFactory = SetupContextFactory(mockProgressInStudyQuery.Object);

            _sut = new VedomostReportService(mockContextFactory.Object, options);

            // ACT
            var actual = await _sut.GetReportAsync(1);

            // ASSERT
            Assert.True(actual.Succedeed);
            Assert.True(actual.Entity.FileBytes.Length > 0);
            Assert.Contains(GetTestProgressInStudy().First().SubjectName, actual.Entity.FileName);
        }
示例#3
0
        public ReportBuilder(IConfigurationProvider provider, ILog log)
        {
            configuration = provider.Get(ReportsConfiguration.Default);
            this.log      = log;

            tests = new Dictionary <Guid, ExtentTest>();

            var reportPath = Path.Combine(
                configuration
                .ReportsFolder
                .GetRootedPath()
                .EnsureDirectoryExistence(),
                $"Report.html").GetRootedPath();
            var stylePath = configuration.ReportStyleFile.GetRootedPath();

            report = new ExtentReports(reportPath, configuration.RewriteExistingReport, DisplayOrder.NewestFirst);
            report.LoadConfig(stylePath);

            AppendEnvironmentInfo();
        }
 private void connectModel()
 {
     ReportsConfigurationModel = new ReportsConfiguration();
 }