public void UpdateMovieWithNullIdTest()
        {
            // Arrange
            Movie movie = new Movie()
            {
                MovieId     = Guid.NewGuid().ToString(),
                Title       = "movie-update-movieid-withnull-test",
                Description = "movie-update-movieid-withnull-test"
            };

            InsertMovieAndCheckIfMovieExists(movie);

            movie = null;

            // Act
            IMoviesRepository moviesRepository = new MoviesRepository(DatabaseHelpers.GetContext());
            IResult <Movie>   updateResult     = moviesRepository.Update(movie);

            // Assert
            switch (updateResult)
            {
            case OK <Movie> ok:
                Assert.Fail();
                break;

            case Error <Movie> error:
                Assert.AreEqual(error.Message, "Movie is required.");
                break;

            default:
                throw new NotImplementedException();
            }
        }
        public void InsertMovieWithNullIdTest()
        {
            // Act
            Movie movie = new Movie()
            {
                MovieId     = null,
                Title       = "movie-ttitle-insert-nullid-test",
                Description = "movie-description-insert-nullid-test"
            };

            // Arrange
            IMoviesRepository moviesRepository = new MoviesRepository(DatabaseHelpers.GetContext());
            var result = moviesRepository.Insert(movie);

            // Assert
            switch (result)
            {
            case OK <Movie> ok:
                Assert.Fail();
                break;

            case Error <Movie> error:
                Assert.AreEqual(error.Message, "Id is null.");
                break;

            default:
                throw new NotImplementedException();
            }
        }
        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();
            }
        }
        public void InsertOkMovieTest()
        {
            // Arrange - creez un film
            Movie movie = new Movie
            {
                MovieId     = Guid.NewGuid().ToString(),
                Title       = "movie-title-insert-ok-test",
                Description = "movie-description-insert-ok-test"
            };

            // Act - folosesc functia pe care vrea sa o testez
            IMoviesRepository moviesRepository = new MoviesRepository(DatabaseHelpers.GetContext());
            IResult <Movie>   result           = moviesRepository.Insert(movie);

            // Assert
            switch (result)
            {
            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();
            }
        }
        public void GetMovieByIdTest()
        {
            // Arrange - creez un film...
            Movie movie = new Movie
            {
                MovieId     = Guid.NewGuid().ToString(),
                Title       = "movie-name-getbyid-test",
                Description = "Movie-description-getbyid-test"
            };

            //....si o inserez in baza de date.
            using (NpgsqlConnection npgsqlConnection = DatabaseHelpers.GetConn())
                InsertMovie(movie, npgsqlConnection);

            // Act - execut functia din repository pe care vreau sa o testez: GetById.
            IMoviesRepository moviesRepository = new MoviesRepository(DatabaseHelpers.GetContext());
            IResult <Movie>   result           = moviesRepository.GetById(movie.MovieId);

            // Assert - in functie de rezultat imi dau seama daca testul a trecut sau a picat

            switch (result)
            {
            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();
            }
        }