Пример #1
0
        public void CreatePerson_TypeStaff_ReturnsStaffMember()
        {
            var person = PersonStrategyFactory <Staff> .CreatePerson(ePerson.Staff, 100, SpecificStaffFunction.ManagerFunctions.HeadManager);

            Assert.IsNotNull(person);
            Assert.IsTrue(typeof(Staff) == person.GetType());
        }
Пример #2
0
        public void CreatePerson_TypePlayer_ReturnsPlayer()
        {
            var person = PersonStrategyFactory <Player> .CreatePerson(ePerson.Player, 100, Position.Goaly);

            Assert.IsNotNull(person);
            Assert.IsTrue(typeof(Player) == person.GetType());
        }
Пример #3
0
        public void SetPlayerPersonalSettings_ReturnsPlayerWithPersonalSettings()
        {
            var player = new Player();

            PersonStrategyFactory <Player> .SetPersonalInformation(ePerson.Player, player);

            Assert.IsNotNull(player.FirstName);
            Assert.IsNotNull(player.LastName);
            Assert.IsNotNull(player.BirthDate);
            Assert.IsTrue(player.BirthDate < DateTime.Now.Date);
        }
Пример #4
0
        public void CreatePlayer_ReturnsPlayerWithPositionsAndAttributes(int mainPosition)
        {
            var player = PersonStrategyFactory <Player> .CreatePerson(ePerson.Player, RandomUtil.GetRandomInt(5, 25), mainPosition);

            Assert.IsNotNull(player);
            Assert.IsNotNull(player.MainFunction);
            Assert.IsNotEmpty(player.Positions);
            Assert.GreaterOrEqual(player.Positions.Count, 1);
            Assert.IsNotEmpty(player.PersonAttributes);
            Assert.AreEqual(28, player.PersonAttributes.Count);
        }
        protected internal static List <TEntity> CreateAllPersonsInAssembly(Dictionary <int, int> assembly, int totalRating, ePerson personType)
        {
            var persons = new List <TEntity>();

            foreach (var person in assembly)
            {
                for (int i = 0; i < person.Value; i++)
                {
                    persons.Add(PersonStrategyFactory <TEntity> .CreatePerson(personType, totalRating, person.Key));
                }
            }

            return(persons);
        }
Пример #6
0
        public void SetPlayerPositionsByMainPosition_SetsPlayerPositionsByMainPosition(int mainPosition)
        {
            var player = new Player {
                MainFunction = mainPosition
            };

            PersonStrategyFactory <Player> .SetPersonAttributes(ePerson.Player, player);

            Assert.IsNotEmpty(player.Positions);
            Assert.GreaterOrEqual(player.Positions.Count, 1);
            switch (mainPosition)
            {
            case Position.Goaly:
                Assert.AreEqual(1, player.Positions.Count);
                Assert.IsTrue(player.Positions.Contains(PlayerPosition.Goaly));
                break;

            case Position.Defence:
                Assert.IsTrue(player.Positions.Contains(PlayerPosition.DefensivePositions.CenterBack) ||
                              player.Positions.Contains(PlayerPosition.DefensivePositions.DefensiveMidfield) ||
                              player.Positions.Contains(PlayerPosition.DefensivePositions.RightBack) ||
                              player.Positions.Contains(PlayerPosition.DefensivePositions.LeftBack));
                break;

            case Position.Midfield:
                Assert.IsTrue(player.Positions.Contains(PlayerPosition.MidfieldPositions.CenterMidfield) ||
                              player.Positions.Contains(PlayerPosition.MidfieldPositions.DefensiveMidfield) ||
                              player.Positions.Contains(PlayerPosition.MidfieldPositions.AttackingMidfield) ||
                              player.Positions.Contains(PlayerPosition.MidfieldPositions.LeftMidfield) ||
                              player.Positions.Contains(PlayerPosition.MidfieldPositions.RightMidfield));
                break;

            default:
                Assert.IsTrue(player.Positions.Contains(PlayerPosition.ForwardPositions.Forward) ||
                              player.Positions.Contains(PlayerPosition.ForwardPositions.AttackingMidfield));
                break;
            }
        }
Пример #7
0
 public void CreatePerson_WrongPersonType_ThrowsException()
 {
     Assert.Throws <InvalidCastException>(() => PersonStrategyFactory <Staff> .CreatePerson(ePerson.Player, 100, Position.Goaly));
 }