Exemplo n.º 1
0
        public void Download()
        {
            var options = new DbContextOptionsBuilder <AppDbContext>()
                          .UseInMemoryDatabase(databaseName: "Download")
                          .Options;

            using var context = new AppDbContext(options);
            Reports report4 = new Reports()
            {
                ReportId = 109
            };
            var _hostingEnviroment = new Mock <IWebHostEnvironment>();

            _hostingEnviroment
            .Setup(m => m.EnvironmentName)
            .Returns("Hosting:UnitTestEnvironment");
            _hostingEnviroment.Setup(p => p.ContentRootPath).Returns("C:\\Users\\finta\\source\\repos\\IncidentReportForm\\IncidentReportForm");

            var service  = new ReportRepository(context, _hostingEnviroment.Object);
            var testType = service.Download(report4);

            Assert.IsInstanceOfType(testType, typeof(FileStreamResult));
        }