public async Task GetScores_Returns_Scores_From_Json() { var repo = new ScoresRepository(); var scores = await repo.GetScores(); scores.Should().NotBeEmpty(); }
public async Task UpdateScore_Saves_To_Json() { var player = "Jonny"; var score = 9000; var repo = new ScoresRepository(); await repo.UpdateScore(new ScoreModel { Player = player, Score = score }); var scores = await repo.GetScores(); scores.Should().NotBeEmpty(); scores.Should().Contain(x => x.Player == player && x.Score == score); }
public void GetScoresTest() { PlayersRepository playersRepository = new PlayersRepository(ConnectionString); GamesRepository gamesRepository = new GamesRepository(ConnectionString); ScoresRepository scoresRepository = new ScoresRepository(ConnectionString); string playerName = GetRandomName(10); string gameName = GetRandomName(10); playersRepository.AddPlayer(new Player(playerName)); _playersList.Add(playerName); gamesRepository.AddGame(new Game(gameName)); _gamesList.Add(gameName); Guid scoreId1 = Guid.NewGuid(), scoreId2 = Guid.NewGuid(); _scoresList.Add(scoreId1); _scoresList.Add(scoreId2); Score score = new Score(scoreId1, playerName, gameName, scores: 5); scoresRepository.AddScore(score); score = new Score(scoreId2, playerName, gameName, scores: 15); scoresRepository.AddScore(score); List <Score> scores = scoresRepository.GetScores(new Game(gameName), new Player(playerName)).ToList(); if (scores.Find(x => x.Id == scoreId1) == null) { Assert.Fail($"Expected score id is {scoreId1}"); } if (scores.Find(x => x.Id == scoreId2) == null) { Assert.Fail($"Expected score id is {scoreId1}"); } }
private void UpdateScores() { _scores = ScoresRepository.GetScores(); ScoresListBox.ItemsSource = _scores; }
public ActionResult <IEnumerable <string> > Get() { IEnumerable <Scores> scores = _scoresRepository.GetScores(); return(Ok(scores)); }