Example #1
0
        public async Task ViewModel_MessageCenter_CharactersViewModel_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 CharactersViewModel();
            var myData      = DefaultModels.CharacterDefault();
            await myViewModel.AddAsync(myData);

            var myPage = new DeleteCharacterPage(new CharacterDetailViewModel(new Character()));

            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);
        }
Example #2
0
        public async Task ViewModel_CharactersViewModel_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 CharactersViewModel();

            myViewModel.ForceDataRefresh();

            var myData = DefaultModels.CharacterDefault();

            // 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);
        }
        //Default Constructor
        public CharactersPage()
        {
            InitializeComponent();

            //Establish the Binding Context
            BindingContext = _viewModel = CharactersViewModel.Instance;
        }
Example #4
0
        public void ViewModel_CharactersViewModel_LoadDataCommand_With_IsBusy_Should_Skip()
        {
            MockForms.Init();

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

            myData.ForceDataRefresh();

            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;
            myData.ForceDataRefresh();

            // Validate the controller can stand up and has a Title
            Assert.AreEqual(Expected, Actual, TestContext.CurrentContext.Test.Name);
        }
Example #5
0
        public override void OnCreate(Bundle savedInstanceState)
        {
            base.OnCreate(savedInstanceState);

            _viewModel = ViewModelProviders.Of(this).Get(DependencyLocator.Current.CreateCharactersViewModel);
            _viewModel.ViewDidLoad();
        }
Example #6
0
        public async Task ViewModel_CharactersViewModel_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 CharactersViewModel();
            var myData      = DefaultModels.CharacterDefault();
            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 <IActionResult> Index(int type, long id)
        {
            var membershipType = (BungieMembershipType)type;

            _logger.LogInformation($"{membershipType}/{id}");

            var accessToken = _contextAccessor.HttpContext.GetTokenAsync("access_token");

            var model = new CharactersViewModel(membershipType, id);

            var profileResponse = await _destiny2.GetProfile(await accessToken, membershipType, id, DestinyComponentType.Characters);

            if (profileResponse == null)
            {
                var url = Url.RouteUrl("AccountIndex");
                return(Redirect(url));
            }

            var classDefTasks = profileResponse.Characters.Data.Select(item => _manifest.LoadClass(item.Value.ClassHash));

            var classDefs = await Task.WhenAll(classDefTasks);

            var characters = profileResponse.Characters.Data.Zip(classDefs,
                                                                 (item, classDef) => (id: item.Key, characters: item.Value, classDef: classDef));

            foreach (var(characterId, character, classDef) in characters)
            {
                model.Characters.Add(new Character(characterId, character, classDef, _bungie.BaseUrl));
            }

            return(View(model));
        }
        private void Filter_Click(object sender, RoutedEventArgs e)
        {
            Grid parentGrid  = (Grid)((Button)sender).Parent;
            int  genderState = ((ComboBox)parentGrid.FindName("GenderCombo")).SelectedIndex;
            int  aliveState  = ((ComboBox)parentGrid.FindName("AliveCombo")).SelectedIndex;

            CharactersViewModel.LoadFilteredPage(genderState, aliveState);
        }
Example #9
0
        public IActionResult Index()
        {
            CharactersViewModel model = new CharactersViewModel();

            model.hero = new HeroModel();

            return(View());
        }
 public CharactersView()
 {
     vm          = new CharactersViewModel();
     DataContext = vm;
     InitializeComponent();
     SavedText.Text       = "Loading";
     SavedText.Visibility = Visibility.Visible;
 }
Example #11
0
        public CharactersPage()
        {
            InitializeComponent();

            BindingContext = _viewModel = DependencyService.Resolve <CharactersViewModel>();

            _viewModel.Navigation = Navigation;
        }
Example #12
0
        public void ViewModel_CharactersViewModel_Instantiate_Should_Pass()
        {
            MockForms.Init();

            var Actual = new CharactersViewModel();

            // Validate the controller can stand up and has a Title
            Assert.AreEqual("Character List", Actual.Title, TestContext.CurrentContext.Test.Name);
        }
 private void First_Click(object sender, RoutedEventArgs e)
 {
     if (CharactersViewModel.Buttons.First == null)
     {
     }
     else
     {
         CharactersViewModel.LoadPage(CharactersViewModel.Buttons.First);
     }
 }
        public async Task <IActionResult> MyCharacters()
        {
            var user = await GetCurrentUserAsync();

            List <Character> characters = _repository.GetCharacters(user.Id);

            CharactersViewModel viewModel = _viewModelFactory.CreateNew <CharactersViewModel>(characters);

            return(View("MyCharacters", viewModel));
        }
