Ejemplo n.º 1
0
        public void RoundEngine_RoundNextTurn_2Characters_1Monster_Weak_Should_Take_2_Turns()
        {
            MockForms.Init();

            bool reincarnation = GameGlobals.EnableReincarnation;

            GameGlobals.EnableReincarnation = false;

            // Can create a new Round engine...
            var myRoundEngine = new RoundEngine();

            // Start
            myRoundEngine.StartRound();

            // Add moderate monsters
            // First monster
            myRoundEngine.MonsterList.Clear();  // start fresh, because it was loaded already with 6...

            var myMonsterWeak = new Monster(DefaultModels.MonsterDefault());

            myMonsterWeak.ScaleLevel(5);
            myMonsterWeak.Attribute.CurrentHealth = 7; // need to set to enough to last 2 rounds...

            myRoundEngine.MonsterList.Add(myMonsterWeak);

            // Add weak character for first...
            var myCharacterWeak = new Character(DefaultModels.CharacterDefault());

            myCharacterWeak.ScaleLevel(10);
            myRoundEngine.CharacterList.Add(myCharacterWeak);

            // Add strong character for second
            var myCharacterStrong = new Character(DefaultModels.CharacterDefault());

            myCharacterStrong.ScaleLevel(20);
            myRoundEngine.CharacterList.Add(myCharacterStrong);

            // Should be Character 20, Character 10, Monster 5

            // Force rolls to 18 for to hit...
            // Turn off random numbers
            GameGlobals.SetForcedRandomNumbersValueAndToHit(1, 18);

            // Character, should kill the monster in the first round.
            // So the check for the second round will say Round over...
            var FirstRound  = myRoundEngine.RoundNextTurn();    // Character 20 Goes
            var SecondRound = myRoundEngine.RoundNextTurn();    // Character 10 Goes
            var Actual      = myRoundEngine.RoundNextTurn();    // Over...


            // Reset
            GameGlobals.ToggleRandomState();

            var Expected = RoundEnum.NextTurn;

            Assert.AreEqual(Expected, Actual, "Status " + TestContext.CurrentContext.Test.Name);
            Assert.AreEqual(3, myRoundEngine.BattleScore.TurnCount, "TurnCount " + TestContext.CurrentContext.Test.Name);
            //Assert.AreEqual(4, myRoundEngine.BattleScore.RoundCount, "RoundCount " + TestContext.CurrentContext.Test.Name);
            GameGlobals.EnableReincarnation = reincarnation;
        }
        public void Model_BaseMonster_Update_With_Valid_Data_Should_Pass()
        {
            var myDataDefault = DefaultModels.MonsterDefault();
            var myData        = new BaseMonster();

            myData.Update(myDataDefault);

            // Validate the new BaseMonster has the expected fields.
            // All fields should match.

            // The attirbute string is what is unique about creating from BaseBaseMonster, and should be passed down...
            Assert.AreEqual(myData.UniqueItem, myDataDefault.UniqueItem, "UniqueItem " + TestContext.CurrentContext.Test.Name);

            Assert.AreEqual(myData.Alive, myDataDefault.Alive, "Alive " + TestContext.CurrentContext.Test.Name);
            Assert.AreEqual(myData.Name, myDataDefault.Name, "Name " + TestContext.CurrentContext.Test.Name);
            Assert.AreEqual(myData.Description, myDataDefault.Description, "Description " + TestContext.CurrentContext.Test.Name);
            Assert.AreEqual(myData.Level, myDataDefault.Level, "Level " + TestContext.CurrentContext.Test.Name);
            Assert.AreEqual(myData.ExperienceTotal, myDataDefault.ExperienceTotal, "ExperienceTotal " + TestContext.CurrentContext.Test.Name);
            Assert.AreEqual(myData.ImageURI, myDataDefault.ImageURI, "ImageURI " + TestContext.CurrentContext.Test.Name);

            Assert.AreEqual(myData.Head, myDataDefault.Head, "Head " + TestContext.CurrentContext.Test.Name);
            Assert.AreEqual(myData.Feet, myDataDefault.Feet, "Feet " + TestContext.CurrentContext.Test.Name);
            Assert.AreEqual(myData.Necklass, myDataDefault.Necklass, "Necklass " + TestContext.CurrentContext.Test.Name);
            Assert.AreEqual(myData.RightFinger, myDataDefault.RightFinger, "RightFinger " + TestContext.CurrentContext.Test.Name);
            Assert.AreEqual(myData.LeftFinger, myDataDefault.LeftFinger, "LeftFinger " + TestContext.CurrentContext.Test.Name);
            Assert.AreEqual(myData.Feet, myDataDefault.Feet, "Feet " + TestContext.CurrentContext.Test.Name);

            // Validate the Attributes
            Assert.AreEqual(myData.AttributeString, myDataDefault.AttributeString, "AttributeString " + TestContext.CurrentContext.Test.Name);

            Assert.AreEqual(myData.Damage, myDataDefault.Damage, "AttributeString " + TestContext.CurrentContext.Test.Name);
        }
        public void Model_Monster_GetUniqueItem_Valid_Should_Pass()
        {
            MockForms.Init();

            var myItem = new Item
            {
                Attribute = AttributeEnum.Attack,
                Location  = ItemLocationEnum.Feet,
                Value     = 1
            };

            ItemsViewModel.Instance.AddAsync(myItem).GetAwaiter().GetResult();  // Register Item to DataSet
            var myMonsterItem = ItemsViewModel.Instance.GetItem(myItem.Id);

            var myData        = new Monster();
            var myDataDefault = DefaultModels.MonsterDefault();

            myDataDefault.UniqueItem = myMonsterItem.Guid;

            var Result   = myDataDefault.GetUniqueItem();
            var Expected = myItem;

            // Guids should match up...
            Assert.AreEqual(Expected.Guid, Result.Guid, TestContext.CurrentContext.Test.Name);
        }
