Esempio n. 1
0
        public void MineFandangoTicketSales_Mine()
        {
            var test = new MineFandangoTicketSales();

            var actual = test.Mine();

            Assert.IsNotNull(actual);
            Assert.IsTrue(actual.Any(), "The list was empty.");
        }
Esempio n. 2
0
        public void MineFandangoTicketSales_Totals()
        {
            var test = new MineFandangoTicketSales();

            var actual = test.Mine();

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

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

            WriteMovies(actual);
        }
Esempio n. 3
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);
        }