public void NotEnoughReceiversOutsideTackleThrowsExceptionWithProperMessage_02()
            {
                PlacedFormation          placedFormation = NumberedSkillPlayersPlacedFormationTestData.testPlacedFormations[3];
                PlacedFormationException ex = Assert.Throws <PlacedFormationException>(() => placedFormation.GetNumberedSkillLeft(FlowDirection.InsideOut, 5));

                Assert.Equal("Not enough skill players outside tackle.", ex.Message);
            }
            public void PassingNegativeValueThrowsExceptionWithProperMessage()
            {
                PlacedFormation          placedFormation = new PlacedFormation();
                PlacedFormationException ex = Assert.Throws <PlacedFormationException>(() => placedFormation.GetNumberedSkillStrong(FlowDirection.OutsideIn, -3));

                Assert.Equal("Can't get negative numbered skill player.", ex.Message);
            }
            static NumberedSkillPlayersPlacedFormationTestData()
            {
                testPlacedFormations    = new PlacedFormation[4];
                testPlacedFormations[0] = new PlacedFormation();
                testPlacedFormations[0].skillPlayers[0].SetLocation(20, 5);
                testPlacedFormations[0].skillPlayers[1].SetLocation(18, 10);
                testPlacedFormations[0].skillPlayers[2].SetLocation(10, 5);
                testPlacedFormations[0].skillPlayers[3].SetLocation(15, 4);
                testPlacedFormations[0].skillPlayers[4].SetLocation(-5, 5);
                testPlacedFormations[0].skillPlayers[5].SetLocation(0, 5);

                testPlacedFormations[1] = new PlacedFormation();
                testPlacedFormations[1].skillPlayers[0].SetLocation(20, 5);
                testPlacedFormations[1].skillPlayers[1].SetLocation(18, 10);
                testPlacedFormations[1].skillPlayers[2].SetLocation(15, 5);
                testPlacedFormations[1].skillPlayers[3].SetLocation(15, 4);
                testPlacedFormations[1].skillPlayers[4].SetLocation(-5, 5);
                testPlacedFormations[1].skillPlayers[5].SetLocation(0, 5);

                testPlacedFormations[2] = new PlacedFormation();
                testPlacedFormations[2].skillPlayers[0].SetLocation(20, 5);
                testPlacedFormations[2].skillPlayers[1].SetLocation(18, 10);
                testPlacedFormations[2].skillPlayers[2].SetLocation(15, 4);
                testPlacedFormations[2].skillPlayers[3].SetLocation(15, 5);
                testPlacedFormations[2].skillPlayers[4].SetLocation(-5, 5);
                testPlacedFormations[2].skillPlayers[5].SetLocation(0, 5);

                testPlacedFormations[3] = new PlacedFormation();
                testPlacedFormations[3].skillPlayers[0].SetLocation(-20, 5);
                testPlacedFormations[3].skillPlayers[1].SetLocation(10, 10);
                testPlacedFormations[3].skillPlayers[2].SetLocation(5, 4);
                testPlacedFormations[3].skillPlayers[3].SetLocation(-10, 5);
                testPlacedFormations[3].skillPlayers[4].SetLocation(-5, 5);
                testPlacedFormations[3].skillPlayers[5].SetLocation(-15, 5);
            }
            public void Passing0ThrowsExceptionWithProperMessage()
            {
                PlacedFormation          placedFormation = new PlacedFormation();
                PlacedFormationException ex = Assert.Throws <PlacedFormationException>(() => placedFormation.GetNumberedSkillWeak(FlowDirection.OutsideIn, 0));

                Assert.Equal("Can't get 0 numbered skill player.", ex.Message);
            }
            public void PassingTooLargeAValueThrowsExceptionWithProperMessage()
            {
                PlacedFormation          placedFormation = new PlacedFormation();
                PlacedFormationException ex = Assert.Throws <PlacedFormationException>(() => placedFormation.GetNumberedSkillWeak(FlowDirection.OutsideIn, 7));

                Assert.Equal("Can't get numbers skill player larger then 6. There are only 6 skill players.", ex.Message);
            }
