コード例 #1
0
 public void Attack_EmptyCharcaterAttacks()
 {
     var human = new TestCharacters().InjuerdHuman;
     var emptyCharacter = new Character();
     Action attack = () => emptyCharacter.Attack(human);
     attack.ShouldThrow<NullReferenceException>();
 }
コード例 #2
0
        public void Attack_SelfAttack()
        {
            var human = new TestCharacters().InjuerdHuman;

            Action attack = () => human.Attack(human);
            attack.ShouldThrow<InvalidOperationException>().WithMessage("Character can not Attack it self!");
        }
コード例 #3
0
        public void Attack_NullAttack()
        {
            var human = new TestCharacters().InjuerdHuman;

            Action attack = () => human.Attack(null);
            attack.ShouldThrow<NullReferenceException>();
        }
コード例 #4
0
        public void Apply_useHeathPoitionOnWrongCharacter()
        {
            var healthPotion = new TestItems().HealthPotion;
            var wolf = new TestCharacters().Wolf;

            Assert.Throws<WrongRequirementException>(()=> healthPotion.Apply(wolf));
        }
コード例 #5
0
        public void Eqip_InvalidItem()
        {
            var human = new TestCharacters().InjuerdHuman;
            var amulet = new TestItems().ElvishAmulet;

           Assert.Throws<WrongRequirementException>(()=> human.Eqip(amulet));           
        }
コード例 #6
0
        public void Defend_HumanDefends(int attackPoints, int expectedLifePoint)
        {
            var human = new TestCharacters().InjuerdHuman;

            human.Defend(attackPoints);
            human.CurrentFluentAttributes.LifePoints.Should().Be(expectedLifePoint);
        }
コード例 #7
0
        public void Eqip_Amulet()
        {
            var elve = new TestCharacters().Elve;
            var amulet = new TestItems().ElvishAmulet;

            elve.Eqip(amulet);
            elve.Eqipped.Should().BeEquivalentTo(new List<StaticItem> { amulet });
        }
コード例 #8
0
        public void Consume_AItemThatTheCharDoesnotHave()
        {
            var human = new TestCharacters().InjuerdHuman;
            var healthPotion = new TestItems().HealthPotion;

            var ex = Assert.Throws<InvalidOperationException>(() => human.Consume(healthPotion));
            ex.Message.Should().Be($"The Character ({human.Name}) has not this Item: {healthPotion.Name}");            
        }
コード例 #9
0
        public void Apply_useHeathPoition()
        {
            var healthPotion = new TestItems().HealthPotion;
            var injuerdHuman = new TestCharacters().InjuerdHuman;
            healthPotion.Apply(injuerdHuman);

            injuerdHuman.CurrentFluentAttributes.LifePoints.Should().Be(11);
        }
        public void GetModifiedFluentAttributes_NothingEquipped()
        {
            var human = new TestCharacters().InjuerdHuman;

            var testData = human.GetModifiedFluentAttributes();

            testData.LifePoints.Should().Be(15);
        }
コード例 #11
0
        public void Eqip_Sword()
        {
            var human = new TestCharacters().InjuerdHuman;
            var sword = new TestItems().Sword;

            human.Eqip(sword);
            human.Eqipped.Should().BeEquivalentTo(new List<StaticItem> { sword });
        }
コード例 #12
0
        public void Eqip_ToMuch()
        {
            var human = new TestCharacters().InjuerdHuman;
            var sword = new TestItems().Sword;

            human.Eqip(sword);
            human.Eqip(sword);
            Assert.Throws<WrongRequirementException>(() => human.Eqip(sword));
        }
コード例 #13
0
        public void Apply_useHeathPoitionOnHealthyCharcater()
        {
            var healthPotion = new TestItems().HealthPotion;
            var elve = new TestCharacters().Elve;

            healthPotion.Apply(elve);

            elve.CurrentFluentAttributes.LifePoints.Should().Be(13);
        }
コード例 #14
0
        public void GetModifiedAttributes_NothingEquipped()
        {
            var human = new TestCharacters().InjuerdHuman;

            var testData = human.GetModifiedAttributes();

            testData.AttackPoints.Should().Be(5);
            testData.DefendPoints.Should().Be(5);
        }
コード例 #15
0
        public void Attack_Human_Attacks_Elve()
        {
            var human = new TestCharacters().InjuerdHuman;
            var elve = new TestCharacters().Elve;

            human.Attack(elve);

            elve.CurrentFluentAttributes.LifePoints.Should().BeLessOrEqualTo(11)
                .And.BeGreaterOrEqualTo(6);
        }
