public void MineToddThatcher_MineAndSolve()
        {
            var fmlMiner    = new MineFantasyMovieLeagueBoxOffice();
            var test        = new MineToddThatcher();
            var moviePicker = new TopMoviePicker(new MovieList());

            var fmlMovies = fmlMiner.Mine();
            var actual    = test.Mine();

            Assert.IsNotNull(actual);
            Assert.IsTrue(actual.Any(), "The list was empty.");

            AssignMovies(fmlMovies, actual);

            Logger.WriteLine("\n==== Todd M Thatcher ====\n");
            WriteMovies(actual.OrderByDescending(item => item.Earnings));

            moviePicker.AddMovies(actual);

            var movieLists = moviePicker.ChooseBest(10);

            Logger.WriteLine("\n==== BONUS ON PICKS ====\n");

            foreach (var movieList in movieLists)
            {
                WriteMovies(movieList.Movies);
                Logger.WriteLine(string.Empty);
            }
        }
Пример #2
0
        public void MineAll_FML_PerfectPick()
        {
            var test = new MineFantasyMovieLeagueBoxOffice();

            var actual = test.Mine();

            Assert.IsNotNull(actual);
            Assert.IsTrue(actual.Any(), "The list was empty.");

            WriteMoviesAndPicks($"==== {test.Name} ====", actual);
        }
        public void MineFantasyMovieLeagueBoxOffice_Mine()
        {
            var test = new MineFantasyMovieLeagueBoxOffice();

            var actual = test.Mine();

            Assert.IsNotNull(actual);
            Assert.IsTrue(actual.Any(), "The list was empty.");

            Logger.WriteLine($"\n==== {test.Name} ====\n");
            Logger.WriteLine($"Contains Estimates: {test.ContainsEstimates}");
            WriteMovies(actual.OrderByDescending(item => item.Earnings));
        }
Пример #4
0
        public void MineVisualRecreation_Mine_GenerateBoxOfficeValues()
        {
            var test  = new MineVisualRecreation();
            var fmlBO = new MineFantasyMovieLeagueBoxOffice();

            var actual = test.Mine();
            var fml    = fmlBO.Mine();

            Assert.IsNotNull(actual);
            Assert.IsTrue(actual.Any(), "The list was empty.");

            var toRemove = new List <IMovie>();

            foreach (var movie in actual)
            {
                var fmlMovie = fml.FirstOrDefault(item => item.Equals(movie) || item.MovieName.EndsWith(movie.MovieName));

                if (fmlMovie == null)
                {
                    // Remove FML movies that are not found (uses Equals() - fuzzy logic)

                    toRemove.Add(movie);
                }
                else
                {
                    movie.MovieName = fmlMovie.MovieName;
                }
            }

            toRemove.ForEach(item => actual.Remove(item));

            var weekendEnding = MovieDateUtil.GameSunday();
            var tab           = "\t";

            Logger.WriteLine($"{tab}{tab}{tab}var weekend = new DateTime({weekendEnding.Year}, {weekendEnding.Month}, {weekendEnding.Day});");
            Logger.WriteLine($"{tab}{tab}{tab}UrlSource = \"{test.UrlSource}\";");
            Logger.WriteLine($"{tab}{tab}{tab}return new List<IMovie>");
            Logger.WriteLine($"{tab}{tab}{tab}{tab}{tab}{tab}{{");

            foreach (var movie in actual.OrderByDescending(item => item.Cost))
            {
                var dayOfWeek = movie.Day.HasValue ? $", Day = DayOfWeek.{movie.Day.ToString()}" : string.Empty;

                Logger.WriteLine($"{tab}{tab}{tab}{tab}{tab}{tab}{tab}{tab}new Movie {{ MovieName = \"{movie.MovieName}\", Earnings = {movie.Earnings}m, WeekendEnding = weekend{dayOfWeek} }},");
            }
            Logger.WriteLine($"{tab}{tab}{tab}{tab}{tab}{tab}}};");
        }
        //----==== PRIVATE ====--------------------------------------------------------------------------

        private List <IMovie> FilterMovies(List <IMovie> toFilter)
        {
            var fmlMiner  = new MineFantasyMovieLeagueBoxOffice();
            var fmlMovies = fmlMiner.Mine();
            var result    = new List <IMovie>();

            foreach (var movie in toFilter)
            {
                var fmlMovie = fmlMovies.FirstOrDefault(item => item.Equals(movie));

                if (fmlMovie != null)
                {
                    movie.Cost = fmlMovie.Cost;
                    result.Add(movie);
                }
            }

            return(result);
        }
        public void MineFantasyMovieLeagueBoxOffice_SetBonusBar()
        {
            const int BAR = 10;

            var test = new MineFantasyMovieLeagueBoxOffice();

            var actual = test.Mine();

            Assert.IsNotNull(actual);
            Assert.IsTrue(actual.Any(), "The list was empty.");

            actual.ForEach(movie => movie.Earnings = movie.Cost * BAR * 1000);

            Logger.WriteLine("\n==== Bonus Bar ====\n");
            foreach (var movie in actual.OrderByDescending(item => item.Cost))
            {
                Logger.WriteLine($"{movie.Earnings:N0}");
            }
        }