Example #15
0
        public IActionResult BeginGame(CharactersViewModel model)
        {
            model.alien = new AlienModel();

            //Default Values
            model.alien.alienName    = "Patrick";
            model.alien.healthPoints = 1;
            model.hero.heroLives     = 3;



            return(View("Characters", ChangeEnemy(model)));
        }
Example #16
0
        public void ViewModel_CharactersViewModel_DataSet_Should_Be_Valid()
        {
            MockForms.Init();

            var myData = new CharactersViewModel();
            var myLoad = myData.LoadDataCommand;

            var Actual   = myData.Dataset;
            var Expected = myData.Dataset;

            // Validate the controller can stand up and has a Title
            Assert.AreEqual(Expected, Actual, TestContext.CurrentContext.Test.Name);
        }
Example #17
0
        public override void ViewDidLoad()
        {
            base.ViewDidLoad();

            _viewModel = DependencyLocator.Current.CreateCharactersViewModel();
            _viewModel.ViewDidLoad();

            var source = new ObservingPlainTableViewSource <CharacterCellViewModel>(_viewModel.Characters, BindCharacterTableViewCell, nameof(CharacterTableViewCell));

            source.WillDisplayCellDelegate = WillDisplayCell;
            TableView.Source = source;

            SetBindings();
        }
Example #18
0
        public void ViewModel_CharactersViewModel_LoadDataCommand_Should_Pass()
        {
            MockForms.Init();

            var myData = new CharactersViewModel();

            myData.ForceDataRefresh();

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

            // Validate the controller can stand up and has a Title
            Assert.AreEqual(Expected, Actual, TestContext.CurrentContext.Test.Name);
        }
Example #19
0
        public IActionResult Index()
        {
            CharactersViewModel model = new CharactersViewModel();

            //Get the names of the players that won this game
            using (var context = new EFCoreGameWebContext())
            {
                model.scoreboard = context.ScoreBoards.ToList();
            }

            model.hero = new HeroModel();

            return(View(model));
        }
Example #20
0
        public void ViewModel_CharactersViewModel_SetNeedsRefresh_True_Should_Be_True()
        {
            MockForms.Init();

            var myData = new CharactersViewModel();

            myData.SetNeedsRefresh(true);

            var Actual   = myData.NeedsRefresh();
            var Expected = true;

            // Validate the controller can stand up and has a Title
            Assert.AreEqual(Expected, Actual, TestContext.CurrentContext.Test.Name);
        }
Example #21
0
        public IActionResult Index()
        {
            CharactersViewModel model = new CharactersViewModel();

            using (var context = new EFCoreGameWebContext())
            {
                model.scoreBoard = context.ScoreBoards.ToList();
            }

            model.hero = new HeroModel();



            return(View(model));
        }
        public async Task <IActionResult> All(string userId = null)
        {
            var user = await GetCurrentUserAsync();

            if (user != null && user.Id == userId)
            {
                return(RedirectToAction("MyCharacters"));
            }

            List <Character> characters = _repository.GetCharacters(userId);

            CharactersViewModel viewModel = _viewModelFactory.CreateNew <CharactersViewModel>(characters);

            return(View("AllCharacters", viewModel));
        }
Example #23
0
        public void ViewModel_BaseViewModel_OnPropertyChange_Should_Pass()
        {
            MockForms.Init();

            var viewModel = new CharactersViewModel();

            NotifyPropertyChangedTester tester = new NotifyPropertyChangedTester(viewModel);

            Assert.AreEqual(0, tester.Changes.Count, "First " + TestContext.CurrentContext.Test.Name);

            viewModel.Title = "Title";

            Assert.AreEqual(1, tester.Changes.Count, "Second " + TestContext.CurrentContext.Test.Name);

            tester.AssertChange(0, "Title");
        }
