예제 #1
0
        public void ViewModel_MonstersViewModel_LoadDataCommand_With_IsBusy_Should_Skip()
        {
            MockForms.Init();

            var myData   = new MonstersViewModel();
            var myIsBusy = myData.IsBusy;

            MasterDataStore.ForceDataRestoreAll();

            myData.Dataset.Clear();

            myData.IsBusy = true;

            var canExecute = myData.LoadDataCommand.CanExecute(null);

            myData.LoadDataCommand.Execute(null);

            var Actual   = myData.Dataset.Count();
            var Expected = 0;

            // set it back...
            myData.IsBusy = myIsBusy;
            MasterDataStore.ForceDataRestoreAll();

            // Validate the controller can stand up and has a Title
            Assert.AreEqual(Expected, Actual, TestContext.CurrentContext.Test.Name);
        }
예제 #2
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();

            MasterDataStore.ForceDataRestoreAll();

            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);
            MasterDataStore.ForceDataRestoreAll();

            // Validate the controller can stand up and has a Title
            Assert.AreEqual(Expected, Actual, TestContext.CurrentContext.Test.Name);
        }
예제 #3
0
        public void BattleEngine_AutoBattle_With_No_Initial_Characters_Should_Pass()
        {
            MockForms.Init();

            // Can create a new battle engine...
            var myBattleEngine = new BattleEngine();

            // Add new myCharacters in automaticaly
            // Characters are Level 1
            // Monsters are Level 1
            // Monsters will kill Characters in round 1.

            // Turn off random numbers
            // For a hit on everything...
            GameGlobals.SetForcedRandomNumbers(1, 20);  // Needs to be 20 so monsters always score a hit...

            MasterDataStore.ForceDataRestoreAll();

            myBattleEngine.AutoBattle();

            // Reset
            GameGlobals.ToggleRandomState();

            var Actual = myBattleEngine.BattleScore;

            Assert.AreNotEqual(1, Actual.RoundCount, "Round Count " + TestContext.CurrentContext.Test.Name);

            Assert.AreNotEqual(null, Actual, "Score Object " + TestContext.CurrentContext.Test.Name);
            Assert.AreNotEqual(0, Actual.ExperienceGainedTotal, "Experience " + TestContext.CurrentContext.Test.Name);
            Assert.AreNotEqual(0, Actual.TurnCount, "Turn Count " + TestContext.CurrentContext.Test.Name);
            Assert.AreNotEqual(0, Actual.ScoreTotal, "Score Total " + TestContext.CurrentContext.Test.Name);
            Assert.AreNotEqual(string.Empty, Actual.ItemsDroppedList, "Items Dropped " + TestContext.CurrentContext.Test.Name);
            Assert.AreNotEqual(string.Empty, Actual.MonstersKilledList, "Monsters Killed " + TestContext.CurrentContext.Test.Name);
            Assert.AreNotEqual(string.Empty, Actual.CharacterAtDeathList, "Character List " + TestContext.CurrentContext.Test.Name);
        }
예제 #4
0
        public void BattleEngine_AutoBattle_With_Characters_Level_2_Should_Level_Up_Pass()
        {
            MockForms.Init();

            // Can create a new battle engine...
            var myBattleEngine = new BattleEngine();

            // Turn off random numbers
            // For a hit on everything...
            GameGlobals.SetForcedRandomNumbers(1, 20);  // Needs to be 20 so monsters always score a hit...

            MasterDataStore.ForceDataRestoreAll();

            // Add new Characters in automaticaly
            // Characters are Level 2
            // Monsters are Level 1
            // Characters have weapons...
            // Use 6 existing Characters.  This will go for a few rounds.
            var myLevel     = 3;
            var myCharacter = myBattleEngine.GetRandomCharacter(myLevel, myLevel);

            myCharacter.Attribute.MaxHealth     = 100;
            myCharacter.Attribute.CurrentHealth = 100;

            // Set them just below the next level, so they level up...
            myCharacter.ExperienceTotal = LevelTable.Instance.LevelDetailsList[myLevel + 1].Experience - 1;

            for (var count = 1; count < 7; count++)
            {
                var myNewCharacter = new Character(myCharacter);
                myNewCharacter.Name = "Fighter " + count;
                myBattleEngine.CharacterList.Add(myNewCharacter);
            }

            var TempDamageBonusValue = GameGlobals.ForceCharacterDamangeBonusValue;

            // Make myCharacter s hit really really hard...
            GameGlobals.ForceCharacterDamangeBonusValue = 100;

            myBattleEngine.AutoBattle();

            // Reset
            GameGlobals.ToggleRandomState();
            GameGlobals.ForceCharacterDamangeBonusValue = TempDamageBonusValue;

            var Actual = myBattleEngine.BattleScore;

            Assert.AreNotEqual(1, Actual.RoundCount, "Round Count " + TestContext.CurrentContext.Test.Name);

            Assert.AreNotEqual(null, Actual, "Score Object " + TestContext.CurrentContext.Test.Name);
            Assert.AreNotEqual(0, Actual.ExperienceGainedTotal, "Experience " + TestContext.CurrentContext.Test.Name);
            Assert.AreNotEqual(0, Actual.TurnCount, "Turn Count " + TestContext.CurrentContext.Test.Name);
            Assert.AreNotEqual(0, Actual.ScoreTotal, "Score Total " + TestContext.CurrentContext.Test.Name);
            Assert.AreNotEqual(string.Empty, Actual.ItemsDroppedList, "Items Dropped " + TestContext.CurrentContext.Test.Name);
            Assert.AreNotEqual(string.Empty, Actual.MonstersKilledList, "Monsters Killed " + TestContext.CurrentContext.Test.Name);
            Assert.AreNotEqual(string.Empty, Actual.CharacterAtDeathList, "Character List " + TestContext.CurrentContext.Test.Name);
        }