コード例 #16
0
        public void Consume_AExistingItem()
        {
            var human = new TestCharacters().InjuerdHuman;
            

            human.Consume(human.Inventory.Single() as ConsumableItem);

            human.Inventory.Should().BeEmpty();
            human.CurrentFluentAttributes.LifePoints.Should().Be(11);
        }
        public void GetModifiedFluentAttributes_AmuelettEquipped()
        {
            var human = new TestCharacters().InjuerdHuman;
            var amulett = new TestItems().AmuletOfLife;
            human.Eqip(amulett);

            var testData = human.GetModifiedFluentAttributes();

            testData.LifePoints.Should().Be(20);
        }
コード例 #18
0
        public void Eqip_twice()
        {
            var elve = new TestCharacters().Elve;
            
            var sword = new TestItems().Sword;

            elve.Eqip(sword);
            elve.Eqip(sword);
            elve.Eqipped.Should().BeEquivalentTo(new List<StaticItem> { sword, sword});
        }
コード例 #19
0
        public void Attack_EqiuppedElve_Attacks_Human()
        {
            var human = new TestCharacters().InjuerdHuman;
            var elve = new TestCharacters().Elve;
            var sword = new TestItems().Sword;
            elve.Eqip(sword);
            elve.Attack(human);

            human.CurrentFluentAttributes.LifePoints.Should().BeLessOrEqualTo(0)
                .And.BeGreaterOrEqualTo(-5);
        }
コード例 #20
0
        public void GetModifiedAttributes_SwordEquipped()
        {
            var human = new TestCharacters().InjuerdHuman;
            var sword = new TestItems().Sword;
            human.Eqip(sword);

            var testData = human.GetModifiedAttributes();

            testData.AttackPoints.Should().Be(8);
            testData.DefendPoints.Should().Be(5);
        }
コード例 #21
0
        public void Apply_useHeathPoitionOnEqipedCharcater()
        {
            var healthPotion = new TestItems().HealthPotion;
            var elve = new TestCharacters().Elve;
            var amuelet = new TestItems().ElvishAmulet;
            
            elve.Eqip(amuelet);

            healthPotion.Apply(elve);
            elve.CurrentFluentAttributes.LifePoints.Should().Be(18);
        }
コード例 #22
0
        public void Eqip_Several()
        {
            var elve = new TestCharacters().Elve;
            var amulet = new TestItems().ElvishAmulet;
            var sword = new TestItems().Sword;
            var axe = new TestItems().Axe;

            elve.Eqip(sword);
            elve.Eqip(axe);
            elve.Eqip(amulet);
            elve.Eqipped.Should().BeEquivalentTo(new List<StaticItem> { amulet, sword, axe });
        }
        public void GetModifiedFluentAttributes_SeveralEquipped()
        {
            var human = new TestCharacters().InjuerdHuman;
            var amuletOfLife = new TestItems().AmuletOfLife;
            var amulettOfDead = new TestItems().AmuletOfDead;
            human.Eqip(amuletOfLife);
            human.Eqip(amulettOfDead);

            var testData = human.GetModifiedFluentAttributes();

            testData.LifePoints.Should().Be(13);
        }
コード例 #24
0
        public void GetModifiedAttributes_SeveralEquipped()
        {
            var human = new TestCharacters().InjuerdHuman;
            var sword = new TestItems().Sword;
            var axe = new TestItems().Axe;
            human.Eqip(sword);
            human.Eqip(axe);

            var testData = human.GetModifiedAttributes();

            testData.AttackPoints.Should().Be(11);
            testData.DefendPoints.Should().Be(4);
        }
コード例 #25
0
 public void Apply_useHeathPoitionDependsOnModifiedFluidAttributes()
 {
     var healthPotion = new TestItems().HealthPotion;
     var elve = Substitute.For<Character>();
     var baseElve = new TestCharacters().Elve;
     elve.BaseFluentAttributes = baseElve.BaseFluentAttributes;
     elve.CurrentFluentAttributes = baseElve.CurrentFluentAttributes;
     elve.Features = baseElve.Features;
     elve.GetModifiedFluentAttributes().Returns(new CharacterFluentAttributes { LifePoints = 20 });
     
     healthPotion.Apply(elve);
     elve.CurrentFluentAttributes.LifePoints.Should().Be(19);
 }