Esempio n. 1
0
        public void CallMoviesRepoDeleteIfMovieExistsAndIsDeleted()
        {
            //Arrange
            var called    = 0;
            var guid      = Guid.NewGuid();
            var testMovie = new Movies()
            {
                Id = Guid.NewGuid()
            };
            var movieToAssert = new Movies()
            {
                IsDeleted = true
            };

            movies.Setup(x => x.Update(It.IsAny <Movies>())).Callback(() => { called++; });
            var sut = new MoviesServiceForTest(movies.Object, genresRepo.Object, commentsRepo.Object, userRepo.Object, likesRepo.Object, dislikesRepo.Object, saver.Object);

            sut.MovieToReturn = movieToAssert;

            //Act
            var result = sut.UndoDeleteById(testMovie.Id);

            //Assert
            Assert.AreEqual(movieToAssert.IsDeleted, false);
            Assert.AreEqual(called, 1);
            Assert.AreEqual(result.ErrorMsg, "Saved");
            Assert.AreEqual(result.ResulType, ResultType.Success);
            Assert.AreEqual(sut.GetMovieCount, 1);
        }
Esempio n. 2
0
        public void CallGetMovieAndReturnChangedResultIfDoesntExists()
        {
            //Arrange
            var guid      = Guid.NewGuid();
            var testMovie = new Movies()
            {
                Id = Guid.NewGuid()
            };
            var sut = new MoviesServiceForTest(movies.Object, genresRepo.Object, commentsRepo.Object, userRepo.Object, likesRepo.Object, dislikesRepo.Object, saver.Object);

            sut.MovieToReturn = (Movies)null;

            //Act
            var result = sut.UndoDeleteById(testMovie.Id);

            //Assert
            Assert.AreEqual(result.ErrorMsg, Constants.MovieNotExists);
            Assert.AreEqual(result.ResulType, ResultType.DoesntExists);
            Assert.AreEqual(sut.GetMovieCount, 1);
        }
Esempio n. 3
0
        public void CallGetMovieAndReturnChangedResultIfExistsButIsNotDeleted()
        {
            //Arrange
            var guid      = Guid.NewGuid();
            var testMovie = new Movies()
            {
                Id = Guid.NewGuid()
            };
            var sut = new MoviesServiceForTest(movies.Object, genresRepo.Object, commentsRepo.Object, userRepo.Object, likesRepo.Object, dislikesRepo.Object, saver.Object);

            sut.MovieToReturn = new Movies()
            {
                IsDeleted = false
            };

            //Act
            var result = sut.UndoDeleteById(testMovie.Id);

            //Assert
            Assert.AreEqual(result.ResulType, ResultType.AlreadyExists);
            Assert.AreEqual(sut.GetMovieCount, 1);
        }