Пример #1
0
        public async Task Read_players_supports_no_filter()
        {
            var routeNormaliser  = new Mock <IRouteNormaliser>();
            var playerDataSource = new SqlServerPlayerDataSource(_databaseFixture.ConnectionFactory, routeNormaliser.Object);

            var results = await playerDataSource.ReadPlayers(null).ConfigureAwait(false);

            Assert.Equal(_databaseFixture.TestData.Players.Count, results.Count);
            foreach (var player in _databaseFixture.TestData.Players)
            {
                Assert.NotNull(results.SingleOrDefault(x => x.PlayerId == player.PlayerId));
            }
        }
Пример #2
0
        public async Task Read_players_supports_filter_by_player_id()
        {
            var routeNormaliser  = new Mock <IRouteNormaliser>();
            var playerDataSource = new SqlServerPlayerDataSource(_databaseFixture.ConnectionFactory, routeNormaliser.Object);
            var expectedIds      = _databaseFixture.TestData.Players.Take(3).Select(x => x.PlayerId.Value).ToList();

            var results = await playerDataSource.ReadPlayers(new PlayerFilter { PlayerIds = expectedIds }).ConfigureAwait(false);

            Assert.Equal(expectedIds.Count, results.Count);
            foreach (var playerId in expectedIds)
            {
                Assert.NotNull(results.SingleOrDefault(x => x.PlayerId == playerId));
            }
        }
Пример #3
0
        public async Task Read_players_returns_player_with_identities_and_teams()
        {
            var routeNormaliser  = new Mock <IRouteNormaliser>();
            var playerDataSource = new SqlServerPlayerDataSource(_databaseFixture.ConnectionFactory, routeNormaliser.Object);

            var results = await playerDataSource.ReadPlayers(null).ConfigureAwait(false);

            foreach (var player in _databaseFixture.TestData.Players)
            {
                var result = results.SingleOrDefault(x => x.PlayerId == player.PlayerId);
                Assert.NotNull(result);
                Assert.Equal(player.PlayerRoute, result.PlayerRoute);

                foreach (var identity in player.PlayerIdentities)
                {
                    var resultIdentity = result.PlayerIdentities.SingleOrDefault(x => x.PlayerIdentityId == identity.PlayerIdentityId);
                    Assert.NotNull(resultIdentity);
                    Assert.Equal(identity.PlayerIdentityName, resultIdentity.PlayerIdentityName);
                    Assert.Equal(identity.FirstPlayed?.AccurateToTheMinute(), resultIdentity.FirstPlayed?.AccurateToTheMinute());
                    Assert.Equal(identity.LastPlayed?.AccurateToTheMinute(), resultIdentity.LastPlayed?.AccurateToTheMinute());
                    Assert.Equal(identity.Team.TeamName, resultIdentity.Team.TeamName);
                }
            }
        }