Example #6
0
        public IPlacementRule GetPlacementRule(FormationRule formationRule, PlacedFormation placedFormation)
        {
            string relativeTypeString   = formationRule.GetParameterValue("relativeType");
            string playerRelativeString = formationRule.GetParameterValue("playerRelative");
            string distanceString       = formationRule.GetParameterValue("distance");

            RelativeType relativeType;

            switch (relativeTypeString)
            {
            case "Left":
                relativeType = RelativeType.Left;
                break;

            case "Right":
                relativeType = RelativeType.Right;
                break;

            case "Inside":
                relativeType = RelativeType.Inside;
                break;

            case "Outside":
                relativeType = RelativeType.Outside;
                break;

            default:
                throw new FormationException("Relative type must be Left/Right/Inside/Outside.");
            }
            int          distance       = int.Parse(distanceString);
            PlacedPlayer playerRelative = placedFormation.GetPlayerByTag(playerRelativeString);

            return(new RelativeToPlayerHorizontally(playerRelative, distance, relativeType));
        }
            public void GetsCorrectPlayerFromInsideOut(PlacedFormation placedFormation, int number, int expectedPlayerIndex)
            {
                PlacedPlayer expectedPlayer = placedFormation.skillPlayers[expectedPlayerIndex];

                PlacedPlayer returnedPlayer = placedFormation.GetNumberedSkillLeft(FlowDirection.InsideOut, number);
                bool         samePlayer     = ReferenceEquals(expectedPlayer, returnedPlayer);

                Assert.True(samePlayer);
            }
        public IPlacementRule GetPlacementRule(FormationRule formationRule, PlacedFormation placedFormation)
        {
            string behindTagParameter   = formationRule.GetParameterValue("playerBehindTag");
            string distanceBehindString = formationRule.GetParameterValue("distanceBehind");
            int    distanceBehind       = int.Parse(distanceBehindString);

            PlacedPlayer playerBehind = placedFormation.GetPlayerByTag(behindTagParameter);

            return(new BehindPlayer(playerBehind, distanceBehind));
        }
            public void PlacesLinemanInCorrectLocations()
            {
                FormationPlacer formationPlacer  = new FormationPlacer(fakePlacementRuleFactory);
                Location        expectedLocation = new Location(0, 0);

                PlacedFormation placedFormation    = formationPlacer.ToPlacedFormation(formation);
                bool            inExpectedLocation = placedFormation.center.location == expectedLocation;

                Assert.True(inExpectedLocation);
            }
            public void GettingPlayerWithNonexistantTagThrowsException()
            {
                PlacedFormation placedFormation = new PlacedFormation();

                placedFormation.leftTackle.tag      = "LT";
                placedFormation.skillPlayers[2].tag = "X";

                PlacedFormationException ex = Assert.Throws <PlacedFormationException>(() => placedFormation.GetPlayerByTag("Nonexistent"));

                Assert.Equal("No player in formation has tag Nonexistent", ex.Message);
            }
            public void GetsCorrectPlayerFromOutsideIn(PlacedFormation placedFormation, Direction strongDirection,
                                                       int number, int expectedPlayerIndex)
            {
                placedFormation.strongSide = strongDirection;
                PlacedPlayer expectedPlayer = placedFormation.skillPlayers[expectedPlayerIndex];

                PlacedPlayer returnedPlayer = placedFormation.GetNumberedSkillWeak(FlowDirection.OutsideIn, number);
                bool         samePlayer     = ReferenceEquals(expectedPlayer, returnedPlayer);

                Assert.True(samePlayer);
            }
            public void ReturnsLeftTackleIfStrongSideIsRight()
            {
                PlacedFormation placedFormation = new PlacedFormation();
                PlacedPlayer    expectedPlayer  = placedFormation.leftTackle;

                placedFormation.strongSide = Direction.Right;

                PlacedPlayer returnedPlayer = placedFormation.GetWeakTackle();
                bool         samePlayer     = ReferenceEquals(returnedPlayer, expectedPlayer);

                Assert.True(samePlayer);
            }
            public void ReturnsRightGuardIfStrongSideIsLeft()
            {
                PlacedFormation placedFormation = new PlacedFormation();
                PlacedPlayer    expectedPlayer  = placedFormation.rightGuard;

                placedFormation.strongSide = Direction.Left;

                PlacedPlayer returnedPlayer = placedFormation.GetWeakGuard();
                bool         samePlayer     = ReferenceEquals(returnedPlayer, expectedPlayer);

                Assert.True(samePlayer);
            }
            public void PlacesTacklesInCorrectLocation()
            {
                FormationPlacer formationPlacer             = new FormationPlacer(fakePlacementRuleFactory);
                Location        expectedLeftTackleLocation  = new Location(-8, 0);
                Location        expectedRightTackleLocation = new Location(8, 0);

                PlacedFormation placedFormation = formationPlacer.ToPlacedFormation(formation);
                bool            leftTackleInExpectedLocation  = placedFormation.leftTackle.location == expectedLeftTackleLocation;
                bool            rightTackleInExpectedLocation = placedFormation.rightTackle.location == expectedRightTackleLocation;

                Assert.True(leftTackleInExpectedLocation);
                Assert.True(rightTackleInExpectedLocation);
            }
            public void PlacesGuardsInCorrectLocation()
            {
                FormationPlacer formationPlacer            = new FormationPlacer(fakePlacementRuleFactory);
                Location        expectedLeftGuardLocation  = new Location(-4, 0);
                Location        expectedRightGuardLocation = new Location(4, 0);

                PlacedFormation placedFormation              = formationPlacer.ToPlacedFormation(formation);
                bool            leftGuardInExpectedLocation  = placedFormation.leftGuard.location == expectedLeftGuardLocation;
                bool            rightGuardInExpectedLocation = placedFormation.rightGuard.location == expectedRightGuardLocation;

                Assert.True(leftGuardInExpectedLocation);
                Assert.True(rightGuardInExpectedLocation);
            }
            public void GetsThePlayerWithTheProperTag_02()
            {
                PlacedFormation placedFormation = new PlacedFormation();

                placedFormation.leftTackle.tag      = "LT";
                placedFormation.skillPlayers[2].tag = "X";
                PlacedPlayer expectedPlayer = placedFormation.leftTackle;

                PlacedPlayer returnedPlayer = placedFormation.GetPlayerByTag("LT");
                bool         sameObject     = ReferenceEquals(expectedPlayer, returnedPlayer);

                Assert.True(sameObject);
            }
