コード例 #1
0
        public void ShowAllGamesCommand_HappyPath()
        {
            // Arrange
            // Instantiate class under test.
            var viewModel = new GamesWindowViewModel(_sharedService, _controlService, _gameFinderWindow);

            // Set up needed infrastructure of class under test.
            var weekCount = 1;

            A.CallTo(() => _controlService.GetWeekCount()).Returns(weekCount);

            // Act
            viewModel.ShowAllGamesCommand.Execute(null);

            // Assert
            #region ViewGames();

            // Load the DataModel's Games table.
            A.CallTo(() => _controlService.GetGames((int)WpfGlobals.SelectedSeason, null, null))
            .MustHaveHappenedOnceExactly();

            Assert.IsInstanceOf <ReadOnlyCollection <Game> >(viewModel.Games);
            Assert.IsNull(viewModel.SelectedGame);

            A.CallTo(() => _controlService.GetWeekCount()).MustHaveHappenedOnceExactly();

            Assert.AreEqual(weekCount, viewModel.Week);

            #endregion ViewGames();

            Assert.IsFalse(viewModel.IsFindGameFilterApplied);
            Assert.IsFalse(viewModel.IsGamesReadOnly);
            Assert.IsFalse(viewModel.IsShowAllGamesEnabled);
            Assert.IsNull(viewModel.SelectedGame);
        }
コード例 #2
0
        private void ViewGames()
        {
            try
            {
                // Load the DataModel's Games table.
                Games = new ReadOnlyCollection <Game>(_controlService.GetGames((int)WpfGlobals.SelectedSeason).ToList());

                SelectedGame = null;

                OnMoveFocus("GuestName");

                Week = _controlService.GetWeekCount();
            }
            catch (Exception ex)
            {
                _sharedService.ShowExceptionMessage(ex);
            }
        }