Skip to content

[with Unit Testing] Hey there! MovieReviewAPI is your go-to platform for managing movie reviews through a simple and powerful API built with ASP.NET MVC Core 6.0. With this API, you can perform various operations on different entities like Categories, Countries, Distributers, Movies, Reviews, and Reviewers.

Notifications You must be signed in to change notification settings

YuhanPizza/MovieReviewAPI

Repository files navigation

Welcome to MovieReviewAPI! [with Unit Testing and Integration Testing]๐ŸŒŸ

MovieReviewAPI-Get-Post-Put-Delete

Hey there! MovieReviewAPI is your go-to platform for managing movie reviews through a simple and powerful API built with ASP.NET MVC Core 6.0. With this API, you can perform various operations on different entities like Categories, Countries, Distributers, Movies, Reviews, and Reviewers.

API Endpoints ๐Ÿš€

Category

  • GET /api/Category

    • Retrieve all categories.
  • POST /api/Category

    • Create a new category.
  • GET /api/Category/{categoryId}

    • Retrieve details of a specific category.
  • PUT /api/Category/{categoryId}

    • Update a specific category.
  • DELETE /api/Category/{categoryId}

    • Delete a specific category.
  • GET /api/Category/movie/{categoryId}

    • Retrieve movies associated with a specific category.

Country

  • GET /api/Country

    • Retrieve all countries.
  • POST /api/Country

    • Create a new country.
  • GET /api/Country/{countryId}

    • Retrieve details of a specific country.
  • PUT /api/Country/{countryId}

    • Update a specific country.
  • DELETE /api/Country/{countryId}

    • Delete a specific country.
  • GET /distributer/{distributerId}

    • Retrieve distributors associated with a specific country.

Distributer

  • GET /api/Distributer

    • Retrieve all distributors.
  • POST /api/Distributer

    • Create a new distributor.

GetById

  • GET /api/Distributer/{distributerId}

    • Retrieve details of a specific distributor.
  • PUT /api/Distributer/{distributerId}

    • Update a specific distributor.
  • DELETE /api/Distributer/{distributerId}

    • Delete a specific distributor.
  • GET /api/Distributer/{distributerId}/movie

    • Retrieve movies associated with a specific distributor.

Movie

  • GET /api/Movie
    • Retrieve all movies.

Post-Request

  • POST /api/Movie

    • Create a new movie.
  • GET /api/Movie/{movieId}

    • Retrieve details of a specific movie.
  • PUT /api/Movie/{movieId}

    • Update a specific movie.
  • DELETE /api/Movie/{movieId}

    • Delete a specific movie.
  • GET /api/Movie/{movieId}/rating

    • Retrieve reviews and ratings for a specific movie.

Review

  • GET /api/Review

    • Retrieve all reviews.
  • POST /api/Review

    • Create a new review.
  • GET /api/Review/{reviewId}

    • Retrieve details of a specific review.

UpdateById-Request

  • PUT /api/Review/{reviewId}

    • Update a specific review.
  • DELETE /api/Review/{reviewId}

    • Delete a specific review.
  • GET /api/Review/movie/{movieId}

    • Retrieve reviews for a specific movie.

Reviewer

  • GET /api/Reviewer

    • Retrieve all reviewers.
  • POST /api/Reviewer

    • Create a new reviewer.
  • GET /api/Reviewer/{reviewerId}

    • Retrieve details of a specific reviewer.
  • PUT /api/Reviewer/{reviewerId}

    • Update a specific reviewer.

DeleteById

  • DELETE /api/Reviewer/{reviewerId}

    • Delete a specific reviewer.
  • GET /api/Reviewer/{reviewerId}/reviews

    • Retrieve reviews submitted by a specific reviewer.

Meet the Controllers ๐ŸŽฎ

  1. CategoryController.cs

    • Takes care of everything related to movie categories.
  2. CountryController.cs

    • Handles operations concerning countries.
  3. DistributorController.cs

    • The go-to place for distributor-related operations.
  4. MovieController.cs

    • Your go-to for all things movie-related.
  5. ReviewController.cs

    • The maestro behind movie review operations.
  6. ReviewerController.cs

    • Manages operations related to reviewers.

Behind the Scenes: Data Management ๐Ÿ•น๏ธ

  1. DataContext.cs
    • This is the database maestro, juggling all the data.
    • Houses DbSet properties for categories, countries, distributors, movies, movie categories, reviews, and reviewers.
    • Defines some fancy relationships between entities in the OnModelCreating method.

DTO (Data Transfer Objects) ๐Ÿ“ฆ

  • These are like the messengers, ensuring smooth communication between entities and the outside world.
  1. CategoryDto.cs
  2. CountryDto.cs
  3. DistributorDto.cs
  4. MovieDto.cs
  5. ReviewDto.cs
  6. ReviewerDto.cs

