Ejemplo n.º 1
0
        public async void AddMovieAsync_Addition_Void()
        {
            var repMock    = new Mock <IMovieRepository>();
            var mapperMock = new Mock <IMapper>();

            var manageMovie = new ManageMoviesService(repMock.Object, mapperMock.Object);

            await manageMovie.AddAsync(movieDTO);

            repMock.Verify(x => x.AddAsync(It.IsAny <Movie>()));
        }
Ejemplo n.º 2
0
        public async void RemoveMovieAsync_Remove_Void()
        {
            var repMock    = new Mock <IMovieRepository>();
            var mapperMock = new Mock <IMapper>();

            var manageMovie = new ManageMoviesService(repMock.Object, mapperMock.Object);

            repMock
            .Setup(x => x.GetByIdAsync(It.IsAny <int>()))
            .Returns(Task.Run(() => movie));

            await manageMovie.RemoveAsync(movie.Id);

            repMock.Verify(x => x.RemoveAsync(It.IsAny <int>()));
        }
Ejemplo n.º 3
0
        public async void AddMovieAsync_Addition_EntityAlreadyExistsException()
        {
            var repMock    = new Mock <IMovieRepository>();
            var mapperMock = new Mock <IMapper>();

            var manageMovie = new ManageMoviesService(repMock.Object, mapperMock.Object);

            repMock
            .Setup(x => x.FindByPredicate(It.IsAny <Func <Movie, bool> >()))
            .Returns(new List <Movie> {
                movie
            });

            await Assert.ThrowsAsync <EntityAlreadyExistsException>(() => manageMovie.AddAsync(movieDTO));
        }