Ejemplo n.º 4
0
        public void TurnEngine_Turn_AttackChoice_Monster_Valid_Attacker_Valid_Defender_Alive_False_Should_Skip()
        {
            // Arrange
            var Attacker = DefaultModels.MonsterDefault();

            var myDefaultCharacter = new Character(DefaultModels.CharacterDefault());

            myDefaultCharacter.Name = "Fighter";
            myDefaultCharacter.ScaleLevel(20);
            myDefaultCharacter.Alive = false; //dead...

            var myTurnEngine = new TurnEngine();

            myTurnEngine.CharacterList.Add(myDefaultCharacter);

            object Expected = null;

            // Act
            var Actual = myTurnEngine.AttackChoice(Attacker);

            // Reset

            // Assert

            Assert.AreEqual(Expected, Actual, TestContext.CurrentContext.Test.Name);
        }
Ejemplo n.º 5
0
        public void TurnEngine_TurnAsAttack_Monster_Attack_DefenderList_CriticalMiss_Should_Pass()
        {
            // Turn off random numbers
            GameGlobals.SetForcedRandomNumbers(1, 20);

            var Attacker = DefaultModels.MonsterDefault();

            Attacker.Name = "Rat";

            var myDefaultCharacter = DefaultModels.CharacterDefault();

            myDefaultCharacter.Name = "Fighter";

            var myTurnEngine = new TurnEngine();

            myTurnEngine.CharacterList.Add(myDefaultCharacter);

            GameGlobals.ForceToHitValue = 1; // Force a miss

            var AttackScore  = Attacker.Level + Attacker.GetAttack();
            var DefenseScore = myDefaultCharacter.GetDefense() + myDefaultCharacter.Level;

            var  Status   = myTurnEngine.TurnAsAttack(Attacker, AttackScore, myDefaultCharacter, DefenseScore);
            var  Actual   = Status;
            bool Expected = true;

            var ActualString = myTurnEngine.TurnMessage;
            var ActualResult = myTurnEngine.HitStatus;
            var ActualDamage = myTurnEngine.DamageAmount;

            // Reset
            GameGlobals.ToggleRandomState();

            Assert.AreEqual(Expected, Actual, TestContext.CurrentContext.Test.Name);
        }
