Esempio n. 1
0
        public async Task AllWithInvalidId()
        {
            ApplicationDbContext dbContext = new ApplicationDbContext(new DbContextOptionsBuilder <ApplicationDbContext>()
                                                                      .UseInMemoryDatabase(databaseName: Guid.NewGuid().ToString()).Options);

            var machineContersService = new MachineCountersService(new EfRepository <MachineCounters>(dbContext));

            var service = new ReportService(new EfDeletableEntityRepository <Report>(dbContext), machineContersService);
            var data    = DateTime.UtcNow;

            for (int i = 1; i <= 5; i++)
            {
                await service.AddAsync(data, 1 + i, 1 + i, "1");
            }

            var reports = service.All <IndexReportViewModel>("11");

            int count = 0;

            foreach (var report in reports)
            {
                count++;
            }

            Assert.Equal(0, count);
            dbContext.Database.EnsureDeleted();
        }