Esempio n. 1
0
    private List <FixtureEvents> CreateGoalEvent(bool removed = false)
    {
        var fixture = TestBuilder.AwayTeamGoal(1, 1);

        return(new List <FixtureEvents>
        {
            new FixtureEvents
            (
                new FixtureScore
                (
                    new FixtureTeam(fixture.HomeTeamId, TestBuilder.HomeTeam().Name, TestBuilder.HomeTeam().ShortName),
                    new FixtureTeam(fixture.AwayTeamId, TestBuilder.AwayTeam().Name, TestBuilder.AwayTeam().ShortName),
                    66,
                    1,
                    0
                ),
                new Dictionary <StatType, List <PlayerEvent> >
            {
                { StatType.GoalsScored, new List <PlayerEvent> {
                      new PlayerEvent(TestBuilder.PlayerDetails(), TeamType.Home, IsRemoved: removed)
                  } }
            }
            )
        });
    }
Esempio n. 2
0
    private static State CreateGoalScoredScenario()
    {
        var playerClient = A.Fake <IGlobalSettingsClient>();

        A.CallTo(() => playerClient.GetGlobalSettings()).Returns(
            new GlobalSettings
        {
            Teams = new List <Team>
            {
                TestBuilder.HomeTeam(),
                TestBuilder.AwayTeam()
            },
            Players = new List <Player>
            {
                TestBuilder.Player()
            }
        });

        var fixtureClient = A.Fake <IFixtureClient>();

        A.CallTo(() => fixtureClient.GetFixturesByGameweek(1)).Returns(new List <Fixture>
        {
            TestBuilder.AwayTeamGoal(888, 1)
        }).Once()
        .Then.Returns(
            new List <Fixture>
        {
            TestBuilder.AwayTeamGoal(888, 2)
        });

        return(CreateBaseScenario(fixtureClient, playerClient));
    }
Esempio n. 3
0
    private List <FixtureEvents> CreateIrrelevantEvents()
    {
        var fixture = TestBuilder.AwayTeamGoal(1, 1);

        return(new List <FixtureEvents>
        {
            new FixtureEvents
            (
                new FixtureScore
                (
                    new FixtureTeam(fixture.HomeTeamId, TestBuilder.HomeTeam().Name, TestBuilder.HomeTeam().ShortName),
                    new FixtureTeam(fixture.AwayTeamId, TestBuilder.AwayTeam().Name, TestBuilder.AwayTeam().ShortName),
                    85,
                    1,
                    0
                ),
                new Dictionary <StatType, List <PlayerEvent> >
            {
                { StatType.YellowCards, new List <PlayerEvent> {
                      new PlayerEvent(TestBuilder.PlayerDetails(), TeamType.Home, IsRemoved: false)
                  } },
                { StatType.Bonus, new List <PlayerEvent> {
                      new PlayerEvent(TestBuilder.PlayerDetails(), TeamType.Home, IsRemoved: false)
                  } },
                { StatType.Saves, new List <PlayerEvent> {
                      new PlayerEvent(TestBuilder.PlayerDetails(), TeamType.Home, IsRemoved: false)
                  } },
                { StatType.GoalsScored, new List <PlayerEvent> {
                      new PlayerEvent(TestBuilder.PlayerDetails(), TeamType.Home, IsRemoved: false)
                  } },
            }
            )
        });
    }
Esempio n. 4
0
 private FinishedFixture GetProvisionalFinishedFixture(params BonusPointsPlayer[] bonusPointsPlayers)
 {
     return(new FinishedFixture
     {
         Fixture = TestBuilder.AwayTeamGoal(1, 1),
         HomeTeam = TestBuilder.HomeTeam(),
         AwayTeam = TestBuilder.AwayTeam(),
         BonusPoints = bonusPointsPlayers
     }
            );
 }
Esempio n. 5
0
    public void NewFixtureWithAdditionalStats_NewEvent()
    {
        var fixture         = TestBuilder.NoGoals(fixtureCode: 10);
        var fixtureWithGoal = TestBuilder.AwayTeamGoal(fixtureCode: 10, goals: 1);
        var events          = FixtureDiffer.DiffFixtureStats(newFixture: fixtureWithGoal, fixture, new List <Player> {
            TestBuilder.Player()
        });

        Assert.NotEmpty(events);
        Assert.Single(events);
        Assert.Equal(StatType.GoalsScored, events.First().Key);
        Assert.Equal(TestBuilder.PlayerId, events.First().Value.First().Player.Id);
    }
Esempio n. 6
0
    public void NewFixtureWithRemovedEvent_NewEvent_WithRemovedFlagTrue()
    {
        var fixtureWithGoal    = TestBuilder.AwayTeamGoal(fixtureCode: 10, goals: 1);
        var fixtureGoalRemoved = TestBuilder.NoGoals(fixtureCode: 10);
        var events             = FixtureDiffer.DiffFixtureStats(newFixture: fixtureGoalRemoved, fixtureWithGoal, new List <Player> {
            TestBuilder.Player()
        });

        Assert.NotEmpty(events);
        Assert.Single(events);
        Assert.Equal(StatType.GoalsScored, events.First().Key);
        var playerEvent = events.First().Value.First();

        Assert.Equal(TestBuilder.PlayerId, playerEvent.Player.Id);
        Assert.True(playerEvent.IsRemoved);
    }
    public static void When_NewAwayGoal_ReturnsAwayTeamGoalEvent()
    {
        var current = new List <Fixture>
        {
            TestBuilder.NoGoals(fixtureCode: 1)
        };

        var latest = new List <Fixture>
        {
            TestBuilder.AwayTeamGoal(fixtureCode: 1, goals: 1, minutes: 72)
        };

        var events = LiveEventsExtractor.GetUpdatedFixtureEvents(latest, current, new List <Player> {
            TestBuilder.Player()
        }, new List <Team> {
            TestBuilder.HomeTeam(), TestBuilder.AwayTeam()
        });
        var awayGoalEvent = events.First();

        Assert.Equal(123, awayGoalEvent.StatMap[StatType.GoalsScored].First().Player.Id);
        Assert.Equal(TeamType.Away, awayGoalEvent.StatMap[StatType.GoalsScored].First().Team);
        Assert.Equal(72, awayGoalEvent.FixtureScore.Minutes);
    }
Esempio n. 8
0
    private static State CreateSingleFinishedFixturesScenario()
    {
        var playerClient = A.Fake <IGlobalSettingsClient>();

        A.CallTo(() => playerClient.GetGlobalSettings()).Returns(
            new GlobalSettings
        {
            Teams = new List <Team>
            {
                TestBuilder.HomeTeam(),
                TestBuilder.AwayTeam()
            },
            Players = new List <Player>
            {
                TestBuilder.Player(),
                TestBuilder.OtherPlayer()
            }
        });

        var fixtureClient = A.Fake <IFixtureClient>();

        A.CallTo(() => fixtureClient.GetFixturesByGameweek(1)).Returns(new List <Fixture>
        {
            TestBuilder.AwayTeamGoal(888, 1),
            TestBuilder.AwayTeamGoal(999, 1)
        }).Once()
        .Then.Returns(
            new List <Fixture>
        {
            TestBuilder.AwayTeamGoal(888, 1),
            TestBuilder.AwayTeamGoal(999, 1).FinishedProvisional()
            .WithProvisionalBonus(TestBuilder.Player().Id, 10)
            .WithProvisionalBonus(TestBuilder.OtherPlayer().Id, 20)
        });

        return(CreateBaseScenario(fixtureClient, playerClient));
    }