Exemplo n.º 1
0
        public void UseSkill_PersonSquadAttacks_Returns5EventOfAttack()
        {
            var skillUsageRandomMock = new Mock <ISkillUsageRandomSource>();

            skillUsageRandomMock.Setup(x => x.RollEfficient(It.IsAny <Roll>()))
            .Returns <Roll>(roll => roll.Dice / 2);
            skillUsageRandomMock.Setup(x => x.RollToHit(It.IsAny <Roll>()))
            .Returns <Roll>(roll => 5);
            skillUsageRandomMock.Setup(x => x.RollPersonIndex(It.IsAny <int>()))
            .Returns <int>(personCount => 0);
            var skillUsageRandom = skillUsageRandomMock.Object;

            var attackerSquadMock = new Mock <ICombatSquad>();

            AddPersonsToSquadMock(attackerSquadMock);
            var attackerSquad = attackerSquadMock.Object;

            var targetSquadMock = new Mock <ICombatSquad>();

            AddPersonsToSquadMock(targetSquadMock);
            var targetSquad = targetSquadMock.Object;

            var squadManagerMock = new Mock <IEntityManager <ICombatSquad> >();
            var squadManager     = squadManagerMock.Object;

            var combatService = new CombatService(squadManager, skillUsageRandom);



            // ACT
            var combatEvents = combatService.UseSkill(attackerSquad, targetSquad).ToArray();



            // ASSERT
            combatEvents.Should().HaveCount(5);
            foreach (var combatEvent in combatEvents)
            {
                combatEvent.Should().BeOfType <AttackCombatEvent>();
            }
        }