Beispiel #1
0
        public void DamageController_LayersParseSuccessfully()
        {
            // Test Values
            const string entityId = "TestEntity";
            Dictionary <string, decimal> testDamageData = new Dictionary <string, decimal>()
            {
                { "BaseHealth", 100 },
                { "Fire", 100 },
                { "Ice", 100 }
            };

            // Setup the test controller.
            DamageController <DamageUnitTest> testController = new DamageController <DamageUnitTest>();

            testController.AddLayer(entityId, "Fire", 300, (decimal)0.5, null);
            testController.AddLayer(entityId, "Ice", 100, 2, null);

            // Execute the calcluations, and compare to expected.
            var dmgResult = testController.CalculateLayerEffects(entityId, ref testDamageData);

            Assert.AreEqual(2, dmgResult);
            Assert.AreEqual(50, testDamageData["Fire"]);
            Assert.AreEqual(200, testDamageData["Ice"]);

            // Make sure the manager was updated correctly, as the manager controls this.
            var entityLayers = testController.DamageManager.GetLayersForEntity(entityId);

            Assert.AreEqual(1, entityLayers.Length);
            Assert.AreEqual(200, entityLayers[0].DamageCap);
            Assert.AreEqual("Fire", entityLayers[0].DamageType);
        }