public void GetEligibleKeepersBytes()
        {
            int teams = 10;
            int playersPerTeam = 15;

            var keepers = BuildKeepers(teams, playersPerTeam);

            var writer = new EligibleKeeperWriter(keepers);
            var aResult = writer.ToCsvArray();
            Assert.IsNotNull(aResult);
            Assert.IsTrue(aResult.Length > 4096); // verify memory stream capacity is not exceeded.
        }
        public void GetEligibleKeepersString()
        {
            int teams = 10;
            int playersPerTeam = 15;

            var keepers = BuildKeepers(teams, playersPerTeam);

            var writer = new EligibleKeeperWriter(keepers);
            var sResult = writer.ToCsvString();
            Assert.IsFalse(string.IsNullOrEmpty(sResult));
            Assert.IsTrue(sResult.Length > 0);
        }
        public ActionResult DownloadEligibleKeepers(string leagueKey)
        {
            var leagueTeamPlayers = this.Fantasizer.GetLeagueTeamPlayers(leagueKey);
            var draftResults = this.Fantasizer.GetDraftResults(leagueKey);

            // TODO: This block is mostly duplicated with the TeamController's ListEligibleKeepers action.
            LeagueDao leagueData;
            using (var session = _sessionFactory.OpenSession())
            {
                leagueData = session.Get<LeagueDao>(draftResults.League.Key);
                if (leagueData == null || !leagueData.AllowKeepersFromPriorSeason.HasValue)
                {
                    TempData["UserAlertMessage"] = "You must specify your league's keeper settings before proceeding.";
                    return RedirectToAction("ViewKeeperSettings", "League", new { leagueKey = draftResults.League.Key });
                }
            }

            var keepers = new KeeperAnalyzer(leagueTeamPlayers, draftResults, leagueData.AllowKeepersFromPriorSeason.Value);
            var writer = new EligibleKeeperWriter(keepers.GetEligibleKeepersForLeague(leagueKey));

            return File(writer.ToCsvArray(), "text/csv", "eligible-keepers.csv");
        }