예제 #5
0
        public void ViewModel_MonstersViewModel_LoadDataCommand_Should_Pass()
        {
            MockForms.Init();

            var myData = new MonstersViewModel();

            MasterDataStore.ForceDataRestoreAll();

            var Actual   = myData.Dataset.Count();
            var Expected = myData.DataStore.GetAllAsync_Monster().GetAwaiter().GetResult().Count();

            // Validate the controller can stand up and has a Title
            Assert.AreEqual(Expected, Actual, TestContext.CurrentContext.Test.Name);
        }
예제 #6
0
        public void BattleEngine_AddCharactersToBattle_With_Empty_CharacterListView_Should_Fail()
        {
            MockForms.Init();

            // Can create a new battle engine...
            var myBattleEngine = new BattleEngine();

            // Clear the dataset...
            CharactersViewModel.Instance.Dataset.Clear();

            var Return = myBattleEngine.AddCharactersToBattle();

            // Reset
            MasterDataStore.ForceDataRestoreAll();

            Assert.AreEqual(false, Return, TestContext.CurrentContext.Test.Name);
        }
예제 #7
0
        public void BattleEngine_AddCharactersToBattle_With_Empty_CharacterList_Should_Create_Characters()
        {
            MockForms.Init();

            // Can create a new battle engine...
            var myBattleEngine = new BattleEngine();

            // Force data for Characters and Items to be loaded and ready...
            MasterDataStore.ForceDataRestoreAll();

            var myItems = ItemsViewModel.Instance;

            var Return = myBattleEngine.AddCharactersToBattle();

            var Actual   = myBattleEngine.CharacterList.Count;
            var Expected = 6;

            Assert.AreEqual(true, Return, " Pass Fail " + TestContext.CurrentContext.Test.Name);
            Assert.AreEqual(Expected, Actual, TestContext.CurrentContext.Test.Name);
        }
예제 #8
0
        public void BattleEngine_AutoBattle_With_Six_Characters_Should_Pass()
        {
            MockForms.Init();

            // Can create a new battle engine...
            var myBattleEngine = new BattleEngine();

            // Use 6 existing myCharacter s.  This will go for a few rounds.
            var myCharacter = new Character(DefaultModels.CharacterDefault());

            myCharacter.Name = "Fighter 1";
            myCharacter.ScaleLevel(1);
            myBattleEngine.CharacterList.Add(myCharacter);

            myCharacter      = new Character(DefaultModels.CharacterDefault());
            myCharacter.Name = "Fighter 2";
            myCharacter.ScaleLevel(2);
            myBattleEngine.CharacterList.Add(myCharacter);

            myCharacter      = new Character(DefaultModels.CharacterDefault());
            myCharacter.Name = "Fighter 3";
            myCharacter.ScaleLevel(3);
            myBattleEngine.CharacterList.Add(myCharacter);

            myCharacter      = new Character(DefaultModels.CharacterDefault());
            myCharacter.Name = "Fighter 4";
            myCharacter.ScaleLevel(4);
            myBattleEngine.CharacterList.Add(myCharacter);

            myCharacter      = new Character(DefaultModels.CharacterDefault());
            myCharacter.Name = "Fighter 5";
            myCharacter.ScaleLevel(5);
            myBattleEngine.CharacterList.Add(myCharacter);

            myCharacter      = new Character(DefaultModels.CharacterDefault());
            myCharacter.Name = "Fighter 6";
            myCharacter.ScaleLevel(6);
            myBattleEngine.CharacterList.Add(myCharacter);

            // Use the Existing Characters...

            // Turn off random numbers
            // For a hit on everything...
            GameGlobals.SetForcedRandomNumbers(1, 20);  // Needs to be 20 so monsters always score a hit...

            MasterDataStore.ForceDataRestoreAll();

            myBattleEngine.AutoBattle();

            // Reset
            GameGlobals.ToggleRandomState();

            var Actual = myBattleEngine.BattleScore;

            Assert.AreNotEqual(null, Actual, "Score Object " + TestContext.CurrentContext.Test.Name);
            Assert.AreNotEqual(0, Actual.ExperienceGainedTotal, "Experience " + TestContext.CurrentContext.Test.Name);
            Assert.AreNotEqual(0, Actual.RoundCount, "Round Count " + TestContext.CurrentContext.Test.Name);
            Assert.AreNotEqual(0, Actual.TurnCount, "Turn Count " + TestContext.CurrentContext.Test.Name);
            Assert.AreNotEqual(0, Actual.ScoreTotal, "Score Total " + TestContext.CurrentContext.Test.Name);
            Assert.AreNotEqual(string.Empty, Actual.ItemsDroppedList, "Items Dropped " + TestContext.CurrentContext.Test.Name);
            Assert.AreNotEqual(string.Empty, Actual.MonstersKilledList, "Monsters Killed " + TestContext.CurrentContext.Test.Name);
            Assert.AreNotEqual(string.Empty, Actual.CharacterAtDeathList, "Character List " + TestContext.CurrentContext.Test.Name);
        }