Exemplo n.º 1
0
            public void GivenCharacterAndBagNoLimit_ThenReturnActionResult()
            {
                // arrange
                var input = new ActionInput()
                {
                    AttributesUsed = new List <AttributeType>()
                    {
                        AttributeType.Reaction, AttributeType.Intuition
                    },
                    SkillsUsed = new List <SkillType>()
                    {
                        SkillType.UnarmedCombat
                    }
                };
                var       actual            = new Action(input);
                var       mockBag           = new Mock <IDiceBag>(MockBehavior.Strict);
                var       mockAttributePool = new Mock <IAttributePool>(MockBehavior.Strict);
                var       mockSkillPool     = new Mock <ISkillPool>(MockBehavior.Strict);
                var       mockSource        = new Mock <ICharacter>(MockBehavior.Strict);
                const int reaction          = 7;
                const int intuition         = 5;
                const int unarmedCombat     = 1;
                var       diceResults       = new List <int>()
                {
                    1, 2, 3, 4, 5, 6, 1, 2, 3, 4, 5, 6, 6
                };

                mockBag.Setup(x => x.d6(reaction + intuition + unarmedCombat))
                .Returns(diceResults);

                mockAttributePool.Setup(x => x[AttributeType.Reaction])
                .Returns(reaction);
                mockAttributePool.Setup(x => x[AttributeType.Intuition])
                .Returns(intuition);
                mockAttributePool.Setup(x => x.Display(AttributeType.Reaction))
                .Returns("one");
                mockAttributePool.Setup(x => x.Display(AttributeType.Intuition))
                .Returns("two");

                mockSkillPool.Setup(x => x[SkillType.UnarmedCombat])
                .Returns(unarmedCombat);
                mockSkillPool.Setup(x => x.Display(SkillType.UnarmedCombat))
                .Returns("three");

                mockSource.Setup(x => x.Attributes)
                .Returns(mockAttributePool.Object);
                mockSource.Setup(x => x.Skills)
                .Returns(mockSkillPool.Object);

                // act
                var results = actual.Do(mockBag.Object, mockSource.Object);

                // assert
                Assert.IsNotNull(results);
                Assert.AreEqual("one + two + three", results.RollNotation); // todo: threshold
                Assert.AreEqual(5, results.DiceResults.Hits);
            }
Exemplo n.º 2
0
            public void GivenNullCharacter_ThenThrowArgumentNullException()
            {
                // arrange
                var actual = new Action(new ActionInput());

                // act
                var results = actual.Do(new DiceBag(), null);

                // assert
                Assert.Fail("ArgumentNullException should have been thrown.");
            }