The Little Helper: MappingProfiles.cs ๐Ÿ—บ๏ธ

  • Uses AutoMapper to create maps between entities and DTOs. It's like the translator making sure everyone speaks the same language.

Interfaces: The Contract Keepers ๐Ÿ“œ

  1. ICategoryRepository.cs

  2. ICountryRepository.cs

  3. IDistributorRepository.cs

  4. IMoviesRepository.cs

  5. IReviewRepository.cs

  6. IReviewerRepository.cs

    • These are the rulebooks for data access. Everyone follows their lead.

The Models: The Cool Kids in Town ๐Ÿ•ถ๏ธ

  • These are the main characters, representing what's happening behind the scenes in the database.
  1. Category.cs
  2. Country.cs
  3. Distributor.cs
  4. Movie.cs
  5. MovieCategory.cs
  6. Review.cs
  7. Reviewer.cs

The Squad: Repository Classes ๐Ÿ› ๏ธ

  • The task force implementing all the data access strategies.
  1. CategoryRepository.cs
  2. CountryRepository.cs
  3. DistributorRepository.cs
  4. MoviesRepository.cs
  5. ReviewRepository.cs
  6. ReviewerRepository.cs

Getting Things Started: Dependency Injection in Program.cs โš™๏ธ

  • Configures all the services like controllers, repositories, AutoMapper, and DbContext.
  • Sets up Swagger to make sure everyone knows what's going on.
  • Defines where the database lives using Entity Framework.

Bringing Life to the Party: Seed Data ๐ŸŒฑ

Want to kickstart the party with some seed data? Just run the application with the "seeddata" argument, and you're good to go!

The Cool Middleware ๐ŸŒ

  • Configures Swagger for some snazzy API documentation when you're in development mode.

Feel free to customize and add your own flavor to the API. It's here to make your movie review adventures even more awesome! ๐Ÿฟ๐ŸŽฌ๐Ÿš€

Unit Testing

I use xUnit, FakeItEasy and Fluent Assertions.

  • xUnit: A testing framework that keeps things simple and snappy. ๐Ÿšฆ

  • FakeItEasy: Our backstage pass to mocking โ€“ perfect for faking it 'til you make it! ๐ŸŽญ

  • Fluent Assertions: Making assertions a breeze with a touch of flair. Fluent and fabulous! ๐Ÿ’ฌ

Controllers

Quick Run Down on how I unit tested the Controllers.

Click to play

MovieController: [Passed!]!

  • GetMovies() Passed!
  • CreateMovies() Passed!
  • GetMovie() Passed!
  • GetMovieRaiting() Passed!
  • UpdateMovie() Passed!
  • DeleteMovie() Passed!

CategoryController: [Passed!]!

  • GetCategories() Passed!
  • GetCategory() Passed!
  • GetMovieByCategoryId() Passed!
  • CreateCategory() Passed!
  • UpdateCategory() Passed!
  • DeleteCategory() Passed!

CountryController: [Passed]!

  • GetCountries() Passed!
  • GetCountry() Passed!
  • GetCountryOfAnDistributer() Passed!
  • CreateCountry() Passed!
  • UpdateCountry() Passed!
  • DeleteCountry() Passed!

DistributerController: [Passed]!

  • GetDistributers() Passed!
  • GetDistributer() Passed!
  • GetMovieByDistributerId() Passed!
  • CreateDistributer() Passed!
  • UpdateDistributer() Passed!
  • DeleteDistributer() Passed!

ReviewController: [Passed]!

  • GetReviews() Passed!
  • GetReview() Passed!
  • GetReviewsForAMovie() Passed!
  • CreateReview() Passed!
  • UpdateReview() Passed!
  • DeleteReview() Passed!

ReviewerController: [Passed]!

  • GetReviewers() Passed!
  • GetReviewer() Passed!
  • GetReviewsByAReviewer() Passed!
  • CreateReviewer() Passed!
  • UpdateReviewer() Passed!
  • DeleteReviewer() Passed!

Repository (Integration Tests)

Quick Run Down on how I unit tested the Repositories.

Click to play

MoviesRepositroy: [Passed!]

  • GetMovie(title) Passed!
  • GetMovie(Id) Passed!
  • GetMovieRaiting() Passed!
  • GetMovies() Passed!
  • MovieExists() Passed!
  • UpdateMovie() Passed!

CategoryRepository: [Passed!]

  • CategoryExists() Passed!
  • CreateCategory() Passed!
  • GetCategories() Passed!
  • GetCategory() Passed!

About

[with Unit Testing] Hey there! MovieReviewAPI is your go-to platform for managing movie reviews through a simple and powerful API built with ASP.NET MVC Core 6.0. With this API, you can perform various operations on different entities like Categories, Countries, Distributers, Movies, Reviews, and Reviewers.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages