Ejemplo n.º 1
0
        public void Substitution_PlayersAreSwapped(int minute)
        {
            //Arrange
            StubMatch.KickOff = DateTime.Now.AddMinutes(-minute); //Skip to minute

            //Act
            StubMatch.Substitute(StubHomePlayer.Id, StubHomeSub.Id, StubMatch.HomeTeam.UserId);
            SimulateStubMatch();

            //Assert
            Assert.DoesNotContain(StubHomeSquad.Lineup.SelectMany(x => x.Value), x => x.Id == StubHomePlayer.Id);
            Assert.DoesNotContain(StubHomeSquad.Subs, x => x.Id == StubHomeSub.Id);
            Assert.Contains(StubHomeSquad.Lineup.SelectMany(x => x.Value), x => x.Id == StubHomeSub.Id);
            Assert.Contains(StubHomeSquad.Subs, x => x.Id == StubHomePlayer.Id);
        }
Ejemplo n.º 2
0
        public void Substitutions_OnSameMinute_AllOccur(int minute)
        {
            //Arrange
            StubMatch.KickOff = DateTime.Now.AddMinutes(-minute);

            //Act
            StubMatch.Substitute(StubHomePlayer.Id, StubHomeSub.Id, StubMatch.HomeTeam.UserId);
            SimulateStubMatch();

            StubMatch.Substitute(StubAwayPlayer.Id, StubAwaySub.Id, StubMatch.AwayTeam.UserId);
            SimulateStubMatch();

            //Assert
            Assert.Contains(StubMatch.Minutes[minute].Events, x => x.SquadId == StubMatch.HomeTeam.Squad.Id && x.CardId == StubHomeSub.Id && x is Substitution);
            Assert.Contains(StubMatch.Minutes[minute].Events, x => x.SquadId == StubMatch.AwayTeam.Squad.Id && x.CardId == StubAwaySub.Id && x is Substitution);
        }
Ejemplo n.º 3
0
        public void AsOfNow_UpUntilCurrentMinute_IncludesEventsAndStatistics()
        {
            //Arrange
            StubMatch.KickOff = DateTime.Now.AddMinutes(-15);
            var stubEvent = new ShotOnTarget(11, StubHomePlayer.Id, StubMatch.HomeTeam.Squad.Id);

            StubMatch.Events.Add(stubEvent);
            var stubStatistic = new MinuteStats(11, StubHomeSquad.Id, 0, 0);

            StubMatch.Statistics.Add(stubStatistic);

            //Act
            StubMatch.AsAtElapsed();

            //Assert
            Assert.Contains(StubMatch.Events, x => x == stubEvent);
            Assert.Contains(StubMatch.Statistics, x => x == stubStatistic);
        }
Ejemplo n.º 4
0
        public void AsOfNow_OnOrAfterCurrentMinute_ExcludesEventsAndStatistics()
        {
            //Arrange
            StubMatch.KickOff = DateTime.Now.AddMinutes(-10);
            var stubEvent = new ShotOnTarget(StubHomePlayer.Id, StubMatch.HomeTeam.Squad.Id);

            StubMatch.Minutes[11].Events.Add(stubEvent);
            var stubStatistic = new MinuteStats(StubHomeSquad.Id, 0, 0);

            StubMatch.Minutes[11].Stats = stubStatistic;

            //Act
            StubMatch.AsAtElapsed();

            //Assert
            Assert.DoesNotContain(StubMatch.Minutes[11].Events, x => x == stubEvent);
            Assert.NotEqual(StubMatch.Minutes[11].Stats, stubStatistic);
        }
Ejemplo n.º 5
0
        public void Substitution_OnSameMinuteAsAnotherEvent_SubstitutionComesLast(int minute)
        {
            //Arrange
            StubMatch.KickOff = DateTime.Now.AddMinutes(-minute);
            StubMatch.Minutes[minute].Events.Add(new ShotOnTarget(StubHomePlayer.Id, StubMatch.HomeTeam.Squad.Id));

            //Act
            StubMatch.Substitute(StubHomePlayer.Id, StubHomeSub.Id, StubMatch.HomeTeam.UserId);
            SimulateStubMatch();

            //Assert
            var shotEvent      = StubMatch.Minutes[minute].Events.FirstOrDefault(x => x.CardId == StubHomePlayer.Id && x is ShotOnTarget);
            var subEvent       = StubMatch.Minutes[minute].Events.FirstOrDefault(x => x.CardId == StubHomeSub.Id && x is Substitution);
            var shotEventIndex = StubMatch.Minutes[minute].Events.IndexOf(shotEvent);
            var subEventIndex  = StubMatch.Minutes[minute].Events.IndexOf(subEvent);

            Assert.True(subEventIndex > shotEventIndex);
        }
Ejemplo n.º 6
0
        public void AsOfNow_BeforeCurrentMinute_IncludesModifiers()
        {
            //Arrange
            StubMatch.KickOff = DateTime.Now.AddMinutes(-10);
            var stubModifier = new Modifier()
            {
                CardId     = Guid.NewGuid(),
                Type       = ModifierType.Fitness,
                DrainValue = 1
            };

            StubMatch.Minutes[8].Modifiers = new[] { stubModifier };

            //Act
            StubMatch.AsAtElapsed();

            //Assert
            Assert.Equal(StubMatch.Minutes[8].Modifiers[0], stubModifier);
        }
Ejemplo n.º 7
0
        public void GetTeam_ReturnsCorrectTeam()
        {
            var teamDetails = StubMatch.GetTeam(StubHomeUserId);

            Assert.Equal(StubHomeTeamDetails, teamDetails);
        }
Ejemplo n.º 8
0
        public void GetOppositionSquad_ReturnsCorrectSquad()
        {
            var awaySquad = StubMatch.GetOppositionSquad(StubHomeSquad.Id);

            Assert.Equal(StubAwaySquad, awaySquad);
        }
Ejemplo n.º 9
0
        public void GetSquad_ReturnsCorrectSquad()
        {
            var homeSquad = StubMatch.GetSquad(StubHomeSquad.Id);

            Assert.Equal(StubHomeSquad, homeSquad);
        }