コード例 #1
0
        public void ThenTheViewModelUserDataForGameFilterIdUserIdShouldBeCorrect(int p0, int p1)
        {
            int gameFilterId = p0;
            int userId       = p1;
            int userDataId   = userId - 1;

            var ugs = UserGameSelections
                      .Where(_ => _.GameSpread.Game.GameFilterId == gameFilterId && _.UserId == userId)
                      .OrderBy(_ => _.GameSpread.GameId)
                      .ToList();

            int gameRowId = 0;

            foreach (var item in ugs)
            {
                var ugr = UserGameResults.FirstOrDefault(_ => _.UserGameSelection.UserGameSelectionId == item.UserGameSelectionId && _.UserGameSelection.UserId == userId);

                string expPick   = item.PickTeam.TeamShortName;
                int    expBet    = item.Bet;
                int    expResult = 0;
                int    expGain   = 0;
                int    expLoss   = 0;
                string expPicked = string.Empty;

                if (item.PickTeamId == item.GameSpread.FavoriteTeamId)
                {
                    expPicked = "Favorite";
                }
                else if (item.PickTeamId == item.GameSpread.UnderdogTeamId)
                {
                    expPicked = "Underdog";
                }
                else if (item.PickTeamId == Teams.First(_ => _.TeamLongName == "No Bet").TeamId)
                {
                    expPicked = "NoBet";
                }
                else
                {
                    expPicked = "NoPicks";
                }

                if (ugr == null)
                {
                    expResult = 0;
                    expGain   = item.Bet;
                    expLoss   = item.Bet * -1;
                }
                else
                {
                    expResult = ugr.BetPoints;
                    expGain   = 0;
                    expLoss   = 0;
                }

                AssertResultsByGameGameRowUserData(gameFilterId, gameRowId, userId, expPicked, expPick, expBet, expResult, expGain, expLoss, actual.GameRows[gameRowId].UsersData[userDataId]);

                gameRowId++;
            }
        }
コード例 #2
0
        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");
        }
コード例 #3
0
        public void ThenTheViewModelTotalRowsShouldBeCorrectForGameFilterIdUserId(int p0, int p1)
        {
            int gameFilterId = p0;
            int userId       = p1;
            int userDataId   = userId - 1;

            var ugs = UserGameSelections
                      .Where(_ => _.GameSpread.Game.GameFilterId == gameFilterId && _.UserId == userId)
                      .OrderBy(_ => _.GameSpread.GameId)
                      .ToList();

            int expTotal = 0;
            int expGain  = 0;
            int expLoss  = 0;

            foreach (var item in ugs)
            {
                var ugr = UserGameResults.FirstOrDefault(_ => _.UserGameSelection.UserGameSelectionId == item.UserGameSelectionId && _.UserGameSelection.UserId == userId);
                var gr  = GameResults.FirstOrDefault(_ => _.GameSpreadId == item.GameSpreadId);

                if (gr.GamePeriod == "F")
                {
                    // then it is a final score, add to total
                    expTotal = expTotal + ugr.BetPoints;
                }
                else
                {
                    // this it is not a final score, so add to potential
                    if (item.PickTeamId == item.GameSpread.FavoriteTeamId)
                    {
                        expGain = expGain + item.Bet;
                    }
                    else if (item.PickTeamId == item.GameSpread.UnderdogTeamId)
                    {
                        expGain = expGain + (item.Bet * 2);  // TODO remove hardcoded *2 and factor in extrapoint
                    }

                    expLoss = expLoss - (item.Bet * -1);
                }
            }

            Assert.AreEqual(expTotal, actual.Totals[userDataId], string.Format("Totals not equalfor GameFilterId:{0} UserId:{1}", gameFilterId, userId));
            Assert.AreEqual(expGain, actual.PotentialGains[0], string.Format("PotentialGains not equalfor GameFilterId:{0} UserId:{1}", gameFilterId, userId));
            Assert.AreEqual(expLoss, actual.PotentialLosses[0], string.Format("PotentialLosses not equalfor GameFilterId:{0} UserId:{1}", gameFilterId, userId));
        }
コード例 #4
0
        public void BuildResultsByGameViewModelTestForGameFilter10WithResults()
        {
            int    currentGameFilterId = 10;
            int    userId = 1;
            string viewBagMessageToUser = string.Empty;
            var    users              = Users;
            var    teams              = Teams;
            var    gameFilters        = GameFilters;
            var    games              = Games;
            var    gameSpreads        = GameSpreads.Where(_ => _.Game.GameFilterId == currentGameFilterId).ToList();
            var    gameResults        = GameResults.Where(_ => _.GameSpread.Game.GameFilterId == currentGameFilterId).ToList();
            var    userGameSelections = UserGameSelections.Where(_ => _.GameSpread.Game.GameFilterId == currentGameFilterId).ToList();
            var    userGameResults    = UserGameResults.Where(_ => _.UserGameSelection.GameSpread.Game.GameFilterId == currentGameFilterId).ToList();
            var    noBetTeam          = Teams.FirstOrDefault(_ => _.TeamLongName == "No Bet");
            var    noPicksTeam        = Teams.FirstOrDefault(_ => _.TeamLongName == "No Picks");
            var    noWinnerTeam       = Teams.FirstOrDefault(_ => _.TeamLongName == "No Winner");

            // expected
            string expectedMessageToUser = "******";
            var    expected = new ResultsByGameViewModel(currentGameFilterId);

            expected.Totals = new List <int> {
                1, 2, 3, 4
            };
            expected.Users = Users;

            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");
        }