Exemplo n.º 1
0
        public void GetTop5ByRating_Should_WorkCorrect()
        {
            var db = new TFContext(DatabaseSimulator());
            var genreServiceMock = new Mock <IGenreServices>();
            var movieService     = new MovieServices(db, genreServiceMock.Object);

            var movie = new Movie()
            {
                Id     = 1,
                Title  = "The Movie",
                Rating = 3.5f
            };
            var secondMovie = new Movie()
            {
                Id     = 2,
                Title  = "The Movies",
                Rating = 5
            };
            var thirdMovie = new Movie()
            {
                Id     = 3,
                Title  = "Movie",
                Rating = 8
            };
            var fourthMovie = new Movie()
            {
                Id     = 4,
                Title  = "Movie",
                Rating = 3
            };
            var fifth = new Movie()
            {
                Id     = 5,
                Title  = "Movie",
                Rating = 1
            };
            var sixth = new Movie()
            {
                Id     = 6,
                Title  = "Movie",
                Rating = 2
            };

            db.Movies.AddRange
                (movie, secondMovie, thirdMovie, fourthMovie, fifth, sixth);
            db.SaveChanges();

            float?ratingOfTheFirstOne = movieService.GetTop5ByRating().First().Rating;
            float?ratingOfTheLastOne  = movieService.GetTop5ByRating().Last().Rating;


            Assert.AreEqual(5, movieService.GetTop5ByRating().Count());
            Assert.AreEqual(8, ratingOfTheFirstOne);
            Assert.AreEqual(2, ratingOfTheLastOne);
        }