private void OnTestExecuted(object sender, EventArgs <TestResult> e) { //Update test item view model and state groups var testItem = TestSolution.FindChild(e.Value.Method); if (testItem != null) { testItem.Result.Results.Add(e.Value); testItem.State = testItem.Result.Results.Max(p => p.Outcome); _testsExecuted++; var resultItem = testItem.CreateResultViewModel(e.Value); var stateGroup = StateGroups.FirstOrDefault(p => p.State == resultItem.State); if (stateGroup == null) { stateGroup = new TestStateGroupViewModel(resultItem.State); StateGroups.OrderedAdd(stateGroup, (a, b) => a.State.CompareTo(b.State)); } stateGroup.Items.OrderedAdd(resultItem, (a, b) => StringComparer.OrdinalIgnoreCase.Compare(a.CodeItem.DisplayName, b.CodeItem.DisplayName)); } //Update test execution state if (e.Value.Method == _testExecuting) { _testExecuting = null; } UpdateTestExecutionState(); }
private async void OnSolutionClosing(object sender, EventArgs e) { if (_testRunner.IsBusy) { await _testRunner.AbortTestsAsync(); } IsSolutionLoaded = false; Update(null as TestSolution); StateGroups.Clear(); }
private void OnTestsStarted(object sender, EventArgs <TestItem> e) { _testsToExecute = e.Value .Flatten(p => p.Children) .Where(p => p.IsTest()) .Count(); _testsExecuted = 0; IsProgressIndeterminate = true; StatusMessage = Resources.InitializingTestRunner; RunnerState = RunnerStates.Testing; TestSolution.ResetAll(); StateGroups.Clear(); _editorContext.ClearLog(); _editorContext.ActivateLog(); }
private static Table CreateTable(int UserChoice, ref List <Game> Games) { Table output = null; List <string[]> AssembledRows = new List <string[]>(); if (UserChoice == 0) { foreach (Game game in Games) { string[] row = new string[] { game.WinningTeam.Name, game.WinningTeam.Year.ToString(), game.WinningTeam.QBToString(), game.WinningTeam.Coach, game.MVP, (game.WinningTeam.Points - game.LosingTeam.Points).ToString() }; AssembledRows.Add(row); } AssembledRows.TrimExcess(); output = new Table("List of all super bowl winners", new string[] { "Winning Team", "Year", "Winning Quaterback(s)", "Winning Coach", "MVP", "Point difference" }, AssembledRows); } else if (UserChoice == 1) { var AttendenceQuery = from game in Games orderby game.Attendance descending select game; Game[] QueryArray = AttendenceQuery.ToArray(); for (int i = 0; i < 5; i++) { Game focusedGame = QueryArray[i]; string[] row = new string[] { focusedGame.Attendance.ToString(), focusedGame.Year.ToString(), focusedGame.WinningTeam.Name, focusedGame.LosingTeam.Name, focusedGame.City, focusedGame.State, focusedGame.Stadium }; AssembledRows.Add(row); } AssembledRows.TrimExcess(); output = new Table("Top five attended super bowls", new string[] { "Attendance", "Year", "Winning Team", "Losing Team", "City", "State", "Stadium" }, AssembledRows); } else if (UserChoice == 2) { var MostHostedQuery = from game in Games group game by game.State into StateGroups orderby StateGroups.Count() descending select StateGroups; var State = MostHostedQuery.First(); foreach (Game game in State) { string[] row = new string[] { game.City, game.State, game.Stadium }; AssembledRows.Add(row); } AssembledRows.TrimExcess(); output = new Table("The state that hosted the most super bowls", new string[] { "Cities", "State", "Stadiums" }, AssembledRows); } else if (UserChoice == 3) { //Generate a list of players who won MVP more than once and output the following: /*Name of MVP * The winning team * The losing team*/ var MVPQuery = from game in Games group game by game.MVP into Players where Players.Count() > 1 orderby Players.Count() descending select Players; foreach (var player in MVPQuery) { foreach (var game in player) { string[] row = new string[] { game.MVP, game.WinningTeam.Name, game.LosingTeam.Name }; AssembledRows.Add(row); } } AssembledRows.TrimExcess(); output = new Table("Players who have won MVP more than once", new string[] { "Name of MVP", "Winning Team", "Losing Team" }, AssembledRows); } else if (UserChoice == 4) { //Which coach lost the most super bowls? var CoachLostQuery = from game in Games group game by game.LosingTeam.Coach into Coaches let Lose = Coaches.Count() orderby Coaches.Count() descending select new { Coaches.Key, Lose }; var MostLostCoach = from coach in CoachLostQuery let Most = CoachLostQuery.First().Lose where coach.Lose == Most select coach; foreach (var coach in MostLostCoach) { string[] row = new string[] { coach.Key, coach.Lose.ToString() }; AssembledRows.Add(row); } AssembledRows.TrimExcess(); output = new Table("Coach(es) that lost the most super bowls", new string[] { "Name of Coach", "Number of Losts" }, AssembledRows); } else if (UserChoice == 5) { //Which coach won the most super bowls? var CoachWinQuery = from game in Games group game by game.WinningTeam.Coach into Coaches let Wins = Coaches.Count() orderby Coaches.Count() descending select new { Coaches.Key, Wins }; var MostWinCoach = from coach in CoachWinQuery let Most = CoachWinQuery.First().Wins where coach.Wins == Most select coach; foreach (var coach in MostWinCoach) { string[] row = new string[] { coach.Key, coach.Wins.ToString() }; AssembledRows.Add(row); } AssembledRows.TrimExcess(); output = new Table("Coach(es) that won the most super bowls", new string[] { "Name of Coach", "Number of Wins" }, AssembledRows); } else if (UserChoice == 6) { //Which team(s) won the most super bowls? var TeamWinQuery = from game in Games group game by game.WinningTeam.Name into Teams let Wins = Teams.Count() orderby Teams.Count() descending select new { Teams.Key, Wins }; var MostWinTeams = from team in TeamWinQuery let Most = TeamWinQuery.First().Wins where team.Wins == Most select team; foreach (var team in MostWinTeams) { string[] row = new string[] { team.Key, team.Wins.ToString() }; AssembledRows.Add(row); } AssembledRows.TrimExcess(); output = new Table("Team that won the most super bowls", new string[] { "Name of Team", "Number of wins" }, AssembledRows); } else if (UserChoice == 7) { //Which team(s) lost the most super bowls? var TeamLoseQuery = from game in Games group game by game.WinningTeam.Name into Teams let Lose = Teams.Count() orderby Teams.Count() descending select new { Teams.Key, Lose }; var MostLoseTeams = from team in TeamLoseQuery let Most = TeamLoseQuery.First().Lose where team.Lose == Most select team; foreach (var team in MostLoseTeams) { string[] row = new string[] { team.Key, team.Lose.ToString() }; AssembledRows.Add(row); } AssembledRows.TrimExcess(); output = new Table("Team that won the most super bowls", new string[] { "Name of Team", "Number of losts" }, AssembledRows); } else if (UserChoice == 8) { //Which Super bowl had the greatest point difference? var ScoreQuery = from game in Games let diff = game.WinningTeam.Points - game.LosingTeam.Points orderby diff descending select new { game.RomanOccurance, WinName = game.WinningTeam.Name, LoseName = game.LosingTeam.Name, game.Date, diff }; var MostDiffTeams = from team in ScoreQuery let Most = ScoreQuery.First().diff where team.diff == Most select team; foreach (var game in MostDiffTeams) { string[] row = new string[] { game.RomanOccurance, game.Date, game.WinName, game.LoseName, game.diff.ToString() }; AssembledRows.Add(row); } AssembledRows.TrimExcess(); output = new Table("Super bowl(s) with the greatest point difference", new string[] { "nth Super Bowl", "Date", "Winning Team", "Losing Team", "Point difference" }, AssembledRows); } else if (UserChoice == 9) { //What is the average attendance of all super bowls? var AttendanceQuery = from game in Games let TotalAttendance = +game.Attendance select TotalAttendance; double averageAttendance = AttendanceQuery.Average(); AssembledRows.Add(new string[] { averageAttendance.ToString() }); AssembledRows.TrimExcess(); output = new Table("", new string[] { "Average Attendance" }, AssembledRows); } else if (UserChoice == 10) { Exit(); } return(output); }