Example #24
0
        public BuildTeamPage()
        {
            InitializeComponent();

            //make sure that the CharactersViewModel has its data loaded
            if (CharactersViewModel.Instance.Dataset.Count == 0)
            {
                CharactersViewModel.Instance.LoadDataCommand.Execute(null);
            }
            else if (CharactersViewModel.Instance.NeedsRefresh())
            {
                CharactersViewModel.Instance.LoadDataCommand.Execute(null);
            }

            // Set the data binding for the page
            BindingContext = viewModel = CharactersViewModel.Instance;
        }
Example #25
0
        public void ViewModel_CharactersViewModel_LoadCommand_With_Bogus_DataSource_Should_Throw_Skip()
        {
            MockForms.Init();

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

            // Make the data store null, this will fire the Exception, which then skips...
            myData.DataStore = null;
            myData.ForceDataRefresh();

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

            // Validate the controller can stand up and has a Title
            Assert.AreEqual(Expected, Actual, TestContext.CurrentContext.Test.Name);
        }
Example #26
0
        // Constructor loads all the characters for display
        public PickCharacter()
        {
            InitializeComponent();
            partyList             = new List <Character>();
            PartyList.ItemsSource = partyList;
            BindingContext        = _viewModel = CharactersViewModel.Instance;

            // Grabs a copy of the monsters
            _monsterViewModel = MonstersViewModel.Instance;
            if (_monsterViewModel.Dataset.Count == 0)
            {
                _monsterViewModel.LoadDataCommand.Execute(null);
            }
            else if (_monsterViewModel.NeedsRefresh())
            {
                _monsterViewModel.LoadDataCommand.Execute(null);
            }
        }
Example #27
0
        public BuildTeamPage()
        {
            InitializeComponent();
            Data = new Creature
            {
                Name       = "Character name",
                Id         = Guid.NewGuid().ToString(),
                Type       = 0,
                Level      = 1,
                XP         = 0,
                MaxHealth  = 10,
                CurrHealth = 10,
                Alive      = true,
            };

            _viewModel     = new CreatureDetailViewModel(Data);
            BindingContext = viewModel = CharactersViewModel.Instance;
            //CharacterPicker1.SelectedIndex = 0;
        }
Example #28
0
        //Constructor
        public BattlePage(CharactersViewModel Data)
        {
            charactersViewModel = Data;
            InitializeComponent();
            monsterViewModel = MonstersViewModel.Instance;

            // _viewModel = GameEngineViewModel.Instance;
            _viewModel          = new GameEngineViewModel();
            _viewModel.gameOver = false;
            _viewModel.gameEngine.ClearDialogCache();

            _viewModel.magicRevive             = true;
            _viewModel.BattleScore.AutoBattle  = false;
            _viewModel.gameEngine.currentRound = 1;
            _viewModel.GenerateNewMonsters();
            _viewModel.MoveFirstCreature(charactersViewModel);
            _viewModel.gameEngine.ConsoleDialog1 = "";
            BindingContext = _viewModel;
        }
Example #29
0
        public IActionResult FightEnemy(CharactersViewModel model)
        {
            /*
             * Now I can capture the weapon value and the enemy.
             * based on the name of the enemy, I can reduce it's health
             * based on the points.
             */

            if (Convert.ToInt32(model.selectedWeapon) > 100)
            {
                int enemy = 1;
                model.gameStatus = "You are a hero!";
                switch (model.alien.alienName)
                {
                case "Slimey":
                    enemy = 2;
                    break;

                case "Anna":
                    enemy = 3;
                    break;

                case "Gaga":
                    enemy = 1;
                    break;

                default:
                    break;
                }
                //You have to move on to the next enemy
                return(RedirectToAction("Characters", new { enemy = enemy }));
            }
            else
            {
                model.gameStatus = "You have died! Game over!";
            }

            return(View(model));
        }
Example #30
0
        public IActionResult BeginGame(CharactersViewModel model)
        {
            //get names of the players thatwon thet game



            model.alien = new AlienModel();


            //Default Values


            model.alien.alienName    = "Patrick";
            model.alien.healthPoints = 1;
            model.hero.heroLives     = 3;

            model.hero.timePlayed = DateTime.Now;



            return(View("Characters", ChangeEnemy(model)));
        }