private static State CreateNewPlayerScenario() { var settingsClient = A.Fake <IGlobalSettingsClient>(); A.CallTo(() => settingsClient.GetGlobalSettings()).Returns(new GlobalSettings { Teams = new List <Team> { TestBuilder.HomeTeam(), TestBuilder.AwayTeam() }, Players = new List <Player> { TestBuilder.Player().WithStatus(PlayerStatuses.Available) } } ).Once().Then.Returns(new GlobalSettings { Teams = new List <Team> { TestBuilder.HomeTeam(), TestBuilder.AwayTeam() }, Players = new List <Player> { TestBuilder.Player().WithStatus(PlayerStatuses.Available), TestBuilder.OtherPlayer().WithStatus(PlayerStatuses.Available) } }); var fixtureClient = A.Fake <IFixtureClient>(); return(CreateBaseScenario(fixtureClient, settingsClient)); }
private static State CreatePriceIncreaseScenario() { 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() } } ).Once().Then.Returns(new GlobalSettings { Teams = new List <Team> { TestBuilder.HomeTeam(), TestBuilder.AwayTeam() }, Players = new List <Player> { TestBuilder.Player().WithCostChangeEvent(1) } }); var fixtureClient = A.Fake <IFixtureClient>(); return(CreateBaseScenario(fixtureClient, playerClient)); }
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)); }
private static State CreateChangeInDoubtfulnessScenario() { var settingsClient = A.Fake <IGlobalSettingsClient>(); A.CallTo(() => settingsClient.GetGlobalSettings()).Returns(new GlobalSettings { Teams = new List <Team> { TestBuilder.HomeTeam(), TestBuilder.AwayTeam() }, Players = new List <Player> { TestBuilder.Player().WithStatus(PlayerStatuses.Doubtful).WithNews("Knock - 75% chance of playing"), } } ).Once().Then.Returns(new GlobalSettings { Teams = new List <Team> { TestBuilder.HomeTeam(), TestBuilder.AwayTeam() }, Players = new List <Player> { TestBuilder.Player().WithStatus(PlayerStatuses.Doubtful).WithNews("Knock - 25% chance of playing") } }); var fixtureClient = A.Fake <IFixtureClient>(); return(CreateBaseScenario(fixtureClient, settingsClient)); }
private LineupState CreateFixture2RemovedScenario() { var fixtureClient = A.Fake <IFixtureClient>(); A.CallTo(() => fixtureClient.GetFixturesByGameweek(1)).Returns(new List <Fixture> { TestBuilder.NoGoals(1), TestBuilder.NoGoals(2) }).Once().Then.Returns(new List <Fixture>() { TestBuilder.NoGoals(1) }); var scraperFake = A.Fake <IGetMatchDetails>(); _session = new TestableMessageSession(); var globalSettingsClient = A.Fake <IGlobalSettingsClient>(); A.CallTo(() => globalSettingsClient.GetGlobalSettings()).Returns(new GlobalSettings { Teams = new List <Team> { TestBuilder.HomeTeam(), TestBuilder.AwayTeam() }, Players = new List <Player> { TestBuilder.Player().WithStatus(PlayerStatuses.Available) } } ); return(new LineupState(fixtureClient, scraperFake, globalSettingsClient, _session, A.Fake <ILogger <LineupState> >())); }
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) } } } ) }); }
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) } }, } ) }); }
private FinishedFixture GetProvisionalFinishedFixture(params BonusPointsPlayer[] bonusPointsPlayers) { return(new FinishedFixture { Fixture = TestBuilder.AwayTeamGoal(1, 1), HomeTeam = TestBuilder.HomeTeam(), AwayTeam = TestBuilder.AwayTeam(), BonusPoints = bonusPointsPlayers } ); }
public void GetChangedPlayers_WhenSamePlayersWithChangeInPriceRemoved_ReturnsNoChanges() { var before = new List <Player> { TestBuilder.Player().WithCostChangeEvent(1) }; var after = new List <Player> { TestBuilder.Player().WithCostChangeEvent(0) }; var priceChanges = PlayerChangesEventsExtractor.GetPriceChanges(after, before, new List <Team> { TestBuilder.HomeTeam(), TestBuilder.AwayTeam() }); Assert.Single(priceChanges); }
public void GetChangedPlayers_OneNewPlayerWithCostChange_ReturnsNewPlayer() { var before = new List <Player> { TestBuilder.Player().WithCostChangeEvent(1) }; var after = new List <Player> { TestBuilder.Player().WithCostChangeEvent(1), TestBuilder.OtherPlayer().WithCostChangeEvent(1) }; var priceChanges = PlayerChangesEventsExtractor.GetPriceChanges(after, before, new List <Team> { TestBuilder.HomeTeam(), TestBuilder.AwayTeam() }); Assert.Empty(priceChanges); }
public void GetChangedPlayers_WhenSamePlayersDuplicateWithChangeInPriceChange_ReturnsSingleChanges() { var before = new List <Player> { TestBuilder.Player().WithCostChangeEvent(0) }; var after = new List <Player> { TestBuilder.Player().WithCostChangeEvent(1), TestBuilder.Player().WithCostChangeEvent(1) }; var priceChanges = PlayerChangesEventsExtractor.GetPriceChanges(after, before, new List <Team> { TestBuilder.HomeTeam(), TestBuilder.AwayTeam() }); Assert.Single(priceChanges); Assert.Equal(TestBuilder.Player().WebName, priceChanges.First().WebName); var before2 = new List <Player> { TestBuilder.Player().WithCostChangeEvent(0), TestBuilder.Player().WithCostChangeEvent(0) }; var after2 = new List <Player> { TestBuilder.Player().WithCostChangeEvent(1), TestBuilder.Player().WithCostChangeEvent(1) }; var priceChanges2 = PlayerChangesEventsExtractor.GetPriceChanges(after2, before2, new List <Team> { TestBuilder.HomeTeam(), TestBuilder.AwayTeam() }); Assert.Single(priceChanges2); Assert.Equal(TestBuilder.Player().WebName, priceChanges2.First().WebName); var before3 = new List <Player> { TestBuilder.Player().WithCostChangeEvent(0), TestBuilder.Player().WithCostChangeEvent(0) }; var after3 = new List <Player> { TestBuilder.Player().WithCostChangeEvent(1) }; var priceChanges3 = PlayerChangesEventsExtractor.GetPriceChanges(after3, before3, new List <Team> { TestBuilder.HomeTeam(), TestBuilder.AwayTeam() }); Assert.Single(priceChanges3); Assert.Equal(TestBuilder.Player().WebName, priceChanges3.First().WebName); }
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); }
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)); }