Exemple #1
0
        public void ViewRankingsCommand_HappyPath()
        {
            // Arrange
            var viewModel = new RankingsControlViewModel(_sharedService, _controlService);

            // Set up needed infrastructure of class under test.
            var seasonID = (int)WpfGlobals.SelectedSeason;

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

            // Assert
            A.CallTo(() => _controlService.GetRankingsTotalBySeason(seasonID)).MustHaveHappenedOnceExactly();
            Assert.IsInstanceOf <ReadOnlyCollection <GetRankingsTotal_Result> >(viewModel.TotalRankings);

            A.CallTo(() => _controlService.GetRankingsOffensiveBySeason(seasonID)).MustHaveHappenedOnceExactly();
            Assert.IsInstanceOf <ReadOnlyCollection <GetRankingsOffensive_Result> >(viewModel.OffensiveRankings);

            A.CallTo(() => _controlService.GetRankingsDefensiveBySeason(seasonID)).MustHaveHappenedOnceExactly();
            Assert.IsInstanceOf <ReadOnlyCollection <GetRankingsDefensive_Result> >(viewModel.DefensiveRankings);
        }
        private void ViewRankings()
        {
            try
            {
                // Load the rankings grids.
                var seasonID = (int)WpfGlobals.SelectedSeason;

                TotalRankings = new ReadOnlyCollection <GetRankingsTotal_Result>(
                    _controlService.GetRankingsTotalBySeason(seasonID).ToList());

                OffensiveRankings = new ReadOnlyCollection <GetRankingsOffensive_Result>(
                    _controlService.GetRankingsOffensiveBySeason(seasonID).ToList());

                DefensiveRankings = new ReadOnlyCollection <GetRankingsDefensive_Result>(
                    _controlService.GetRankingsDefensiveBySeason(seasonID).ToList());
            }
            catch (Exception ex)
            {
                _sharedService.ShowExceptionMessage(ex);
            }
        }