Ejemplo n.º 6
0
        public void RoundEngine_RoundNextTurn_2_Characters_Should_Return_NextTurn()
        {
            MockForms.Init();

            // No characters, so return should be game over...

            // Can create a new Round engine...
            var myRoundEngine = new RoundEngine();

            // Add 2 monsters
            myRoundEngine.MonsterList.Add(new Monster(DefaultModels.MonsterDefault()));
            myRoundEngine.MonsterList.Add(new Monster(DefaultModels.MonsterDefault()));

            // Add 2 characters
            myRoundEngine.CharacterList.Add(new Character(DefaultModels.CharacterDefault()));
            myRoundEngine.CharacterList.Add(new Character(DefaultModels.CharacterDefault()));

            // Start
            myRoundEngine.StartRound();

            // Do the turn...
            var Actual = myRoundEngine.RoundNextTurn();

            // There are 2 characters, and 2 monsters, so the first turn should happen, and it is now next turn...

            var Expected = RoundEnum.NextTurn;

            Assert.AreEqual(Expected, Actual, TestContext.CurrentContext.Test.Name);
        }
Ejemplo n.º 7
0
        public void TurnEngine_TurnAsAttack_Monster_Attack_DefenderList_Miss_Should_Pass()
        {
            MockForms.Init();

            // Turn off random numbers
            GameGlobals.SetForcedRandomNumbersValueAndToHit(1, 20);

            var Attacker = DefaultModels.MonsterDefault();

            Attacker.Name = "Rat";

            var myDefaultCharacter = new Character(DefaultModels.CharacterDefault());

            myDefaultCharacter.Name = "Fighter";
            myDefaultCharacter.ScaleLevel(20);

            var myTurnEngine = new TurnEngine();

            myTurnEngine.CharacterList.Add(myDefaultCharacter);

            GameGlobals.ForceToHitValue = 2; // Force a miss

            var AttackScore  = Attacker.Level + Attacker.GetAttack();
            var DefenseScore = myDefaultCharacter.GetDefense() + myDefaultCharacter.Level;

            var Status = myTurnEngine.TurnAsAttack(Attacker, AttackScore, myDefaultCharacter, DefenseScore);

            var  Actual   = Status;
            bool Expected = true;

            // Reset
            GameGlobals.ToggleRandomState();

            Assert.AreEqual(Expected, Actual, TestContext.CurrentContext.Test.Name);
        }
Ejemplo n.º 8
0
        public async Task ViewModel_MonstersViewModel_UpdateData_Bogus_Should_Skip()
        {
            MockForms.Init();

            // Get State of the DataStore, and set to run on the Mock
            var myDataStoreEnum = MasterDataStore.GetDataStoreMockFlag();

            MasterDataStore.ToggleDataStore(DataStoreEnum.Mock);

            var myViewModel = new MonstersViewModel();

            myViewModel.ForceDataRefresh();

            var myData = DefaultModels.MonsterDefault();

            // Make the ID bogus...
            var value = "new";

            myData.Id = value;

            var myReturn = await myViewModel.UpdateAsync(myData);

            var  Actual   = myReturn;
            bool Expected = false;

            // Return state
            MasterDataStore.ToggleDataStore(myDataStoreEnum);
            myViewModel.ForceDataRefresh();

            // Validate the controller can stand up and has a Title
            Assert.AreEqual(Expected, Actual, TestContext.CurrentContext.Test.Name);
        }
