コード例 #1
0
        public async void AddTempHP_InvalidArguments_FailingTest()
        {
            CharacterHealthService characterHealthService = InitilizeEnvironment();
            Exception ex = await Assert.ThrowsAsync <ArgumentException>(() => characterHealthService.AddTempHPToCharacter("", 5));

            Assert.Equal("Invalid arguments", ex.Message);
        }
コード例 #2
0
        public async void AddTempHP_InvalidCharacter_FailingTest()
        {
            CharacterHealthService characterHealthService = InitilizeEnvironment();
            Exception ex = await Assert.ThrowsAsync <KeyNotFoundException>(() => characterHealthService.AddTempHPToCharacter("TEST", 5));

            Assert.Equal("Character not found for identifier", ex.Message);
        }
コード例 #3
0
        public async void AddTempHP_PassingTest()
        {
            CharacterHealthService characterHealthService = InitilizeEnvironment();
            Character character = await characterHealthService.AddTempHPToCharacter("Briv", 5);

            Assert.True(character.HP.Total == character.HP.Max + 5); //no damage done to character yet, should be max
        }
コード例 #4
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);
        }