Beispiel #1
0
        public void Get_First_MovieId()
        {
            var data = this.CreateMovieTagMethod().AsQueryable();

            var mockSet = new Mock <DbSet <MovieTag> >();

            mockSet.As <IQueryable <MovieTag> >().Setup(m => m.Provider).Returns(data.Provider);
            mockSet.As <IQueryable <MovieTag> >().Setup(m => m.Expression).Returns(data.Expression);
            mockSet.As <IQueryable <MovieTag> >().Setup(m => m.ElementType).Returns(data.ElementType);
            mockSet.As <IQueryable <MovieTag> >().Setup(m => m.GetEnumerator()).Returns(data.GetEnumerator());

            var mockContext = new Mock <FilmCatalogContext>();

            mockContext.Setup(m => m.MovieTags).Returns(mockSet.Object);

            var service = new MovieTagController(mockContext.Object);

            foreach (var movieTag in data)
            {
                service.AddMovieTag(movieTag);
            }

            var movieTags = service.GetAllMovieTags();

            //Assertva count
            Assert.AreEqual(1, movieTags[0].MovieId);
        }
Beispiel #2
0
 public Display(FilmCatalogContext context)
 {
     this.movieTagController = new MovieTagController(context);
     this.tagController      = new TagController(context);
     this.movieController    = new MovieController(context);
     this.genreController    = new GenreController(context);
     this.ratingController   = new RatingController(context);
     this.userController     = new UserController(context);
     this.validate           = new Validate(context);
     this.RegisterOrLogin();
     HandleInput();
 }
Beispiel #3
0
        public void AddMovieTag()
        {
            var mockSet = new Mock <DbSet <MovieTag> >();

            var movieTag    = new MovieTag();
            var mockContext = new Mock <FilmCatalogContext>();

            mockContext.Setup(m => m.MovieTags).Returns(mockSet.Object);

            var service = new MovieTagController(mockContext.Object);

            service.AddMovieTag(movieTag);

            mockSet.Verify(m => m.Add(It.IsAny <MovieTag>()), Times.Once());
            mockContext.Verify(m => m.SaveChanges(), Times.Once());
        }
Beispiel #4
0
        public void GetAllMovieTags_Gives_All_MoviesTags()
        {
            var data = this.CreateMovieTagMethod().AsQueryable();

            var mockSet = new Mock <DbSet <MovieTag> >();

            mockSet.As <IQueryable <MovieTag> >().Setup(m => m.Provider).Returns(data.Provider);
            mockSet.As <IQueryable <MovieTag> >().Setup(m => m.Expression).Returns(data.Expression);
            mockSet.As <IQueryable <MovieTag> >().Setup(m => m.ElementType).Returns(data.ElementType);
            mockSet.As <IQueryable <MovieTag> >().Setup(m => m.GetEnumerator()).Returns(data.GetEnumerator());

            var mockContext = new Mock <FilmCatalogContext>();

            mockContext.Setup(m => m.MovieTags).Returns(mockSet.Object);

            var service   = new MovieTagController(mockContext.Object);
            var movieTags = service.GetAllMovieTags();

            //Assertva count
            Assert.AreEqual(3, movieTags.Count());
        }