Skip to content

Automated Testing - Unit #6

@scottkuhl

Description

@scottkuhl

Add automated unit tests example for Movies. These should automatically run on pull requests and require passing.

Movie Entity

  • Year defaults to the current year.

Movie Repository

  • New movies generate a GUID ID.
  • Collection initializes with a composite index on year descending and title ascending.
  • Lists default to sorted by year descending and title ascending.
  • Lists can limit the minimum year and/or maximum year.
  • A not found exception is thrown when a movie is not found.

Movie Functions

  • Mark as integration tests.
  • If a new movie is not valid, throw a bad request object result.
  • If a new movie is valid, add it to the database and return the new movie.
  • If a non-guid is sent into a delete request, throw a bad request result.
  • Delete a movie from the database and return an OK result.
  • If a non-guid is sent into a get request, throw a bad request result.
  • Get a movie from the database and return an OK object result.
  • Get a list of pagable movies.
  • Get a list of virtual movies.
  • If an existing movie is not valid, throw a bad request object result.
  • If an existing movie is valid, update it in the database and return the updated movie.

Movie Admin Edit

  • Delete a movie only after confirmation.
  • Add a new movie.
  • Update a movie.

Movie List Edit

  • Get a list of movies.
  • Search for movies.
  • Navigate to the second page of movies.
  • Delete a movie.

Movies Page

  • Get a list of movies.

Movie HTTP Service

  • Create a movie.
  • Delete a movie.
  • Get a movie.
  • Get a list of pagable movies.
  • Get a list of virtual movies.
  • Update a movie.

Movie Model

  • Poster is limited to 2048 characters.
  • Poster must be a valid URL.
  • Summary input is sanitized.
  • Title is required.
  • Title is limited to 200 characters.
  • Year is required.
  • Year must be between 1890 and 2120.

ref: Testing ASP.NET Core Applications Tutorial - Code Maze Blog
ref: bUnit - a testing library for Blazor components
ref: Testing Blazor Apps & Components: Carl Franklin's Blazor Train Ep 43

Metadata

Metadata

Assignees

No one assigned

    Labels

    help wantedExtra attention is needed

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions