Ejemplo n.º 1
0
        private void ViewTeamSchedule()
        {
            try
            {
                if (SelectedTeam == null)
                {
                    TeamSeasonScheduleProfile  = null;
                    TeamSeasonScheduleTotals   = null;
                    TeamSeasonScheduleAverages = null;
                }
                else
                {
                    // Load data from TeamScheduleProfile, TeamScheduleTotals, and TeamScheduleAverages for selected team.
                    var teamName = SelectedTeam.TeamName;
                    var seasonID = (int)WpfGlobals.SelectedSeason;

                    TeamSeasonScheduleProfile = new ReadOnlyCollection <GetTeamSeasonScheduleProfile_Result>(
                        _controlService.GetTeamSeasonScheduleProfile(teamName, seasonID).ToList());

                    TeamSeasonScheduleTotals = new ReadOnlyCollection <GetTeamSeasonScheduleTotals_Result>(
                        _controlService.GetTeamSeasonScheduleTotals(teamName, seasonID).ToList());

                    TeamSeasonScheduleAverages = new ReadOnlyCollection <GetTeamSeasonScheduleAverages_Result>(
                        _controlService.GetTeamSeasonScheduleAverages(teamName, seasonID).ToList());
                }
            }
            catch (Exception ex)
            {
                _sharedService.ShowExceptionMessage(ex);
            }
        }
        public void ViewTeamScheduleCommand_SelectedTeamIsNotNull_SetsTeamSeasonScheduleProfileTotalsAndAveragesToNotNull()
        {
            // Arrange
            // Instantiate class under test.
            var teamName = "Team";

            WpfGlobals.SelectedSeason = 2017;

            var viewModel = new TeamSeasonsControlViewModel(_sharedService, _controlService)
            {
                // Set up needed infrastructure of class under test.
                SelectedTeam = new TeamSeason
                {
                    TeamName = teamName,
                    SeasonID = (int)WpfGlobals.SelectedSeason
                }
            };

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

            // Assert
            A.CallTo(() => _controlService.GetTeamSeasonScheduleProfile(teamName, WpfGlobals.SelectedSeason))
            .MustHaveHappenedOnceExactly();
            Assert.IsInstanceOf <ReadOnlyCollection <GetTeamSeasonScheduleProfile_Result> >(
                viewModel.TeamSeasonScheduleProfile);

            A.CallTo(() => _controlService.GetTeamSeasonScheduleTotals(teamName, WpfGlobals.SelectedSeason))
            .MustHaveHappenedOnceExactly();
            Assert.IsInstanceOf <ReadOnlyCollection <GetTeamSeasonScheduleTotals_Result> >(
                viewModel.TeamSeasonScheduleTotals);

            A.CallTo(() => _controlService.GetTeamSeasonScheduleAverages(teamName, WpfGlobals.SelectedSeason))
            .MustHaveHappenedOnceExactly();
            Assert.IsInstanceOf <ReadOnlyCollection <GetTeamSeasonScheduleAverages_Result> >(
                viewModel.TeamSeasonScheduleAverages);
        }