Ejemplo n.º 9
0
        public async Task ViewModel_MessageCenter_MonstersViewModel_MessageCenter_DeleteData_Should_Pass()
        {
            MockForms.Init();

            // Get State of the DataStore, and set to run on the Mock
            var myDataStoreEnum = MasterDataStore.GetDataStoreMockFlag();

            MasterDataStore.ToggleDataStore(DataStoreEnum.Mock);

            var myViewModel = new MonstersViewModel();
            var myData      = DefaultModels.MonsterDefault();
            await myViewModel.AddAsync(myData);

            var myPage = new DeleteMonsterPage(new MonsterDetailViewModel(new Monster()));

            MessagingCenter.Send(myPage, "DeleteData", myData);

            var Actual = await myViewModel.GetAsync(myData.Id);

            Object Expected = null;

            // Return state
            MasterDataStore.ToggleDataStore(myDataStoreEnum);

            // Validate the controller can stand up and has a Title
            Assert.AreEqual(Expected, Actual, TestContext.CurrentContext.Test.Name);
        }
Ejemplo n.º 10
0
        public async Task ViewModel_MonstersViewModel_UpdateData_Should_Pass()
        {
            MockForms.Init();

            // Get State of the DataStore, and set to run on the Mock
            var myDataStoreEnum = MasterDataStore.GetDataStoreMockFlag();

            MasterDataStore.ToggleDataStore(DataStoreEnum.Mock);

            var myViewModel = new MonstersViewModel();
            var myData      = DefaultModels.MonsterDefault();
            await myViewModel.AddAsync(myData);

            var value = "new";

            myData.Name = value;
            var myReturn = myViewModel.UpdateAsync(myData);

            var Actual = await myViewModel.GetAsync(myData.Id);

            string Expected = value;

            // Return state
            MasterDataStore.ToggleDataStore(myDataStoreEnum);

            // Validate the controller can stand up and has a Title
            Assert.AreEqual(Expected, Actual.Name, TestContext.CurrentContext.Test.Name);
        }
        public void Model_Monster_Instantiate_Should_Pass()
        {
            var myData        = new Monster();
            var myDataDefault = DefaultModels.MonsterDefault();

            // Set Monster to be the same as a default Monster

            // Base information
            myData.Name            = myDataDefault.Name;
            myData.Description     = myDataDefault.Description;
            myData.Level           = myDataDefault.Level;
            myData.ExperienceTotal = myDataDefault.ExperienceTotal;
            myData.ImageURI        = myDataDefault.ImageURI;
            myData.Alive           = myDataDefault.Alive;

            // Populate the Attributes
            myData.AttributeString = myDataDefault.AttributeString;

            myData.Attribute.Speed         = myDataDefault.Attribute.Speed;
            myData.Attribute.Defense       = myDataDefault.Attribute.Defense;
            myData.Attribute.Attack        = myDataDefault.Attribute.Attack;
            myData.Attribute.CurrentHealth = myDataDefault.Attribute.CurrentHealth;
            myData.Attribute.MaxHealth     = myDataDefault.Attribute.MaxHealth;

            // Set the strings for the items
            myData.Head        = null;
            myData.Feet        = null;
            myData.Necklass    = null;
            myData.RightFinger = null;
            myData.LeftFinger  = null;
            myData.Feet        = null;

            // Compare Monster to what is expected.
            Assert.AreEqual(myData.Alive, myDataDefault.Alive, "Alive " + TestContext.CurrentContext.Test.Name);
            Assert.AreEqual(myData.Name, myDataDefault.Name, "Name " + TestContext.CurrentContext.Test.Name);
            Assert.AreEqual(myData.Description, myDataDefault.Description, "Description " + TestContext.CurrentContext.Test.Name);
            Assert.AreEqual(myData.Level, myDataDefault.Level, "Level " + TestContext.CurrentContext.Test.Name);
            Assert.AreEqual(myData.ExperienceTotal, myDataDefault.ExperienceTotal, "ExperienceTotal " + TestContext.CurrentContext.Test.Name);
            Assert.AreEqual(myData.ImageURI, myDataDefault.ImageURI, "ImageURI " + TestContext.CurrentContext.Test.Name);

            Assert.AreEqual(myData.Head, myDataDefault.Head, "Head " + TestContext.CurrentContext.Test.Name);
            Assert.AreEqual(myData.Feet, myDataDefault.Feet, "Feet " + TestContext.CurrentContext.Test.Name);
            Assert.AreEqual(myData.Necklass, myDataDefault.Necklass, "Necklass " + TestContext.CurrentContext.Test.Name);
            Assert.AreEqual(myData.RightFinger, myDataDefault.RightFinger, "RightFinger " + TestContext.CurrentContext.Test.Name);
            Assert.AreEqual(myData.LeftFinger, myDataDefault.LeftFinger, "LeftFinger " + TestContext.CurrentContext.Test.Name);
            Assert.AreEqual(myData.Feet, myDataDefault.Feet, "Feet " + TestContext.CurrentContext.Test.Name);

            //Assert.AreEqual(myData.Damage, myDataDefault.Damage, "Damage " + TestContext.CurrentContext.Test.Name);

            // Validate the Attributes
            Assert.AreEqual(myData.AttributeString, myDataDefault.AttributeString, "AttributeString " + TestContext.CurrentContext.Test.Name);

            Assert.AreEqual(myData.Attribute.Speed, myDataDefault.Attribute.Speed, "Speed " + TestContext.CurrentContext.Test.Name);
            Assert.AreEqual(myData.Attribute.Defense, myDataDefault.Attribute.Defense, "Defense " + TestContext.CurrentContext.Test.Name);
            Assert.AreEqual(myData.Attribute.Attack, myDataDefault.Attribute.Attack, "Attack " + TestContext.CurrentContext.Test.Name);
            Assert.AreEqual(myData.Attribute.CurrentHealth, myDataDefault.Attribute.CurrentHealth, "CurrentHealth " + TestContext.CurrentContext.Test.Name);
            Assert.AreEqual(myData.Attribute.MaxHealth, myDataDefault.Attribute.MaxHealth, "MaxHealth " + TestContext.CurrentContext.Test.Name);
        }
