public async Task GetAll_WhenCalled_ShouldReturnAllItems()
        {
            var item = new Game()
            {
                Name      = "example",
                CreatedBy = "user",
                IsDeleted = false,
                Ready     = true
            };
            var item2 = new Game()
            {
                Name      = "example",
                CreatedBy = "user",
                IsDeleted = false,
                Ready     = true
            };
            var entityRepository = new GamesRepository(_dbContext);
            var added            = await entityRepository.Add(item);

            await entityRepository.Add(item2);

            var found = entityRepository.GetAll();

            found.Count().ShouldBe(2);
        }
Esempio n. 2
0
        public async Task GetsGames()
        {
            using (var context = new ApplicationDbContext(_options))
            {
                var team1 = new Team {
                    Id = 1
                };
                var team2 = new Team {
                    Id = 2
                };
                context.Teams.AddRange(team1, team2);
                context.Games.AddRange(
                    new Game {
                    Id = 1, HomeTeam = team1, VisitorTeam = team2, Public = true
                },
                    new Game {
                    Id = 2, HomeTeam = team2, VisitorTeam = team1
                },
                    new Game {
                    Id = 3, HomeTeam = team2, VisitorTeam = team1, Public = true
                });

                context.SaveChanges();
            }

            using (var context = new ApplicationDbContext(_options))
            {
                var gamesRepository = new GamesRepository(context);

                var games = await gamesRepository.GetAll(0, 3, null);

                Assert.Equal(2, games.Count);
                Assert.NotNull(games.SingleOrDefault(x => x.Id == 1));
                Assert.NotNull(games.SingleOrDefault(x => x.Id == 3));
            }
        }
Esempio n. 3
0
 // GET api/games
 public string Get()
 {
     return(Newtonsoft.Json.JsonConvert.SerializeObject(gamesRepositorie.GetAll()));
 }