Beispiel #1
0
        public async Task GetAllReportsTest()
        {
            var options = new DbContextOptionsBuilder <ApplicationDbContext>()
                          .UseInMemoryDatabase(Guid.NewGuid().ToString());
            var reportsRepository = new EfDeletableEntityRepository <Report>(new ApplicationDbContext(options.Options));

            foreach (var report in this.GetReportsData())
            {
                await reportsRepository.AddAsync(report);

                await reportsRepository.SaveChangesAsync();
            }

            AutoMapperConfig.RegisterMappings(typeof(ReportViewModel).Assembly);
            var service = new ReportsService(reportsRepository);

            var reports = service.GetAllReports <ReportViewModel>();

            Assert.Equal(4, reports.Count());
        }