Ejemplo n.º 12
0
        public void RoundEngine_RoundNextTurn_2Characters_1Monster_Strong_Should_Take_3_Rounds()
        {
            MockForms.Init();

            // No characters, so return should be game over...

            // Can create a new Round engine...
            var myRoundEngine = new RoundEngine();

            // Start
            myRoundEngine.StartRound();

            // Add moderate monsters
            // First monster
            myRoundEngine.MonsterList.Clear();  // start fresh, because it was loaded already with 6...

            var myMonsterWeak = new Monster(DefaultModels.MonsterDefault());

            myMonsterWeak.ScaleLevel(2);
            myMonsterWeak.Attribute.CurrentHealth = 20; // need to set to enough to last 4 rounds...
            myRoundEngine.MonsterList.Add(myMonsterWeak);

            // Add weak character for first...
            var myCharacterStrong = new Character(DefaultModels.CharacterDefault());

            myCharacterStrong.ScaleLevel(10);
            myRoundEngine.CharacterList.Add(myCharacterStrong);

            // Add strong character for second
            myCharacterStrong = new Character(DefaultModels.CharacterDefault());
            myCharacterStrong.ScaleLevel(20);
            myRoundEngine.CharacterList.Add(myCharacterStrong);

            // Should be Character 20, Character 10, Monster 5

            // Force rolls to 18 for to hit...
            // Turn off random numbers
            GameGlobals.SetForcedRandomNumbers(1, 18);

            // Character, should kill the monster in the first round.
            // So the check for the second round will say Round over...
            var FirstRound  = myRoundEngine.RoundNextTurn();    // Character 20
            var SecondRound = myRoundEngine.RoundNextTurn();    // Character 10 goes
            var ThirdRound  = myRoundEngine.RoundNextTurn();    // Monster goes
            var FourthRound = myRoundEngine.RoundNextTurn();    // Character 20 goes, kills monster...
            var Actual      = myRoundEngine.RoundNextTurn();    // over...

            // Reset
            GameGlobals.ToggleRandomState();

            var Expected = RoundEnum.NewRound;

            Assert.AreEqual(Expected, Actual, "Status " + TestContext.CurrentContext.Test.Name);
            Assert.AreEqual(4, myRoundEngine.BattleScore.TurnCount, "TurnCount " + TestContext.CurrentContext.Test.Name);
            Assert.AreEqual(1, myRoundEngine.BattleScore.RoundCount, "RoundCount " + TestContext.CurrentContext.Test.Name);
        }
        public void Model_Monster_GetSpeed_Valid_Should_Pass()
        {
            var myData        = new Monster();
            var myDataDefault = DefaultModels.MonsterDefault();

            var Result   = myDataDefault.GetSpeed();
            var Expected = 1;

            Assert.AreEqual(Expected, Result, TestContext.CurrentContext.Test.Name);
        }
        public void Model_Monster_GetDamage_Valid_Should_Pass()
        {
            var myData        = new Monster();
            var myDataDefault = DefaultModels.MonsterDefault();

            var Result   = myDataDefault.GetDamage();
            var Expected = 1; // 1 for level, and 1 for base damage

            Assert.AreEqual(Expected, Result, TestContext.CurrentContext.Test.Name);
        }
