コード例 #1
0
        public void can_retrieve_player_json_from_site_and_parse_as_player()
        {
            //Arrange

            //Act
            var json = _playerJsonService.GetPlayerJson(514);

            //Assert
            var jsonPlayer = new JsonPlayer(json);
            Assert.That(jsonPlayer.Id, Is.EqualTo(514));
            Assert.That(jsonPlayer.MaxCost, Is.GreaterThan(0));
        }
コード例 #2
0
        public void can_parse_player_future_fixtures_from_json()
        {
            //Arrange
            var testJson = ResourceHelper.GetFromResources("FantasyFootballRobot.Tests.TestData.SampleGoalkeeperJson.txt");

            //Act
            var player = new JsonPlayer(testJson);

            //Assert
            Assert.That(player.Fixtures.All.Length, Is.EqualTo(18));
            Assert.That(player.Fixtures.All.First()[0], Is.EqualTo("15 Jan"));
            Assert.That(player.Fixtures.All.First()[1], Is.EqualTo("Gameweek 21"));
            Assert.That(player.Fixtures.All.First()[2], Is.EqualTo("Arsenal (H)"));
        }
コード例 #3
0
        public void can_parse_player_fixture_history_from_json()
        {
            //Arrange
            var testJson = ResourceHelper.GetFromResources("FantasyFootballRobot.Tests.TestData.SampleGoalkeeperJson.txt");

            //Act
            var player = new JsonPlayer(testJson);

            //Assert
            Assert.That(player.FixtureHistory.All.Length, Is.EqualTo(20));
            Assert.That(player.FixtureHistory.All.First()[0], Is.EqualTo("15 Aug"));
            Assert.That(player.FixtureHistory.All.First()[1], Is.EqualTo(1));
            Assert.That(player.FixtureHistory.All.First()[2], Is.EqualTo("MCI(A) 0-4"));
            Assert.That(player.FixtureHistory.All.First()[18], Is.EqualTo(3));
        }
コード例 #4
0
        public void player_future_fixtures_are_mapped_correctly()
        {
            //Arrange
            var json = ResourceHelper.GetFromResources("FantasyFootballRobot.Tests.TestData.SampleGoalkeeperJson.txt");
            var jsonPlayer = new JsonPlayer(json);

            //Act
            var player = Mapper.Map<JsonPlayer, Player>(jsonPlayer);

            //Assert
            Assert.That(player.FutureFixtures.Count, Is.EqualTo(18));
            Assert.That(player.FutureFixtures.First().Home, Is.True);
            Assert.That(player.FutureFixtures.First().OppositionClubCode, Is.EqualTo(Club.Arsenal.Code));
            Assert.That(player.FutureFixtures[3].OppositionClubCode, Is.EqualTo(Club.WestBrom.Code));
            Assert.That(player.FutureFixtures.First().Date, Is.EqualTo(new DateTime(2012, 1, 15)));
        }
コード例 #5
0
        public void basic_player_attributes_mapped_correctly()
        {
            //Arrange
            var json = ResourceHelper.GetFromResources("FantasyFootballRobot.Tests.TestData.SampleGoalkeeperJson.txt");
            var jsonPlayer = new JsonPlayer(json);

            //Act
            var player = Mapper.Map<JsonPlayer, Player>(jsonPlayer);

            //Assert
            Assert.That(player.Id, Is.EqualTo(514));
            Assert.That(player.NowCost, Is.EqualTo(52));
            Assert.That(player.ClubCode, Is.EqualTo(Club.Swansea.Code));
            Assert.That(player.Position, Is.EqualTo(Position.Goalkeeper));
            Assert.That(player.Name, Is.EqualTo("Michel Vorm"));
            Assert.That(player.Status, Is.EqualTo(Status.Available));
        }
コード例 #6
0
        public void can_parse_player_properties_from_json()
        {
            //Arrange
            var testJson = ResourceHelper.GetFromResources("FantasyFootballRobot.Tests.TestData.SampleGoalkeeperJson.txt");

            //Act
            var player = new JsonPlayer(testJson);

            //Assert
            Assert.That(player.Id, Is.EqualTo(514));
            Assert.That(player.EventCost, Is.EqualTo(52));
            Assert.That(player.LastSeasonPoints, Is.EqualTo(0));
            Assert.That(player.FirstName, Is.EqualTo("Michel"));
            Assert.That(player.SecondName, Is.EqualTo("Vorm"));
            Assert.That(player.TeamId, Is.EqualTo(16));
            Assert.That(player.TeamName, Is.EqualTo("Swansea"));
            Assert.That(player.TypeName, Is.EqualTo("Goalkeeper"));
        }
