Exemple #1
0
        public void CallMoviesRepoDeleteIfMovieExistsAndIsNotDeleted()
        {
            //Arrange
            var called    = 0;
            var guid      = Guid.NewGuid();
            var testMovie = new Movies()
            {
                Id = Guid.NewGuid()
            };

            movies.Setup(x => x.Delete(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 = new Movies()
            {
                IsDeleted = false
            };

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

            //Assert
            Assert.AreEqual(called, 1);
            Assert.AreEqual(result.ErrorMsg, "Saved");
            Assert.AreEqual(result.ResulType, ResultType.Success);
            Assert.AreEqual(sut.GetMovieCount, 1);
        }
Exemple #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.DeleteByid(testMovie.Id);

            //Assert
            Assert.AreEqual(result.ErrorMsg, Constants.MovieNotExists);
            Assert.AreEqual(result.ResulType, ResultType.DoesntExists);
            Assert.AreEqual(sut.GetMovieCount, 1);
        }
Exemple #3
0
        public void CallGetMovieAndReturnChangedResultIfExistsButIsDeleted()
        {
            //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 = true
            };

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

            //Assert
            Assert.AreEqual(result.ErrorMsg, Constants.ErorsDict[ResultType.AlreadyDeleted]);
            Assert.AreEqual(result.ResulType, ResultType.AlreadyDeleted);
            Assert.AreEqual(sut.GetMovieCount, 1);
        }