Ejemplo n.º 15
0
        public void TurnEngine_TurnAsAttack_Monster_Attack_Defender_Die_With_Item_Should_Drop()
        {
            MockForms.Init();

            // Turn off random numbers
            GameGlobals.SetForcedRandomNumbers(1, 20);

            var Attacker = DefaultModels.MonsterDefault();

            Attacker.Name = "Rat";
            Attacker.ScaleLevel(20);

            var myDefaultCharacter = new Character(DefaultModels.CharacterDefault());

            myDefaultCharacter.Name = "Fighter";
            myDefaultCharacter.ScaleLevel(1);

            // Add Uniqueitem
            var myItem = new Item
            {
                Attribute = AttributeEnum.Attack,
                Location  = ItemLocationEnum.Feet,
                Value     = 1
            };

            ItemsViewModel.Instance.AddAsync(myItem).GetAwaiter().GetResult();  // Register Item to DataSet
            myDefaultCharacter.PrimaryHand = myItem.Guid;

            var myTurnEngine = new TurnEngine();

            myTurnEngine.CharacterList.Add(myDefaultCharacter);

            // Get Score, and remember item.
            var BeforeItemDropList = myTurnEngine.BattleScore.ItemsDroppedList;

            GameGlobals.ForceToHitValue = 20; // Force a hit

            // Should Kill because level 20 hit on level 1 Character for Critical is more damage than health...
            var AttackScore  = Attacker.Level + Attacker.GetAttack();
            var DefenseScore = myDefaultCharacter.GetDefense() + myDefaultCharacter.Level;

            var Status = myTurnEngine.TurnAsAttack(Attacker, AttackScore, myDefaultCharacter, DefenseScore);


            // Item should drop...

            // Reset
            GameGlobals.ToggleRandomState();

            // Need to get Score
            // See if Item is now in the score list...
            var AfterItemDropList = myTurnEngine.BattleScore.ItemsDroppedList;

            Assert.AreNotEqual(BeforeItemDropList, AfterItemDropList, TestContext.CurrentContext.Test.Name);
        }
