Ejemplo n.º 1
0
        public MovieControllerTests()
        {
            _collections = new List <Library>
            {
                new Library {
                    Id = "id1", Name = "collection1", PrimaryImage = "image1", Type = LibraryType.Movies
                },
                new Library {
                    Id = "id2", Name = "collection2", PrimaryImage = "image2", Type = LibraryType.Movies
                }
            };

            _movieCards = new List <TopCard>
            {
                new TopCard {
                    Title = "The lord of the rings"
                }
            };

            var movieStatistics = new MovieStatistics
            {
                TopCards = _movieCards
            };

            _movieServiceMock = new Mock <IMovieService>();
            _movieServiceMock.Setup(x => x.GetMovieLibraries()).Returns(_collections);
            _movieServiceMock.Setup(x => x.GetStatistics(It.IsAny <List <string> >()))
            .Returns(movieStatistics);

            var _mapperMock = new Mock <IMapper>();

            _mapperMock.Setup(x => x.Map <MovieStatisticsViewModel>(It.IsAny <MovieStatistics>()))
            .Returns(new MovieStatisticsViewModel {
                TopCards = new List <TopCardViewModel> {
                    new TopCardViewModel {
                        Title = "The lord of the rings"
                    }
                }
            });
            _mapperMock.Setup(x => x.Map <IList <LibraryViewModel> >(It.IsAny <List <Library> >())).Returns(
                new List <LibraryViewModel>
            {
                new LibraryViewModel
                {
                    Name         = "collection1",
                    PrimaryImage = "image1",
                    Type         = (int)LibraryType.Movies
                },
                new LibraryViewModel
                {
                    Name         = "collection2",
                    PrimaryImage = "image2",
                    Type         = (int)LibraryType.Movies
                }
            });
            _subject = new MovieController(_movieServiceMock.Object, _mapperMock.Object);
        }
Ejemplo n.º 2
0
        public MovieStatistics CalculateMovieStatistics(List <string> libraryIds)
        {
            var statistics = new MovieStatistics
            {
                Cards     = CalculateCards(libraryIds),
                TopCards  = CalculateTopCards(libraryIds),
                Charts    = CalculateCharts(libraryIds),
                People    = CalculatePeopleStatistics(libraryIds),
                Shorts    = CalculateShorts(libraryIds),
                NoImdb    = CalculateNoImdbs(libraryIds),
                NoPrimary = CalculateNoPrimary(libraryIds),
            };

            var json = JsonConvert.SerializeObject(statistics);

            _statisticsRepository.AddStatistic(json, DateTime.UtcNow, StatisticType.Movie, libraryIds);

            return(statistics);
        }
Ejemplo n.º 3
0
        public MovieStatistics GetStatistics()
        {
            using (var connection = DBTools.GetConnection(MovieDBConnectionName))
            {
                using (var dataSet = connection.ExecuteStoredProcedureDataSet("GetStatistics"))
                {
                    var output         = new MovieStatistics();
                    var actorsPerGenre = dataSet.Tables[0];
                    var actorsPerMovie = dataSet.Tables[1];
                    var moviesPerActor = dataSet.Tables[2];
                    var numberOfActors = dataSet.Tables[3];
                    var numberOfMovies = dataSet.Tables[4];
                    var genres         = dataSet.Tables[5];

                    foreach (DataRow row in actorsPerGenre.Rows)
                    {
                        output.ActorsPerGenre.Add(row.GetString("Genre"), row.GetInt32("# Actors"));
                    }

                    foreach (DataRow row in actorsPerMovie.Rows)
                    {
                        output.ActorsPerMovie.Add(row.GetString("Title"), row.GetInt32("# Actors"));
                    }

                    foreach (DataRow row in moviesPerActor.Rows)
                    {
                        output.MoviesPerActor.Add(row.GetString("Actor"), row.GetInt32("# Movies"));
                    }

                    output.NumberOfActors = numberOfActors.Rows[0].GetInt32("# Actors");
                    output.NumberOfMovies = numberOfMovies.Rows[0].GetInt32("# Movies");

                    foreach (DataRow row in genres.Rows)
                    {
                        output.Genres.Add(row.GetString("Genre"));
                    }

                    return(output);
                }
            }
        }
Ejemplo n.º 4
0
 private void LinkMovieStatistics(MovieResource resource, MovieStatistics moviesStatistics)
 {
     //resource.SizeOnDisk = 0;//TODO: incorporate movie statistics moviesStatistics.SizeOnDisk;
 }