コード例 #7
0
        public void season_12_13_player_fixtures_are_mapped_correctly()
        {
            //Arrange
            var configMock = new Mock<IConfigurationSettings> { CallBase = true };
            configMock.SetupGet(x => x.SeasonStartYear).Returns(2012);
            SetConfigurationInstance(configMock.Object);

            var json = ResourceHelper.GetFromResources("FantasyFootballRobot.Tests.TestData.Season1213.SamplePlayerJson.txt");
            var jsonPlayer = new JsonPlayer(json);

            //Act
            var player = Mapper.Map<JsonPlayer, Player>(jsonPlayer);

            //Assert
            Assert.That(player.FutureFixtures.Count, Is.EqualTo(0));
            Assert.That(player.PastFixtures.Count, Is.EqualTo(38));
            Assert.That(player.PastFixtures.Last().OppositionClubCode, Is.EqualTo(Club.Newcastle.Code));
            Assert.That(player.PastFixtures.Last().Date, Is.EqualTo(new DateTime(2013, 5, 19)));
        }
コード例 #8
0
        public void player_past_fixtures_are_mapped_correctly()
        {
            //Arrange
            var json = ResourceHelper.GetFromResources("FantasyFootballRobot.Tests.TestData.SampleGoalkeeperJson.txt");
            var jsonPlayer = new JsonPlayer(json);

            //Act
            var player = Mapper.Map<JsonPlayer, Player>(jsonPlayer);

            //Assert
            Assert.That(player.PastFixtures.Count, Is.EqualTo(20));
            Assert.That(player.PastFixtures.First().Home, Is.False);
            Assert.That(player.PastFixtures.First().OppositionClubCode, Is.EqualTo(Club.ManCity.Code));
            Assert.That(player.PastFixtures.First().Date, Is.EqualTo(new DateTime(2011, 8, 15)));
            Assert.That(player.PastFixtures.Last().Date, Is.EqualTo(new DateTime(2012, 1, 2)));
            Assert.That(player.PastFixtures.First().GameWeek, Is.EqualTo(1));
            Assert.That(player.PastFixtures.First().PlayerValueAtTime, Is.EqualTo(40));
            Assert.That(player.PastFixtures.First().MinutesPlayed, Is.EqualTo(90));
            Assert.That(player.PastFixtures.First().TeamGoals, Is.EqualTo(0));
            Assert.That(player.PastFixtures.First().OppositionGoals, Is.EqualTo(4));
            Assert.That(player.PastFixtures.First().TotalPointsScored, Is.EqualTo(3));
        }
コード例 #9
0
        public void player_past_fixtures_points_are_mapped()
        {
            //Arrange
            var json = ResourceHelper.GetFromResources("FantasyFootballRobot.Tests.TestData.SampleGoalkeeperJson.txt");
            var jsonPlayer = new JsonPlayer(json);

            //Act
            var player = Mapper.Map<JsonPlayer, Player>(jsonPlayer);

            //Assert
            Assert.That(player.PastFixtures.First().TotalPointsScored, Is.EqualTo(3));
            Assert.That(player.PastFixtures.First().GoalsScored, Is.EqualTo(0));
            Assert.That(player.PastFixtures.First().Assists, Is.EqualTo(0));
            Assert.That(player.PastFixtures.First().CleanSheets, Is.EqualTo(0));
            Assert.That(player.PastFixtures.First().GoalsConceded, Is.EqualTo(4));
            Assert.That(player.PastFixtures.First().OwnGoals, Is.EqualTo(0));
            Assert.That(player.PastFixtures.First().PenaltiesSaved, Is.EqualTo(0));
            Assert.That(player.PastFixtures.First().PenaltiesMissed, Is.EqualTo(0));
            Assert.That(player.PastFixtures.First().YellowCards, Is.EqualTo(0));
            Assert.That(player.PastFixtures.First().RedCards, Is.EqualTo(0));
            Assert.That(player.PastFixtures.First().Saves, Is.EqualTo(10));
            Assert.That(player.PastFixtures.First().Bonus, Is.EqualTo(0));
        }
コード例 #10
0
        public void player_past_seasons_are_mapped_for_players_with_no_past_seasons()
        {
            //Arrange
            var json = ResourceHelper.GetFromResources("FantasyFootballRobot.Tests.TestData.SampleGoalkeeperJson.txt");
            var jsonPlayer = new JsonPlayer(json);

            //Act
            var player = Mapper.Map<JsonPlayer, Player>(jsonPlayer);

            //Assert
            Assert.That(player.PastSeasons, Is.Empty);
        }
コード例 #11
0
        public void player_past_seasons_are_mapped_for_players()
        {
            //Arrange
            var json = ResourceHelper.GetFromResources("FantasyFootballRobot.Tests.TestData.SampleDefenderJson.txt");
            var jsonPlayer = new JsonPlayer(json);

            //Act
            var player = Mapper.Map<JsonPlayer, Player>(jsonPlayer);

            //Assert
            Assert.That(player.PastSeasons.Count, Is.EqualTo(5));
            Assert.That(player.PastSeasons.Last().SeasonEndYear, Is.EqualTo(2011));
            Assert.That(player.PastSeasons.Last().MinutesPlayed, Is.EqualTo(2961));
            Assert.That(player.PastSeasons.Last().PlayerValueAtTime, Is.EqualTo(74));
            Assert.That(player.PastSeasons.Last().TotalPointsScored, Is.EqualTo(134));
        }
 static Player HydratePlayerFromJson(string json)
 {
     var jsonPlayer = new JsonPlayer(json);
     return AutoMapper.Mapper.Map<JsonPlayer, Player>(jsonPlayer);
 }