Exemplo n.º 1
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);
        }
Exemplo n.º 2
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 async Task ViewModel_ScoresViewModel_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 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);
        }
Exemplo n.º 4
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);
        }
Exemplo n.º 5
0
        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_ScoresViewModel_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 ScoresViewModel();
            var myData      = DefaultModels.ScoreDefault();

            var myPage = new ScoreNewPage();

            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);
        }
Exemplo n.º 7
0
        public async Task ViewModel_ItemsViewModel_InsertUpdateAsync_Update_Data_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);

            // Update existing
            var Value = "updated";

            myData.Name = Value;
            var myReturn = await myViewModel.InsertUpdateAsync(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);
        }
Exemplo n.º 8
0
        public async Task ViewModel_ItemsViewModel_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 ItemsViewModel();
            // Load data
            var canExecute = myViewModel.LoadDataCommand.CanExecute(null);

            myViewModel.LoadDataCommand.Execute(null);

            var myData = DefaultModels.ItemDefault(ItemLocationEnum.Feet, AttributeEnum.Attack);

            // 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);

            // Validate the controller can stand up and has a Title
            Assert.AreEqual(Expected, Actual, TestContext.CurrentContext.Test.Name);
        }
Exemplo n.º 9
0
        public AboutPage()
        {
            InitializeComponent();

            // Set the flag for Mock on or off...
            UseMockDatabaseSwitch.IsToggled = (MasterDataStore.GetDataStoreMockFlag() == DataStoreEnum.Mock);
            SetDataSource(UseMockDatabaseSwitch.IsToggled);
        }
Exemplo n.º 10
0
        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();
        }
Exemplo n.º 11
0
        public async Task ViewModel_CharactersViewModel_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 = CharactersViewModel.Instance;
            var myData      = DefaultModels.CharacterDefault();
            var myReturn    = await myViewModel.AddAsync(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);
        }