예제 #1
0
        public async void DamageCharacter_InvalidCharacter_FailingTest()
        {
            CharacterHealthService characterHealthService = InitilizeEnvironment();
            Exception ex = await Assert.ThrowsAsync <KeyNotFoundException>(() => characterHealthService.DamageCharacter("TEST", new CharacterDamage[1]));

            Assert.Equal("Character not found for identifier", ex.Message);
        }
예제 #2
0
        public async void DamageCharacter_InvalidArguments_FailingTest()
        {
            CharacterHealthService characterHealthService = InitilizeEnvironment();
            Exception ex = await Assert.ThrowsAsync <ArgumentException>(() => characterHealthService.DamageCharacter("", new CharacterDamage[1]));

            Assert.Equal("Invalid arguments", ex.Message);
        }
예제 #3
0
        public async void DamageCharacter_PassingTest()
        {
            CharacterHealthService characterHealthService = InitilizeEnvironment();
            Character character = await characterHealthService.AddTempHPToCharacter("Briv", 5);

            CharacterDamage[] characterDamages = new CharacterDamage[1];
            characterDamages[0] = new CharacterDamage()
            {
                Amount = 4,
                Type   = "piercing"
            };
            //testing that the health correctly removes from temp before it removes from current health
            character = await characterHealthService.DamageCharacter("Briv", characterDamages);

            Assert.True(character.HP.Total == character.HP.Max + 1);
            character = await characterHealthService.DamageCharacter("Briv", characterDamages);

            Assert.True(character.HP.Total == character.HP.Max - 3);
            await characterHealthService.HealCharacter("Briv", 3); //bring back to full for next part

            characterDamages = new CharacterDamage[4];
            //testing damage that includes a resistance, immunity, and normal. we've tested normal already above. This also tests that a null record should be skipped correct, the 4th index is not initilized
            characterDamages[0] = new CharacterDamage()
            {
                Amount = 10,
                Type   = "fire"
            };
            characterDamages[1] = new CharacterDamage()
            {
                Amount = 5,
                Type   = "slashing"
            };
            characterDamages[2] = new CharacterDamage()
            {
                Amount = 2,
                Type   = "psychic"
            };
            character = await characterHealthService.DamageCharacter("Briv", characterDamages); //This should deal 4 damage total because the fire is restited

            Assert.True(character.HP.Total == character.HP.Max - 4);
        }
예제 #4
0
        public async void HealCharacter_PassingTest()
        {
            CharacterHealthService characterHealthService = InitilizeEnvironment();
            Character character = await characterHealthService.HealCharacter("Briv", 5);

            Assert.True(character.HP.Current == character.HP.Max); //no damage done to character yet, should be max
            CharacterDamage[] characterDamages = new CharacterDamage[1];
            characterDamages[0] = new CharacterDamage()
            {
                Amount = 10,
                Type   = "piercing"
            };
            await characterHealthService.DamageCharacter("Briv", characterDamages);

            character = await characterHealthService.HealCharacter("Briv", 5);

            Assert.True(character.HP.Current == character.HP.Max - 5);
        }