コード例 #1
0
        public async Task AllWithNullId()
        {
            ApplicationDbContext dbContext = new ApplicationDbContext(new DbContextOptionsBuilder <ApplicationDbContext>()
                                                                      .UseInMemoryDatabase(databaseName: Guid.NewGuid().ToString()).Options);
            var service = new SlotMachinesService(new EfDeletableEntityRepository <SlotMachine>(dbContext));

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

            var results = service.All <SlotMachineViewModel>(null);
            int count   = 0;

            foreach (var result in results)
            {
                count++;
            }

            Assert.Equal(0, count);
            dbContext.Database.EnsureDeleted();
        }
コード例 #2
0
        public async Task GetByIdWithNullId()
        {
            ApplicationDbContext dbContext = new ApplicationDbContext(new DbContextOptionsBuilder <ApplicationDbContext>()
                                                                      .UseInMemoryDatabase(databaseName: Guid.NewGuid().ToString()).Options);
            var service = new SlotMachinesService(new EfDeletableEntityRepository <SlotMachine>(dbContext));
            await service.AddAsync(
                "1234567890",
                "Megajack",
                1,
                "1");

            var result = service.GetById <IndexViewModel>(null);

            Assert.True(result == null);
            dbContext.Database.EnsureDeleted();
        }
コード例 #3
0
        public async Task GetHallIdWithValidId()
        {
            ApplicationDbContext dbContext = new ApplicationDbContext(new DbContextOptionsBuilder <ApplicationDbContext>()
                                                                      .UseInMemoryDatabase(databaseName: Guid.NewGuid().ToString()).Options);
            var service = new SlotMachinesService(new EfDeletableEntityRepository <SlotMachine>(dbContext));
            await service.AddAsync(
                "1234567890",
                "Megajack",
                1,
                "1");

            var slotMachine = await dbContext.SlotMachines.FirstOrDefaultAsync();

            var result = service.GetHallId(slotMachine.Id);

            Assert.Equal("1", result);
            dbContext.Database.EnsureDeleted();
        }
コード例 #4
0
        public async Task AddAsyncWithCorectData()
        {
            ApplicationDbContext dbContext = new ApplicationDbContext(new DbContextOptionsBuilder <ApplicationDbContext>()
                                                                      .UseInMemoryDatabase(databaseName: Guid.NewGuid().ToString()).Options);
            var service = new SlotMachinesService(new EfDeletableEntityRepository <SlotMachine>(dbContext));
            await service.AddAsync(
                "1234567890",
                "Megajack",
                1,
                "1");

            var result = await dbContext.SlotMachines.FirstOrDefaultAsync();

            Assert.Equal("1234567890", result.LicenseNumber);
            Assert.Equal("Megajack", result.Model);
            Assert.Equal(1, result.NumberInHall);
            Assert.Equal("1", result.GamingHallId);
            dbContext.Database.EnsureDeleted();
        }
コード例 #5
0
        public async Task DeleteAsyncWithValidId()
        {
            ApplicationDbContext dbContext = new ApplicationDbContext(new DbContextOptionsBuilder <ApplicationDbContext>()
                                                                      .UseInMemoryDatabase(databaseName: Guid.NewGuid().ToString()).Options);
            var service = new SlotMachinesService(new EfDeletableEntityRepository <SlotMachine>(dbContext));
            await service.AddAsync(
                "1234567890",
                "Megajack",
                1,
                "1");

            var slotMachine = await dbContext.SlotMachines.FirstOrDefaultAsync();

            await service.DeleteAsync(slotMachine.Id);

            var result = await dbContext.GamingHalls.Where(x => x.Id == slotMachine.Id).FirstOrDefaultAsync();

            Assert.True(result == null);
            dbContext.Database.EnsureDeleted();
        }