Ejemplo n.º 16
0
        public void ViewModel_MonstersViewModel_Instantiate_With_Data_Should_Pass()
        {
            var myData = DefaultModels.MonsterDefault();

            var value = "hi";

            myData.Name = value;
            var Actual = new MonsterDetailViewModel(myData);

            Assert.AreEqual(value, Actual.Title, TestContext.CurrentContext.Test.Name);
        }
        public void Model_Monster_FormatOutput_DefaultMonster_Should_Pass()
        {
            MockForms.Init();
            var myData = DefaultModels.MonsterDefault();

            var Expected = "Name , Description , Level : 1 , Total Experience : 0 , Unique Item : None";

            var Actual = myData.FormatOutput();

            Assert.AreEqual(Expected, Actual, TestContext.CurrentContext.Test.Name);
        }
        public void Model_Monster_ExperienceRemaining_Get_Valid_Should_Pass()
        {
            var myData        = new Monster();
            var myDataDefault = DefaultModels.MonsterDefault(); // default is 3000


            var Result   = myDataDefault.ExperienceRemaining;
            var Expected = 3000;

            Assert.AreEqual(Expected, Result, TestContext.CurrentContext.Test.Name);
        }
        public void Model_Monster_GetUniqueItem_Null_Should_Skip()
        {
            var myData        = new Monster();
            var myDataDefault = DefaultModels.MonsterDefault();

            myDataDefault.UniqueItem = null;

            var  Result   = myDataDefault.GetUniqueItem();
            Item Expected = null;

            Assert.AreEqual(Expected, Result, TestContext.CurrentContext.Test.Name);
        }
Ejemplo n.º 20
0
        public void Model_Monster_GetDefense_Valid_Should_Pass()
        {
            var myData        = new Monster();
            var myDataDefault = DefaultModels.MonsterDefault();

            myDataDefault.Attribute.Defense = 200;

            var Result   = myDataDefault.GetDefense();
            var Expected = 200;

            Assert.AreEqual(Expected, Result, TestContext.CurrentContext.Test.Name);
        }
Ejemplo n.º 21
0
        public void Model_Score_AddMonsterToList_With_Null_Add_Should_Skip()
        {
            var myAdd  = DefaultModels.MonsterDefault();
            var myData = new Score();

            myData.AddMonsterToList(null);

            var    Actual   = myData.MonstersKilledList;
            string Expected = null;

            // Validate the controller can stand up and has a Title
            Assert.AreEqual(Expected, Actual, TestContext.CurrentContext.Test.Name);
        }
Ejemplo n.º 22
0
        public void TurnEngine_Turn_AttackChoice_Monster_Valid_Attacker_Empty_Defender_Should_Pass()
        {
            var Attacker = DefaultModels.MonsterDefault();

            var myTurnEngine = new TurnEngine();

            myTurnEngine.CharacterList = new List <Character>();

            var    Actual   = myTurnEngine.AttackChoice(Attacker);
            object Expected = null;

            Assert.AreEqual(Expected, Actual, TestContext.CurrentContext.Test.Name);
        }
        public void Model_Monster_DropAllItems_Null_Should_Skip()
        {
            MockForms.Init();

            var myData        = new Monster();
            var myDataDefault = DefaultModels.MonsterDefault();

            myDataDefault.UniqueItem = null;

            var Result   = myDataDefault.DropAllItems();
            var Expected = 0;

            Assert.AreEqual(Expected, Result.Count, TestContext.CurrentContext.Test.Name);
        }
Ejemplo n.º 24
0
        public void TurnEngine_TakeTurn_Attack_Valid_Defender_Valid_Defender_Should_Die()
        {
            MockForms.Init();

            // Turn off random numbers
            GameGlobals.SetForcedRandomNumbers(1, 20);

            var Attacker = DefaultModels.CharacterDefault();

            Attacker.Name = "Fighter";
            Attacker.ScaleLevel(20);

            var myDefaultMonster = new Monster(DefaultModels.MonsterDefault());

            myDefaultMonster.Name = "Rat";
            myDefaultMonster.ScaleLevel(1);

            // Add Uniqueitem
            var myItem = new Item
            {
                Attribute = AttributeEnum.Attack,
                Location  = ItemLocationEnum.Feet,
                Value     = 1
            };

            ItemsViewModel.Instance.AddAsync(myItem).GetAwaiter().GetResult();  // Register Item to DataSet
            myDefaultMonster.UniqueItem = myItem.Guid;

            var myTurnEngine = new TurnEngine();

            myTurnEngine.MonsterList.Add(myDefaultMonster);

            // Get Score, and remember item.
            var BeforeItemDropList = myTurnEngine.BattleScore.ItemsDroppedList;

            GameGlobals.ForceToHitValue = 20; // Force a hit

            var BeforeMonsterList = myTurnEngine.MonsterList.Count();

            // Instead of calling TurnAsAttack, call TakeTurn...
            var Status = myTurnEngine.TakeTurn(Attacker);

            var AfterMonsterList = myTurnEngine.MonsterList.Count();

            // Item should drop...
            // Reset
            GameGlobals.ToggleRandomState();

            Assert.AreEqual(BeforeMonsterList - 1, AfterMonsterList, TestContext.CurrentContext.Test.Name);
        }