Example #17
0
            public void PassingGoodParametersInDoesntThrowException()
            {
                FormationRule formationRule = new FormationRule();

                formationRule.parameters.Add(new FormationRuleParameter("playerBehindTag", "RG"));
                formationRule.parameters.Add(new FormationRuleParameter("distanceBehind", "12"));
                BehindPlayerAdapter behindPlayerAdapter = new BehindPlayerAdapter();
                PlacedFormation     placedFormation     = new PlacedFormation();

                placedFormation.rightGuard.tag = "RG";

                behindPlayerAdapter.GetPlacementRule(formationRule, placedFormation);
            }
Example #18
0
        public void PassingGoodParametersInDoesntThrowException()
        {
            FormationRule formationRule = new FormationRule();

            formationRule.parameters.Add(new FormationRuleParameter("playerRelative", "X"));
            formationRule.parameters.Add(new FormationRuleParameter("relativeType", "Inside"));
            formationRule.parameters.Add(new FormationRuleParameter("distance", "7"));
            RelativeToPlayerHorizontallyAdapter relativePlayerAdapter = new RelativeToPlayerHorizontallyAdapter();
            PlacedFormation placedFormation = new PlacedFormation();

            placedFormation.skillPlayers[1].tag = "X";

            relativePlayerAdapter.GetPlacementRule(formationRule, placedFormation);
        }
Example #19
0
 public IPlacementRule GetPlacementRule(FormationRule formationRule, PlacedFormation placedFormation)
 {
     return(new OnLineOfScrimmage());
 }
 public IPlacementRule GetPlacementRule(FormationRule formationRule, PlacedFormation placedFormation)
 {
     return(new FakePlacementRule());
 }