public void ThenTheViewModelGameRowsShouldBeCorrectForGameFilterIdDefaultedToNoWinner(int p0)
        {
            int gameFilterId = p0;

            var gs = GameSpreads
                     .Where(_ => _.Game.GameFilterId == gameFilterId)
                     .OrderBy(_ => _.GameId)
                     .ToList();

            Assert.AreEqual(gs.Count, actual.GameRows.Count, string.Format("GameRows.Count not equal for GameFilterId:{0}", gameFilterId));

            int gameRowId = 0;

            foreach (var item in gs)
            {
                string  expFavoriteTeam = item.FavoriteTeam.TeamLongName;
                string  expUnderdogTeam = item.UnderdogTeam.TeamLongName;
                decimal expSpread       = item.Spread;
                string  expWinnerTeam   = Teams.First(_ => _.TeamLongName == "No Winner").TeamLongName;

                AssertResultsByGameGameRows(gameFilterId, gameRowId, expFavoriteTeam, expUnderdogTeam, expSpread, expWinnerTeam, actual.GameRows[gameRowId]);

                gameRowId++;
            }
        }
        public void GivenTheDataIsLoadedForGameFilterId(int p0)
        {
            gameFilterId = p0;
            users        = Users;
            var teams = Teams;

            gameSpreads        = GameSpreads.Where(_ => _.Game.GameFilterId == gameFilterId).ToList();
            gameResults        = GameResults.Where(_ => _.GameSpread.Game.GameFilterId == gameFilterId).ToList();
            userGameSelections = UserGameSelections.Where(_ => _.GameSpread.Game.GameFilterId == gameFilterId).ToList();
            userGameResults    = UserGameResults.Where(_ => _.UserGameSelection.GameSpread.Game.GameFilterId == gameFilterId).ToList();
            noBetTeam          = Teams.FirstOrDefault(_ => _.TeamLongName == "No Bet");
            noPicksTeam        = Teams.FirstOrDefault(_ => _.TeamLongName == "No Picks");
            noWinnerTeam       = Teams.FirstOrDefault(_ => _.TeamLongName == "No Winner");
        }
        public void BuildResultsByGameViewModelTest_WhenGameSpreadsExistButNoUserGameSelections_ShouldCreateDefaultUserGameSelections()
        {
            int    currentGameFilterId = 10;
            int    userId = 1;
            string viewBagMessageToUser = string.Empty;
            var    users              = Users;
            var    teams              = Teams;
            var    noBetTeam          = Teams.FirstOrDefault(_ => _.TeamLongName == "No Bet");
            var    noPicksTeam        = Teams.FirstOrDefault(_ => _.TeamLongName == "No Picks");
            var    noWinnerTeam       = Teams.FirstOrDefault(_ => _.TeamLongName == "No Winner");
            var    gameSpreads        = GameSpreads.Where(_ => _.Game.GameFilterId == currentGameFilterId).ToList();
            var    gameResults        = new List <GameResult>();        // if there are no user game selections, no need to worry about results
            var    userGameSelections = new List <UserGameSelection>(); // this is what we are testing...when this is empty
            var    userGameResults    = new List <UserGameResult>();    // if there are no user game selections, then there cannot be any user game results

            // expected
            string expectedMessageToUser = "******";

            ResultsByGameController controller = new ResultsByGameController();
            ResultsByGameViewModel  actual     = controller.BuildResultsByGameViewModel(currentGameFilterId, ref viewBagMessageToUser, users, gameSpreads, gameResults, userGameSelections, userGameResults, noBetTeam, noPicksTeam, noWinnerTeam);

            Assert.AreEqual(expectedMessageToUser, viewBagMessageToUser);

            Assert.AreEqual(14, actual.GameRows.Count);

            AssertResultsByGameGameRows("Indianapolis", "Jacksonville", Convert.ToDecimal(-3.00), "Indianapolis", actual.GameRows[0]);
            AssertResultsByGameGameRows("New England", "Buffalo", Convert.ToDecimal(-11.00), "New England", actual.GameRows[1]);
            AssertResultsByGameGameRows("NY Giants", "Cincinnati", Convert.ToDecimal(-4.00), "Cincinnati", actual.GameRows[2]);
            AssertResultsByGameGameRows("Tampa Bay", "San Diego", Convert.ToDecimal(-3.00), "Tampa Bay", actual.GameRows[3]);
            AssertResultsByGameGameRows("Denver", "Carolina", Convert.ToDecimal(-3.50), "Denver", actual.GameRows[4]);
            AssertResultsByGameGameRows("Miami", "Tennessee", Convert.ToDecimal(-6.00), "Tennessee", actual.GameRows[5]);
            AssertResultsByGameGameRows("Baltimore", "Oakland", Convert.ToDecimal(-7.50), "Baltimore", actual.GameRows[6]);
            AssertResultsByGameGameRows("Atlanta", "New Orleans", Convert.ToDecimal(-2.50), "New Orleans", actual.GameRows[7]);
            AssertResultsByGameGameRows("Detroit", "Minnesota", Convert.ToDecimal(-2.00), "Minnesota", actual.GameRows[8]);
            AssertResultsByGameGameRows("Seattle", "NY Jets", Convert.ToDecimal(-6.50), "Seattle", actual.GameRows[9]);
            AssertResultsByGameGameRows("Dallas", "Philadelphia", Convert.ToDecimal(-1.00), "Dallas", actual.GameRows[10]);
            AssertResultsByGameGameRows("San Francisco", "St. Louis", Convert.ToDecimal(-11.50), "No Winner", actual.GameRows[11]);
            AssertResultsByGameGameRows("Chicago", "Houston", Convert.ToDecimal(-1.00), "Houston", actual.GameRows[12]);
            AssertResultsByGameGameRows("Pittsburgh", "Kansas City", Convert.ToDecimal(-12.50), "Pittsburgh", actual.GameRows[13]);

            int gameRowId = 0;

            Assert.AreEqual(4, actual.GameRows[gameRowId].UsersData.Count);
            AssertResultsByGameGameRowUserData(1, "Favorite", "IND", 1, 1, 0, 0, actual.GameRows[gameRowId].UsersData[0]);
            AssertResultsByGameGameRowUserData(2, "Favorite", "IND", 1, 1, 0, 0, actual.GameRows[gameRowId].UsersData[1]);
            AssertResultsByGameGameRowUserData(3, "NoBet", "X", 0, 0, 0, 0, actual.GameRows[gameRowId].UsersData[2]);
            AssertResultsByGameGameRowUserData(4, "Favorite", "IND", 1, 1, 0, 0, actual.GameRows[gameRowId].UsersData[3]);

            gameRowId = 1;
            Assert.AreEqual(4, actual.GameRows[gameRowId].UsersData.Count);
            AssertResultsByGameGameRowUserData(1, "Favorite", "NE", 1, 1, 0, 0, actual.GameRows[gameRowId].UsersData[0]);
            AssertResultsByGameGameRowUserData(2, "Favorite", "NE", 1, 1, 0, 0, actual.GameRows[gameRowId].UsersData[1]);
            AssertResultsByGameGameRowUserData(3, "Favorite", "NE", 1, 1, 0, 0, actual.GameRows[gameRowId].UsersData[2]);
            AssertResultsByGameGameRowUserData(4, "Favorite", "NE", 1, 1, 0, 0, actual.GameRows[gameRowId].UsersData[3]);

            gameRowId = 2;
            Assert.AreEqual(4, actual.GameRows[gameRowId].UsersData.Count);
            AssertResultsByGameGameRowUserData(1, "Favorite", "NYG", 1, -1, 0, 0, actual.GameRows[gameRowId].UsersData[0]);
            AssertResultsByGameGameRowUserData(2, "Favorite", "NYG", 1, -1, 0, 0, actual.GameRows[gameRowId].UsersData[1]);
            AssertResultsByGameGameRowUserData(3, "Underdog", "CIN", 1, 2, 0, 0, actual.GameRows[gameRowId].UsersData[2]);
            AssertResultsByGameGameRowUserData(4, "Favorite", "NYG", 1, -1, 0, 0, actual.GameRows[gameRowId].UsersData[3]);

            gameRowId = 3;
            Assert.AreEqual(4, actual.GameRows[gameRowId].UsersData.Count);
            AssertResultsByGameGameRowUserData(1, "Favorite", "TB", 1, 1, 0, 0, actual.GameRows[gameRowId].UsersData[0]);
            AssertResultsByGameGameRowUserData(2, "Underdog", "SD", 1, -1, 0, 0, actual.GameRows[gameRowId].UsersData[1]);
            AssertResultsByGameGameRowUserData(3, "Underdog", "SD", 4, -4, 0, 0, actual.GameRows[gameRowId].UsersData[2]);
            AssertResultsByGameGameRowUserData(4, "Favorite", "TB", 1, 1, 0, 0, actual.GameRows[gameRowId].UsersData[3]);

            gameRowId = 4;
            Assert.AreEqual(4, actual.GameRows[gameRowId].UsersData.Count);
            AssertResultsByGameGameRowUserData(1, "Favorite", "DEN", 1, 1, 0, 0, actual.GameRows[gameRowId].UsersData[0]);
            AssertResultsByGameGameRowUserData(2, "Favorite", "DEN", 1, 1, 0, 0, actual.GameRows[gameRowId].UsersData[1]);
            AssertResultsByGameGameRowUserData(3, "Favorite", "DEN", 1, 1, 0, 0, actual.GameRows[gameRowId].UsersData[2]);
            AssertResultsByGameGameRowUserData(4, "Favorite", "DEN", 1, 1, 0, 0, actual.GameRows[gameRowId].UsersData[3]);

            gameRowId = 5;
            Assert.AreEqual(4, actual.GameRows[gameRowId].UsersData.Count);
            AssertResultsByGameGameRowUserData(1, "Favorite", "MIA", 1, -1, 0, 0, actual.GameRows[gameRowId].UsersData[0]);
            AssertResultsByGameGameRowUserData(2, "Favorite", "MIA", 1, -1, 0, 0, actual.GameRows[gameRowId].UsersData[1]);
            AssertResultsByGameGameRowUserData(3, "Underdog", "TEN", 1, 2, 0, 0, actual.GameRows[gameRowId].UsersData[2]);
            AssertResultsByGameGameRowUserData(4, "Favorite", "MIA", 1, -1, 0, 0, actual.GameRows[gameRowId].UsersData[3]);

            gameRowId = 6;
            Assert.AreEqual(4, actual.GameRows[gameRowId].UsersData.Count);
            AssertResultsByGameGameRowUserData(1, "Favorite", "BAL", 1, 1, 0, 0, actual.GameRows[gameRowId].UsersData[0]);
            AssertResultsByGameGameRowUserData(2, "Favorite", "BAL", 1, 1, 0, 0, actual.GameRows[gameRowId].UsersData[1]);
            AssertResultsByGameGameRowUserData(3, "Favorite", "BAL", 1, 1, 0, 0, actual.GameRows[gameRowId].UsersData[2]);
            AssertResultsByGameGameRowUserData(4, "Favorite", "BAL", 5, 5, 0, 0, actual.GameRows[gameRowId].UsersData[3]);

            gameRowId = 7;
            Assert.AreEqual(4, actual.GameRows[gameRowId].UsersData.Count);
            AssertResultsByGameGameRowUserData(1, "Favorite", "ATL", 1, -1, 0, 0, actual.GameRows[gameRowId].UsersData[0]);
            AssertResultsByGameGameRowUserData(2, "Underdog", "NO", 5, 10, 0, 0, actual.GameRows[gameRowId].UsersData[1]);
            AssertResultsByGameGameRowUserData(3, "Underdog", "NO", 1, 2, 0, 0, actual.GameRows[gameRowId].UsersData[2]);
            AssertResultsByGameGameRowUserData(4, "Favorite", "ATL", 1, -1, 0, 0, actual.GameRows[gameRowId].UsersData[3]);

            gameRowId = 8;
            Assert.AreEqual(4, actual.GameRows[gameRowId].UsersData.Count);
            AssertResultsByGameGameRowUserData(1, "Favorite", "DET", 1, -1, 0, 0, actual.GameRows[gameRowId].UsersData[0]);
            AssertResultsByGameGameRowUserData(2, "Favorite", "DET", 1, -1, 0, 0, actual.GameRows[gameRowId].UsersData[1]);
            AssertResultsByGameGameRowUserData(3, "Underdog", "MIN", 1, 2, 0, 0, actual.GameRows[gameRowId].UsersData[2]);
            AssertResultsByGameGameRowUserData(4, "Favorite", "DET", 1, -1, 0, 0, actual.GameRows[gameRowId].UsersData[3]);

            gameRowId = 9;
            Assert.AreEqual(4, actual.GameRows[gameRowId].UsersData.Count);
            AssertResultsByGameGameRowUserData(1, "Favorite", "SEA", 1, 1, 0, 0, actual.GameRows[gameRowId].UsersData[0]);
            AssertResultsByGameGameRowUserData(2, "Favorite", "SEA", 1, 1, 0, 0, actual.GameRows[gameRowId].UsersData[1]);
            AssertResultsByGameGameRowUserData(3, "Favorite", "SEA", 1, 1, 0, 0, actual.GameRows[gameRowId].UsersData[2]);
            AssertResultsByGameGameRowUserData(4, "Favorite", "SEA", 1, 1, 0, 0, actual.GameRows[gameRowId].UsersData[3]);

            gameRowId = 10;
            Assert.AreEqual(4, actual.GameRows[gameRowId].UsersData.Count);
            AssertResultsByGameGameRowUserData(1, "Underdog", "PHI", 3, -3, 0, 0, actual.GameRows[gameRowId].UsersData[0]);
            AssertResultsByGameGameRowUserData(2, "Underdog", "PHI", 5, -5, 0, 0, actual.GameRows[gameRowId].UsersData[1]);
            AssertResultsByGameGameRowUserData(3, "Underdog", "PHI", 1, -1, 0, 0, actual.GameRows[gameRowId].UsersData[2]);
            AssertResultsByGameGameRowUserData(4, "Favorite", "DAL", 1, 1, 0, 0, actual.GameRows[gameRowId].UsersData[3]);

            gameRowId = 11;
            Assert.AreEqual(4, actual.GameRows[gameRowId].UsersData.Count);
            AssertResultsByGameGameRowUserData(1, "Favorite", "SF", 3, -3, 0, 0, actual.GameRows[gameRowId].UsersData[0]);
            AssertResultsByGameGameRowUserData(2, "Favorite", "SF", 1, -1, 0, 0, actual.GameRows[gameRowId].UsersData[1]);
            AssertResultsByGameGameRowUserData(3, "Favorite", "SF", 1, -1, 0, 0, actual.GameRows[gameRowId].UsersData[2]);
            AssertResultsByGameGameRowUserData(4, "Favorite", "SF", 1, -1, 0, 0, actual.GameRows[gameRowId].UsersData[3]);

            gameRowId = 12;
            Assert.AreEqual(4, actual.GameRows[gameRowId].UsersData.Count);
            AssertResultsByGameGameRowUserData(1, "Underdog", "HOU", 3, 6, 0, 0, actual.GameRows[gameRowId].UsersData[0]);
            AssertResultsByGameGameRowUserData(2, "Underdog", "HOU", 1, 2, 0, 0, actual.GameRows[gameRowId].UsersData[1]);
            AssertResultsByGameGameRowUserData(3, "Underdog", "HOU", 1, 2, 0, 0, actual.GameRows[gameRowId].UsersData[2]);
            AssertResultsByGameGameRowUserData(4, "Favorite", "CHI", 1, -1, 0, 0, actual.GameRows[gameRowId].UsersData[3]);

            gameRowId = 13;
            Assert.AreEqual(4, actual.GameRows[gameRowId].UsersData.Count);
            AssertResultsByGameGameRowUserData(1, "Favorite", "PIT", 3, 3, 0, 0, actual.GameRows[gameRowId].UsersData[0]);
            AssertResultsByGameGameRowUserData(2, "Favorite", "PIT", 1, 1, 0, 0, actual.GameRows[gameRowId].UsersData[1]);
            AssertResultsByGameGameRowUserData(3, "Favorite", "PIT", 5, 5, 0, 0, actual.GameRows[gameRowId].UsersData[2]);
            AssertResultsByGameGameRowUserData(4, "Favorite", "PIT", 5, 5, 0, 0, actual.GameRows[gameRowId].UsersData[3]);

            Assert.AreEqual(5, actual.Totals[0], "Totals not equal");
            Assert.AreEqual(8, actual.Totals[1], "Totals not equal");
            Assert.AreEqual(13, actual.Totals[2], "Totals not equal");
            Assert.AreEqual(10, actual.Totals[3], "Totals not equal");

            Assert.AreEqual(0, actual.PotentialGains[0], "PotentialGains not equal");
            Assert.AreEqual(0, actual.PotentialGains[1], "PotentialGains not equal");
            Assert.AreEqual(0, actual.PotentialGains[2], "PotentialGains not equal");
            Assert.AreEqual(0, actual.PotentialGains[3], "PotentialGains not equal");

            Assert.AreEqual(0, actual.PotentialLosses[0], "PotentialLosses not equal");
            Assert.AreEqual(0, actual.PotentialLosses[1], "PotentialLosses not equal");
            Assert.AreEqual(0, actual.PotentialLosses[2], "PotentialLosses not equal");
            Assert.AreEqual(0, actual.PotentialLosses[3], "PotentialLosses not equal");
        }