Пример #7
0
        public void MineVisualRecreation_Mine()
        {
            var test  = new MineVisualRecreation();
            var fmlBO = new MineFantasyMovieLeagueBoxOffice();

            var actual = test.Mine();
            var fml    = fmlBO.Mine();

            Assert.IsNotNull(actual);
            Assert.IsTrue(actual.Any(), "The list was empty.");

            Logger.WriteLine("\n==== Visual Recreation ====\n");
            WriteMovies(actual.OrderByDescending(item => item.Earnings));

            var toRemove = new List <IMovie>();

            foreach (var movie in actual)
            {
                var fmlMovie = fml.FirstOrDefault(item => item.Equals(movie) || item.MovieName.EndsWith(movie.MovieName));

                if (fmlMovie == null)
                {
                    // Remove FML movies that are not found (uses Equals() - fuzzy logic)

                    toRemove.Add(movie);
                }
                else
                {
                    movie.MovieName = fmlMovie.MovieName;
                }
            }

            Logger.WriteLine("\n==== NOT FOUND ====\n");
            WriteMovies(toRemove.OrderByDescending(item => item.Earnings));

            toRemove.ForEach(item => actual.Remove(item));

            Logger.WriteLine("\n==== FML Matches ====\n");
            WriteMovies(actual.OrderByDescending(item => item.Earnings));
        }
Пример #8
0
        public void MineVisualRecreation_Mine_GenerateEmptyBoxOfficeValues()
        {
            var test = new MineFantasyMovieLeagueBoxOffice();

            var actual = test.Mine();

            Assert.IsNotNull(actual);
            Assert.IsTrue(actual.Any(), "The list was empty.");

            var weekendEnding = actual[0].WeekendEnding;
            var tab           = "\t";
            var urlSource     = "https://twitter.com/VisRecVids/status/1083349593272799232";

            Logger.WriteLine($"{tab}{tab}{tab}var weekend = new DateTime({weekendEnding.Year}, {weekendEnding.Month}, {weekendEnding.Day});");
            Logger.WriteLine($"{tab}{tab}{tab}UrlSource = \"{urlSource}\";");
            Logger.WriteLine($"{tab}{tab}{tab}return new List<IMovie>");
            Logger.WriteLine($"{tab}{tab}{tab}{tab}{tab}{tab}{{");

            foreach (var movie in actual.OrderByDescending(item => item.Cost))
            {
                Logger.WriteLine($"{tab}{tab}{tab}{tab}{tab}{tab}{tab}{tab}new Movie {{ MovieName = \"{movie.MovieName}\", Earnings = 0 * MBAR, WeekendEnding = weekend }},");
            }
            Logger.WriteLine($"{tab}{tab}{tab}{tab}{tab}{tab}}};");
        }
        public void MineVisualRecreation_Mine_GenerateEmptyBoxOfficeValues()
        {
            var test = new MineFantasyMovieLeagueBoxOffice();

            var actual = test.Mine();

            Assert.IsNotNull(actual);
            Assert.IsTrue(actual.Any(), "The list was empty.");

            var weekendEnding = actual[0].WeekendEnding;
            var tab           = "\t";
            var urlSource     = "https://www.boxofficepro.com/weekend-forecast-jordan-peeles-us-poised-for-breakout-debut";

            Logger.WriteLine($"{tab}{tab}{tab}var weekend = new DateTime({weekendEnding.Year}, {weekendEnding.Month}, {weekendEnding.Day});");
            Logger.WriteLine($"{tab}{tab}{tab}UrlSource = \"{urlSource}\";");
            Logger.WriteLine($"{tab}{tab}{tab}return new List<IMovie>");
            Logger.WriteLine($"{tab}{tab}{tab}{tab}{tab}{tab}{{");

            foreach (var movie in actual.OrderByDescending(item => item.Cost))
            {
                Logger.WriteLine($"{tab}{tab}{tab}{tab}{tab}{tab}{tab}{tab}new Movie {{ MovieName = \"{movie.MovieName}\", Earnings = 0 * MBAR, WeekendEnding = weekend }},");
            }
            Logger.WriteLine($"{tab}{tab}{tab}{tab}{tab}{tab}}};");
        }
Пример #10
0
        public void MineFandangoTicketSales_TotalsCompressed()
        {
            var test     = new MineFandangoTicketSales();
            var fmlMiner = new MineFantasyMovieLeagueBoxOffice();

            var actual = test.Mine();

            Assert.IsNotNull(actual);
            Assert.IsTrue(actual.Any(), "The list was empty.");

            var gameMovies = fmlMiner.Mine();

            Assert.IsNotNull(gameMovies);
            Assert.IsTrue(gameMovies.Any(), "The game list was empty.");

            actual = actual.GroupBy(movie => movie.Name)
                     .Select(group => new Movie {
                Name = group.Key, Earnings = group.Sum(item => item.Earnings)
            })
                     .Cast <IMovie>()
                     .OrderByDescending(movie => movie.Earnings)
                     .ToList();

            actual = actual.Where(movie => gameMovies.Contains(movie)).ToList();

            var copy     = new List <IMovie>(actual);
            var toRemove = new List <IMovie>();

            foreach (var movie in actual)
            {
                // Find a simlarly named movie

                var likeMovie = copy.FirstOrDefault(item => item.Equals(movie) && item.MovieName != movie.MovieName);

                if (likeMovie != null && !toRemove.Contains(likeMovie))
                {
                    // Add the totals.

                    movie.Earnings += likeMovie.Earnings;

                    // Remove the movie so it can't be found again.

                    RemoveSameName(copy, likeMovie);
                    toRemove.Add(likeMovie);
                }
            }

            foreach (var movie in toRemove)
            {
                var found = actual.FirstOrDefault(item => item.MovieName == movie.MovieName);

                if (found != null)
                {
                    RemoveSameName(actual, found);
                }
            }

            // Assign the cost for WriteMovies to compute Efficiency.

            var now = DateTime.Now;

            foreach (var movie in actual)
            {
                var found = gameMovies.FirstOrDefault(item => item.Equals(movie));

                if (found != null)
                {
                    movie.Cost          = found.Cost;
                    movie.WeekendEnding = now;
                }
            }

            WriteMovies(actual, true);
        }