public async Task ViewModel_MessageCenter_ScoresViewModel_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 ScoresViewModel(); var myData = DefaultModels.ScoreDefault(); await myViewModel.AddAsync(myData); var myPage = new DeleteScorePage(new ScoreDetailViewModel(new Score())); 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); }
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); }
public async Task ViewModel_ScoresViewModel_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 ScoresViewModel(); myViewModel.ForceDataRefresh(); var myData = DefaultModels.ScoreDefault(); // 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); }
public async Task ViewModel_ItemsViewModel_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 ItemsViewModel(); var myData = DefaultModels.ItemDefault(ItemLocationEnum.Feet, AttributeEnum.Attack); await myViewModel.AddAsync(myData); var myReturn = await myViewModel.DeleteAsync(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); }
public async Task ViewModel_MessageCenter_ItemsViewModel_MessageCenter_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 ItemsViewModel(); var myData = DefaultModels.ItemDefault(ItemLocationEnum.Feet, AttributeEnum.Attack); await myViewModel.AddAsync(myData); var value = "new"; myData.Name = value; var myPage = new EditItemPage(new ItemDetailViewModel(new Item())); MessagingCenter.Send(myPage, "EditData", 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 async Task ViewModel_MessageCenter_CharactersViewModel_MessageCenter_AddData_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 CharactersViewModel(); var myData = DefaultModels.CharacterDefault(); var myPage = new NewCharacterPage(); MessagingCenter.Send(myPage, "AddData", myData); var Actual = await myViewModel.GetAsync(myData.Id); var Expected = myData; // Return state MasterDataStore.ToggleDataStore(myDataStoreEnum); // Validate the controller can stand up and has a Title Assert.AreEqual(Expected.Id, Actual.Id, TestContext.CurrentContext.Test.Name); }
public void ViewModel_CharactersViewModel_LoadDataCommand_With_IsBusy_Should_Skip() { MockForms.Init(); var myData = CharactersViewModel.Instance; 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); }
public async Task ViewModel_ScoresViewModel_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 ScoresViewModel(); var myData = DefaultModels.ScoreDefault(); 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 AboutPage() { InitializeComponent(); // Set the flag for Mock on or off... UseMockDatabaseSwitch.IsToggled = (MasterDataStore.GetDataStoreMockFlag() == DataStoreEnum.Mock); SetDataSource(UseMockDatabaseSwitch.IsToggled); }
public App() { InitializeComponent(); MainPage = new MainPage(); // Load The Mock Datastore by default MasterDataStore.ToggleDataStore(DataStoreEnum.Mock); }
public App() { InitializeComponent(); MainPage = new NavigationPage(new OpeningPage()); //defaults to sql database MasterDataStore.ToggleDataStore(Models.DataStoreEnum.Sql); }
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); }
private void SetDataSource(bool isMock) { var set = DataStoreEnum.Sql; if (isMock) { set = DataStoreEnum.Mock; } MasterDataStore.ToggleDataStore(set); }
public void SetDataSource(bool isMock) { var set = DataStoreEnum.SQL; if (isMock) { set = DataStoreEnum.Mock; } MasterDataStore.ToggleDataStore(set); }
//switches datasource from sql to mock private void SetDataSource(bool isMock) { var set = DataStoreEnum.Sql; if (isMock) { set = DataStoreEnum.Mock; } //tells MasterDataStore to set to appropriate database MasterDataStore.ToggleDataStore(set); }
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); }
public AboutPage() { InitializeComponent(); BindingContext = _viewModel; // Set the flag for Mock on or off... UseMockDataSource.IsToggled = (MasterDataStore.GetDataStoreMockFlag() == DataStoreEnum.Mock); SetDataSource(UseMockDataSource.IsToggled); // Example of how to add an view to an existing set of XAML. // Give the Xaml layout you want to add the data to a good x:Name, so you can access it. Here "DateRoot" is what I am using. var dateLabel = new Label { Text = DateTime.Now.ToShortDateString(), HorizontalOptions = LayoutOptions.Center, VerticalOptions = LayoutOptions.Center, FontFamily = "Helvetica Neue", FontAttributes = FontAttributes.Bold, FontSize = 12, TextColor = Color.Black, }; DateRoot.Children.Add(dateLabel); // Set debug settings EnableCriticalMissProblems.IsToggled = GameGlobals.EnableCriticalMissProblems; EnableCriticalHitDamage.IsToggled = GameGlobals.EnableCriticalHitDamage; // Turn off the Debug Frame DebugSettingsFrame.IsVisible = false; // Turn off Forced Random Numbers Frame ForcedRandomValuesSettingsFrame.IsVisible = false; // Turn off Database Settings Frame DatabaseSettingsFrame.IsVisible = false; var myTestItem = new Item(); var myTestCharacter = new Character(); var myTestMonster = new Monster(); var myOutputItem = myTestItem.FormatOutput(); var myOutputCharacter = myTestCharacter.FormatOutput(); var myOutputMonster = myTestMonster.FormatOutput(); }
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); }
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); }
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); }