コード例 #1
0
        public void Model_Monster_Monster_From_BaseMonster_Should_Pass()
        {
            // Arrange
            var myBase = DefaultModels.BaseMonsterDefault();

            // New Monster scales the level, so need to control the random.
            Crawl.Models.GameGlobals.SetForcedRandomNumbersValue(5);

            // Act
            var Expected = new Monster(myBase);
            var Result   = new Monster(myBase);

            // Reset
            // New Monster scales the level, so need to control the random.
            Crawl.Models.GameGlobals.DisableRandomValues();

            // Assert

            // Check all Monster fields, that come from BaseMonster.
            //Assert.AreEqual(Expected.Guid, Result.Guid, "Guid "+TestContext.CurrentContext.Test.Name);
            //Assert.AreEqual(Result.Guid, Result.Id, " Guid match ID " +TestContext.CurrentContext.Test.Name);

            Assert.AreEqual(Expected.Head, Result.Head, "Head " + TestContext.CurrentContext.Test.Name);
            Assert.AreEqual(Expected.Necklass, Result.Necklass, "Necklass " + TestContext.CurrentContext.Test.Name);
            Assert.AreEqual(Expected.RightFinger, Result.RightFinger, "Right Finger " + TestContext.CurrentContext.Test.Name);
            Assert.AreEqual(Expected.LeftFinger, Result.LeftFinger, "Left Finger " + TestContext.CurrentContext.Test.Name);
            Assert.AreEqual(Expected.Feet, Result.Feet, "Feet " + TestContext.CurrentContext.Test.Name);

            //Assert.AreEqual(Expected.Damage, Result.Damage, "Damage " + TestContext.CurrentContext.Test.Name);
            //Assert.AreEqual(300, Result.ExperienceRemaining, "Experience Remaining "+TestContext.CurrentContext.Test.Name);

            // Check the Attributes
            var myAttributes = new AttributeBase
            {
                Attack        = 1,
                Speed         = 1,
                MaxHealth     = 5,
                CurrentHealth = 5,
                Defense       = 1
            };

            JObject myAttributesJson  = (JObject)JToken.FromObject(myAttributes);
            var     myAttibutesString = myAttributesJson.ToString();

            //Assert.AreEqual(myAttibutesString, Result.AttributeString, "Attribute String" + TestContext.CurrentContext.Test.Name);

            Assert.AreEqual(Expected.Name, Result.Name, "Name " + TestContext.CurrentContext.Test.Name);
            Assert.AreEqual(Expected.Description, Result.Description, "Description " + TestContext.CurrentContext.Test.Name);
            Assert.AreEqual(Expected.Level, Result.Level, "Level " + TestContext.CurrentContext.Test.Name);
            Assert.AreEqual(Expected.ExperienceTotal, Result.ExperienceTotal, "Experience Total " + TestContext.CurrentContext.Test.Name);
            Assert.AreEqual(Expected.ImageURI, Result.ImageURI, "Image " + TestContext.CurrentContext.Test.Name);
        }
コード例 #2
0
        public void Model_BaseMonster_Update_With_Bogus_Data_Should_Skip()
        {
            var myDataDefault = DefaultModels.BaseMonsterDefault();
            var myData        = new BaseMonster();

            myData.Name = "Original Name";

            myData.Update(null);

            var Expected = "Original Name";
            var Actual   = myData.Name;

            Assert.AreEqual(Expected, Actual, TestContext.CurrentContext.Test.Name);
        }