Ejemplo n.º 25
0
        public void ViewModel_MonstersViewModel_GetData_With_Data_Should_Pass()
        {
            var myData = DefaultModels.MonsterDefault();

            var value = "hi";

            myData.Name = value;
            var myViewModel = new MonsterDetailViewModel(myData);

            var Actual   = myViewModel.Data;
            var Expected = myData;

            Assert.AreEqual(Expected.Name, Actual.Name, TestContext.CurrentContext.Test.Name);
        }
        public void Model_Monster_Update_With_Bogus_Data_Should_Skip()
        {
            var myDataDefault = DefaultModels.MonsterDefault();
            var myData        = new Monster();

            myData.Name = "Original Name";

            myData.Update(null);

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

            Assert.AreEqual(Expected, Actual, TestContext.CurrentContext.Test.Name);
        }
Ejemplo n.º 27
0
        public void Model_Score_AddMonsterToList_With_Valid_Should_Pass()
        {
            var myAdd  = DefaultModels.MonsterDefault();
            var myData = new Score();

            myData.AddMonsterToList(myAdd);

            var Actual   = myData.MonstersKilledList;
            var myValue  = "Name , Description , Level : 1 , Total Experience : 0 , Unique Item : None\n";
            var Expected = myValue;

            // Validate the controller can stand up and has a Title
            Assert.AreEqual(Expected, Actual, TestContext.CurrentContext.Test.Name);
        }
Ejemplo n.º 28
0
        public void RoundEngine_RoundNextTurn_1_Character_Should_Have_NewRound_Should_Pass()
        {
            MockForms.Init();

            // Start round with one monster and character
            var myRoundEngine = new RoundEngine();

            myRoundEngine.MonsterList.Add(new Monster(DefaultModels.MonsterDefault()));
            myRoundEngine.CharacterList.Add(new Character(DefaultModels.CharacterDefault()));
            myRoundEngine.StartRound();
            var Expected = RoundEnum.NextTurn;
            var Actual   = myRoundEngine.RoundNextTurn();

            Assert.AreEqual(Expected, Actual, TestContext.CurrentContext.Test.Name);
        }
        public void Model_Monster_CalculateExperienceEarned_3_Should_Pass()
        {
            var myData        = new Monster();
            var myDataDefault = DefaultModels.MonsterDefault();

            myDataDefault.ExperienceRemaining     = 3000;
            myDataDefault.Attribute.MaxHealth     = 20;
            myDataDefault.Attribute.CurrentHealth = 20;

            // Call calculate experience before applying damage
            var Result = myDataDefault.CalculateExperienceEarned(3);

            var Expected = 450;

            Assert.AreEqual(Expected, Result, TestContext.CurrentContext.Test.Name);
        }
        public void Model_Monster_TakeDamage_With_Zero_Should_Skip()
        {
            var health = 100;
            var myData = DefaultModels.MonsterDefault();

            myData.Attribute.CurrentHealth = health;
            myData.Attribute.MaxHealth     = health;

            var value = 0;

            myData.TakeDamage(value);

            var Expected = health - value;
            var Actual   = myData.GetHealthCurrent();

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