예제 #1
0
        public async void GetShouldReturnMovies()
        {
            var repository = new MoviesRepository(new MockApi());
            var movies     = await repository.Get();

            Assert.True(movies.Count() == 8);
            Assert.Equal("tt3606756", movies.First().Id);
        }
 public void Verify_Deactivate_Should_SetTheActivePropertyToFalseOnTheEntity()
 {
     // Arrange
     Mock<IDbSet<Movie>> mockSetMovies;
     var mockContext = MoviesMockingSetup.DoMockingSetupForContext(true, out mockSetMovies);
     var repository = new MoviesRepository(mockContext.Object);
     var movies = repository.Get(1);
     // Act
     repository.Deactivate(movies);
     // Assert
     Assert.Equal(false, movies.Active);
 }
        public void Verify_Get_ByKey_Should_ReturnTheCorrectMovie()
        {
            // Arrange
            Mock <IDbSet <Movie> > mockSetMovies;
            var mockContext = MoviesMockingSetup.DoMockingSetupForContext(true, out mockSetMovies);
            var repository  = new MoviesRepository(mockContext.Object);
            // Act
            var movies = repository.Get("KING-STEPHEN");

            // Assert
            Assert.Equal("/TEST/KING-STEPHEN", movies.ApiDetailUrl);
        }
        public void Verify_Deactivate_Should_SetTheActivePropertyToFalseOnTheEntity()
        {
            // Arrange
            Mock <IDbSet <Movie> > mockSetMovies;
            var mockContext = MoviesMockingSetup.DoMockingSetupForContext(true, out mockSetMovies);
            var repository  = new MoviesRepository(mockContext.Object);
            var movies      = repository.Get(1);

            // Act
            repository.Deactivate(movies);
            // Assert
            Assert.Equal(false, movies.Active);
        }
        public void Verify_Remove_Should_RemoveTheEntityFromTheContext()
        {
            // Arrange
            Mock <IDbSet <Movie> > mockSetMovies;
            var mockContext = MoviesMockingSetup.DoMockingSetupForContext(true, out mockSetMovies);
            var repository  = new MoviesRepository(mockContext.Object);
            var movies      = repository.Get(1);

            // Act
            repository.Remove(movies);
            // Assert
            mockSetMovies.Verify(x => x.Remove((Movie)movies), Times.Once);
        }
        public void Verify_Update_Should_SetTheEntityStateToModified()
        {
            // Arrange
            Mock <IDbSet <Movie> > mockSetMovies;
            var mockContext = MoviesMockingSetup.DoMockingSetupForContext(true, out mockSetMovies);
            var repository  = new MoviesRepository(mockContext.Object);
            var movies      = repository.Get(1);

            movies.ApiDetailUrl = "/TEST";
            // Act
            repository.Update(movies);
            // Assert
            mockContext.Verify(x => x.SetModified(It.IsAny <object>()), Times.Once);
        }
예제 #7
0
        internal Review MapToReview(ReviewDB R)
        {
            if (R == null)
            {
                return(null);
            }
            var MoviesRepo = new MoviesRepository();
            var Mov        = MoviesRepo.Get(R.MovieId);
            var a          = new Person();

            a.Id = R.Author;
            return(new Review()
            {
                Id = R.Id, Author = a, Content = R.Content, Movie = Mov, Score = R.Score, MovieId = Mov.Id
            });
        }
예제 #8
0
 public Movie Get(int Id)
 {
     return(_movieRepoLib.Get(Id));
 }
 public void Verify_Get_ByID_Should_ReturnTheCorrectMovie()
 {
     // Arrange
     Mock<IDbSet<Movie>> mockSetMovies;
     var mockContext = MoviesMockingSetup.DoMockingSetupForContext(true, out mockSetMovies);
     var repository = new MoviesRepository(mockContext.Object);
     // Act
     var movies = repository.Get(1);
     // Assert
                 Assert.Equal("/TEST/KING-STEPHEN", movies.ApiDetailUrl);
 }
 public void Verify_Update_Should_SetTheEntityStateToModified()
 {
     // Arrange
     Mock<IDbSet<Movie>> mockSetMovies;
     var mockContext = MoviesMockingSetup.DoMockingSetupForContext(true, out mockSetMovies);
     var repository = new MoviesRepository(mockContext.Object);
     var movies = repository.Get(1);
     movies.ApiDetailUrl = "/TEST";
     // Act
     repository.Update(movies);
     // Assert
     mockContext.Verify(x => x.SetModified(It.IsAny<object>()), Times.Once);
 }
 public void Verify_Remove_Should_RemoveTheEntityFromTheContext()
 {
     // Arrange
     Mock<IDbSet<Movie>> mockSetMovies;
     var mockContext = MoviesMockingSetup.DoMockingSetupForContext(true, out mockSetMovies);
     var repository = new MoviesRepository(mockContext.Object);
     var movies = repository.Get(1);
     // Act
     repository.Remove(movies);
     // Assert
     mockSetMovies.Verify(x => x.Remove((Movie)movies), Times.Once);
 }
예제 #12
0
 public IEnumerable <Movie> Get()
 {
     return(_repo.Get());
 }
예제 #13
0
        public void GetShouldThrowException()
        {
            var repository = new MoviesRepository(new MockApiError());

            Assert.ThrowsAsync <HttpException>(() => repository.Get());
        }
        public ActionResult <IEnumerable <Movie> > Get()
        {
            var movies = _movies.Get();

            return(movies);
        }