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);
        }
        public void Constructor_ShouldThrowExceptionWhenArgumentIsNull1()
        {
            var mockFileService = new Mock <IOptions <ReportsConfiguration> >();

            mockFileService
            .SetupGet(f => f.Value)
            .Returns(new ReportsConfiguration {
                BaseDirectory = @"C:\Users\E7450\source\repos\TrainingDivision\TrainingDivisionKedis.BLL.Tests\bin\Debug\netcoreapp2.2\ReportTemplates\", VedomostTemplate = @"VedomostTemplate.txt"
            });
            Assert.Throws <ArgumentNullException>(() => _sut = new VedomostReportService(null, mockFileService.Object));
        }
        public void Constructor_ShouldThrowExceptionWhenDirectoryNotFound()
        {
            var mockDbContextFactory = new Mock <IAppDbContextFactory>();
            var mockFileService      = new Mock <IOptions <ReportsConfiguration> >();

            mockFileService
            .SetupGet(f => f.Value)
            .Returns(new ReportsConfiguration {
                BaseDirectory = @"C:\Users\", VedomostTemplate = @"VedomostTemplate.txt"
            });
            Assert.Throws <FileNotFoundException>(() => _sut = new VedomostReportService(mockDbContextFactory.Object, mockFileService.Object));
        }
        public void Constructor_ShouldThrowExceptionWhenArgumentIsNull2()
        {
            var mockDbContextFactory = new Mock <IAppDbContextFactory>();

            Assert.Throws <ArgumentNullException>(() => _sut = new VedomostReportService(mockDbContextFactory.Object, null));
        }