public void DeleteMovieTest()
        {
            // Arrange
            Movie movie = new Movie()
            {
                MovieId     = Guid.NewGuid().ToString(),
                Title       = "movie-title-delete-movie-test",
                Description = "movie-description-deletemovie-test"
            };

            // Verific sa vad daca filmul este in baza de date
            InsertMovieAndCheckIfMovieExists(movie);
            // Act
            IMoviesRepository moviesRepository = new MoviesRepository(DatabaseHelpers.GetContext());
            IResult <Movie>   deleteResult     = moviesRepository.Delete(movie);

            // Assert
            switch (deleteResult)
            {
            case OK <Movie> ok:
                Assert.AreEqual(movie.MovieId, ok.Result.MovieId);
                Assert.AreEqual(movie.Title, ok.Result.Title);
                Assert.AreEqual(movie.Description, ok.Result.Description);
                break;

            case Error <Movie> error:
                Console.WriteLine(error.Message);
                break;

            default:
                throw new NotImplementedException();
            }
        }
Exemple #2
0
        public async Task PostgreRepo_Delete_Test()
        {
            var repo  = new MoviesRepository(new PostgresDbContext());
            var movie = await repo.GetByIdAsync(1);

            movie.Should().NotBeNull();
            movie.MovieId.Should().Be(1);
            repo.Delete(movie);
            var success = await repo.SaveChangesAsync();

            success.Should().BeTrue();
        }
        public ActionResult MovieDelete(int movieID, string imageAddress)
        {
            string Paath = Server.MapPath("~/Images/");

            imageAddress = imageAddress.Substring(imageAddress.IndexOf("/"));
            FileInfo path = new FileInfo(Paath + imageAddress);

            path.Delete();

            MoviesRepository.Delete(movieID);
            return(RedirectToAction("MoviesList"));
        }
Exemple #4
0
 public bool Delete(int Id)
 {
     return(_movieRepoLib.Delete(Id));
 }