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(); }
public async Task AddAsyncWithCorectData() { ApplicationDbContext dbContext = new ApplicationDbContext(new DbContextOptionsBuilder <ApplicationDbContext>() .UseInMemoryDatabase(databaseName: Guid.NewGuid().ToString()).Options); var service = new MachineCountersService(new EfRepository <MachineCounters>(dbContext)); var date = DateTime.UtcNow; await service.AddAsync( 1, 1, 2, 2, date, "1"); var result = await dbContext.MachineCounters.FirstOrDefaultAsync(); Assert.Equal(1, result.ElIn); Assert.Equal(1, result.ElOut); Assert.Equal(2, result.MechIn); Assert.Equal(2, result.MechOut); Assert.Equal(date, result.Date); Assert.Equal("1", result.SlotMachineId); dbContext.Database.EnsureDeleted(); dbContext.Dispose(); }
public async Task AddAsyncWithCorectData() { 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; await service.AddAsync(data, 1, 1, "1"); var report = await dbContext.Reports.FirstOrDefaultAsync(); Assert.Equal(data, report.Date); Assert.Equal(1, report.InForDay); Assert.Equal(1, report.OutForDay); Assert.Equal("1", report.GamingHallId); dbContext.Database.EnsureDeleted(); }