public async Task Get_WhenItemDoesNotExist_ShouldReturnNull()
        {
            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 result = entityRepository.Get("not existing id");

            result.ShouldBeNull();
        }
        public async Task Get_WhenItemExists_ShouldReturnItem()
        {
            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.Get(added.Id);

            found.Id.ShouldBe(added.Id);
            found.IsDeleted.ShouldBe(added.IsDeleted);
            found.Name.ShouldBe(added.Name);
            found.Ready.ShouldBe(added.Ready);
        }
示例#3
0
        private static List <Game> GetOpenGames()
        {
            var gamesRepository = new GamesRepository();
            var allGames        = gamesRepository.Get().ToList();

            WriteLine(string.Format("Got {0} games from database", allGames.Count));
            var openGames = allGames.OrderBy(game => game.Date).Where(game => game.Date.Subtract(TimeSpan.FromMinutes(30)) > DateTime.UtcNow).ToList();

            WriteLine(string.Format("{0} games are still open", openGames.Count));
            return(openGames);
        }
示例#4
0
 // GET api/games/5
 public string Get(int id)
 {
     return(Newtonsoft.Json.JsonConvert.SerializeObject(gamesRepositorie.Get(id)));
 }
示例#5
0
 public IEnumerable <Game> Get()
 {
     return(_repo.Get());
 }
示例#6
0
 public IEnumerable <Game> Get()
 {
     return(repository.Get());
 }