Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,8 @@ public async Task Handle_ShouldPassThrough_Query()

var context = Substitute.For<IAuthorsRepository>();
var handler = new GetAuthorByIdHandler(context);
var token = new CancellationTokenSource().Token;
using var tokenSource = new CancellationTokenSource();
var token = tokenSource.Token;

_ = context.GetAuthorById(Arg.Any<Guid>(), token).Returns(new Author(Guid.Empty, "FirstName", "LastName"));

Expand Down Expand Up @@ -54,7 +55,8 @@ public async Task Handle_ShouldThrowException_DoesNotExist()

var context = Substitute.For<IAuthorsRepository>();
var handler = new GetAuthorByIdHandler(context);
var token = new CancellationTokenSource().Token;
using var tokenSource = new CancellationTokenSource();
var token = tokenSource.Token;

// Act
var exception = Should.Throw<NotFoundException>(async () => await handler.Handle(query, token));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,8 @@ public async Task Handle_ShouldPassThrough_Query()

var context = Substitute.For<IAuthorsRepository>();
var handler = new GetAuthorsHandler(context);
var token = new CancellationTokenSource().Token;
using var tokenSource = new CancellationTokenSource();
var token = tokenSource.Token;

_ = context.GetAuthors(token).Returns([new Author(Guid.Empty, "FirstName", "LastName")]);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,8 @@ public async Task Handle_ShouldPassThrough_Query()

var context = Substitute.For<IMoviesRepository>();
var handler = new GetMovieByIdHandler(context);
var token = new CancellationTokenSource().Token;
using var tokenSource = new CancellationTokenSource();
var token = tokenSource.Token;

_ = context.GetMovieById(Arg.Any<Guid>(), token).Returns(new Movie(Guid.Empty, "Title"));

Expand Down Expand Up @@ -52,7 +53,8 @@ public async Task Handle_ShouldThrowException_DoesNotExist()

var context = Substitute.For<IMoviesRepository>();
var handler = new GetMovieByIdHandler(context);
var token = new CancellationTokenSource().Token;
using var tokenSource = new CancellationTokenSource();
var token = tokenSource.Token;

// Act
var exception = Should.Throw<NotFoundException>(async () => await handler.Handle(query, token));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,8 @@ public async Task Handle_ShouldPassThrough_Query()

var context = Substitute.For<IMoviesRepository>();
var handler = new GetMoviesHandler(context);
var token = new CancellationTokenSource().Token;
using var tokenSource = new CancellationTokenSource();
var token = tokenSource.Token;

_ = context.GetMovies(token).Returns([new Movie(Guid.Empty, "Title")]);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,8 @@ public async Task Handle_ShouldPassThrough_Command()
_ = moviesRepository.MovieExists(default, default).ReturnsForAnyArgs(true);

var handler = new CreateReviewHandler(authorsRepository, moviesRepository, reviewsRepository);
var token = new CancellationTokenSource().Token;
using var tokenSource = new CancellationTokenSource();
var token = tokenSource.Token;

// Act
_ = await handler.Handle(command, token);
Expand Down Expand Up @@ -62,7 +63,8 @@ public async Task Handle_ShouldThrowException_AuthorDoesNotExist()
_ = moviesRepository.MovieExists(default, default).ReturnsForAnyArgs(true);

var handler = new CreateReviewHandler(authorsRepository, moviesRepository, reviewsRepository);
var token = new CancellationTokenSource().Token;
using var tokenSource = new CancellationTokenSource();
var token = tokenSource.Token;

// Act
var exception = Should.Throw<NotFoundException>(async () => await handler.Handle(command, token));
Expand Down Expand Up @@ -93,7 +95,8 @@ public async Task Handle_ShouldThrowException_MovieDoesNotExist()
_ = moviesRepository.MovieExists(default, default).ReturnsForAnyArgs(false);

var handler = new CreateReviewHandler(authorsRepository, moviesRepository, reviewsRepository);
var token = new CancellationTokenSource().Token;
using var tokenSource = new CancellationTokenSource();
var token = tokenSource.Token;

// Act
var exception = Should.Throw<NotFoundException>(async () => await handler.Handle(command, token));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,8 @@ public async Task Handle_ShouldPassThrough_Command()
_ = reviewsRepository.ReviewExists(default, default).ReturnsForAnyArgs(true);

var handler = new DeleteReviewHandler(reviewsRepository);
var token = new CancellationTokenSource().Token;
using var tokenSource = new CancellationTokenSource();
var token = tokenSource.Token;

// Act
_ = await handler.Handle(command, token);
Expand All @@ -41,7 +42,8 @@ public async Task Handle_ShouldThrowException_ReviewDoesNotExist()
_ = reviewsRepository.ReviewExists(default, default).ReturnsForAnyArgs(false);

var handler = new DeleteReviewHandler(reviewsRepository);
var token = new CancellationTokenSource().Token;
using var tokenSource = new CancellationTokenSource();
var token = tokenSource.Token;

// Act
var exception = Should.Throw<NotFoundException>(async () => await handler.Handle(command, token));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,8 @@ public async Task Handle_ShouldPassThrough_Command()
_ = moviesRepository.MovieExists(default, default).ReturnsForAnyArgs(true);

var handler = new UpdateReviewHandler(authorsRepository, moviesRepository, reviewsRepository);
var token = new CancellationTokenSource().Token;
using var tokenSource = new CancellationTokenSource();
var token = tokenSource.Token;

// Act
_ = await handler.Handle(command, token);
Expand Down Expand Up @@ -67,7 +68,8 @@ public async Task Handle_ShouldThrowException_ReviewDoesNotExist()
_ = moviesRepository.MovieExists(default, default).ReturnsForAnyArgs(true);

var handler = new UpdateReviewHandler(authorsRepository, moviesRepository, reviewsRepository);
var token = new CancellationTokenSource().Token;
using var tokenSource = new CancellationTokenSource();
var token = tokenSource.Token;

// Act
var exception = Should.Throw<NotFoundException>(async () => await handler.Handle(command, token));
Expand Down Expand Up @@ -102,7 +104,8 @@ public async Task Handle_ShouldThrowException_AuthorDoesNotExist()
_ = moviesRepository.MovieExists(default, default).ReturnsForAnyArgs(true);

var handler = new UpdateReviewHandler(authorsRepository, moviesRepository, reviewsRepository);
var token = new CancellationTokenSource().Token;
using var tokenSource = new CancellationTokenSource();
var token = tokenSource.Token;

// Act
var exception = Should.Throw<NotFoundException>(async () => await handler.Handle(command, token));
Expand Down Expand Up @@ -137,7 +140,8 @@ public async Task Handle_ShouldThrowException_MovieDoesNotExist()
_ = moviesRepository.MovieExists(default, default).ReturnsForAnyArgs(false);

var handler = new UpdateReviewHandler(authorsRepository, moviesRepository, reviewsRepository);
var token = new CancellationTokenSource().Token;
using var tokenSource = new CancellationTokenSource();
var token = tokenSource.Token;

// Act
var exception = Should.Throw<NotFoundException>(async () => await handler.Handle(command, token));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,8 @@ public async Task Handle_ShouldPassThrough_Query()

var context = Substitute.For<IReviewsRepository>();
var handler = new GetReviewByIdHandler(context);
var token = new CancellationTokenSource().Token;
using var tokenSource = new CancellationTokenSource();
var token = tokenSource.Token;

_ = context.GetReviewById(Arg.Any<Guid>(), token).Returns(new Review(Guid.Empty, 5));

Expand Down Expand Up @@ -52,7 +53,8 @@ public async Task Handle_ShouldThrowException_DoesNotExist()

var context = Substitute.For<IReviewsRepository>();
var handler = new GetReviewByIdHandler(context);
var token = new CancellationTokenSource().Token;
using var tokenSource = new CancellationTokenSource();
var token = tokenSource.Token;

// Act
var exception = Should.Throw<NotFoundException>(async () => await handler.Handle(query, token));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,8 @@ public async Task Handle_ShouldPassThrough_Query()

var context = Substitute.For<IReviewsRepository>();
var handler = new GetReviewsHandler(context);
var token = new CancellationTokenSource().Token;
using var tokenSource = new CancellationTokenSource();
var token = tokenSource.Token;

_ = context.GetReviews(token).Returns([new Review(Guid.Empty, 5)]);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,8 @@ public async Task Handle_ShouldPassThrough_Query()
var query = new GetVersionQuery();

var handler = new GetVersionHandler();
var token = new CancellationTokenSource().Token;
using var tokenSource = new CancellationTokenSource();
var token = tokenSource.Token;

// Act
var result = await handler.Handle(query, token);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,8 @@ public async Task GetAuthors_ShouldReturn_Authors()
{
// Arrange
var repository = fixture.Repository;
var token = new CancellationTokenSource().Token;
using var tokenSource = new CancellationTokenSource();
var token = tokenSource.Token;

// Act
var result = await repository.GetAuthors(token);
Expand All @@ -32,7 +33,8 @@ public async Task GetAuthorById_ShouldReturn_Author()
{
// Arrange
var repository = fixture.Repository;
var token = new CancellationTokenSource().Token;
using var tokenSource = new CancellationTokenSource();
var token = tokenSource.Token;
var author = fixture.Context.Authors.FirstOrDefault(a => a.FirstName == "One");

// Act
Expand All @@ -52,7 +54,8 @@ public async Task GetAuthorById_ShouldReturn_Null()
{
// Arrange
var repository = fixture.Repository;
var token = new CancellationTokenSource().Token;
using var tokenSource = new CancellationTokenSource();
var token = tokenSource.Token;

// Act
var result = await repository.GetAuthorById(Guid.Empty, token);
Expand All @@ -66,7 +69,8 @@ public async Task AuthorExists_ShouldReturn_True()
{
// Arrange
var repository = fixture.Repository;
var token = new CancellationTokenSource().Token;
using var tokenSource = new CancellationTokenSource();
var token = tokenSource.Token;
var author = fixture.Context.Authors.FirstOrDefault(a => a.FirstName == "One");

// Act
Expand All @@ -81,7 +85,8 @@ public async Task AuthorExists_ShouldReturn_False()
{
// Arrange
var repository = fixture.Repository;
var token = new CancellationTokenSource().Token;
using var tokenSource = new CancellationTokenSource();
var token = tokenSource.Token;

// Act
var result = await repository.AuthorExists(Guid.Empty, token);
Expand All @@ -99,7 +104,8 @@ public async Task GetMovies_ShouldReturn_Movies()
{
// Arrange
var repository = fixture.Repository;
var token = new CancellationTokenSource().Token;
using var tokenSource = new CancellationTokenSource();
var token = tokenSource.Token;

// Act
var result = await repository.GetMovies(token);
Expand All @@ -115,7 +121,8 @@ public async Task GetMovieById_ShouldReturn_Movie()
{
// Arrange
var repository = fixture.Repository;
var token = new CancellationTokenSource().Token;
using var tokenSource = new CancellationTokenSource();
var token = tokenSource.Token;
var movie = fixture.Context.Movies.FirstOrDefault(m => m.Title == "One");

// Act
Expand All @@ -134,7 +141,8 @@ public async Task GetMovieById_ShouldReturn_Null()
{
// Arrange
var repository = fixture.Repository;
var token = new CancellationTokenSource().Token;
using var tokenSource = new CancellationTokenSource();
var token = tokenSource.Token;

// Act
var result = await repository.GetMovieById(Guid.Empty, token);
Expand All @@ -148,7 +156,8 @@ public async Task MovieExists_ShouldReturn_True()
{
// Arrange
var repository = fixture.Repository;
var token = new CancellationTokenSource().Token;
using var tokenSource = new CancellationTokenSource();
var token = tokenSource.Token;
var movie = fixture.Context.Movies.FirstOrDefault(m => m.Title == "One");

// Act
Expand All @@ -163,7 +172,8 @@ public async Task MovieExists_ShouldReturn_False()
{
// Arrange
var repository = fixture.Repository;
var token = new CancellationTokenSource().Token;
using var tokenSource = new CancellationTokenSource();
var token = tokenSource.Token;

// Act
var result = await repository.MovieExists(Guid.Empty, token);
Expand All @@ -186,7 +196,8 @@ public async Task CreateReview_ShouldReturn_NewReviews()
MovieId = fixture.Context.Movies.FirstOrDefault(m => m.Title == "One").Id,
Stars = 5
};
var token = new CancellationTokenSource().Token;
using var tokenSource = new CancellationTokenSource();
var token = tokenSource.Token;

// Act
var result = await fixture.Repository.CreateReview(review.AuthorId, review.MovieId, review.Stars, token);
Expand All @@ -207,7 +218,8 @@ public async Task DeleteReview_ShouldReturn_True()
{
// Arrange
var id = fixture.Context.Reviews.FirstOrDefault(r => r.Stars == 1).Id;
var token = new CancellationTokenSource().Token;
using var tokenSource = new CancellationTokenSource();
var token = tokenSource.Token;

// Act
var result = await fixture.Repository.DeleteReview(id, token);
Expand All @@ -225,7 +237,8 @@ public async Task DeleteReview_ShouldReturn_True()
public async Task DeleteReview_ShouldReturn_False()
{
// Arrange
var token = new CancellationTokenSource().Token;
using var tokenSource = new CancellationTokenSource();
var token = tokenSource.Token;

// Act
var result = await fixture.Repository.DeleteReview(Guid.Empty, token);
Expand All @@ -239,7 +252,8 @@ public async Task GetReviews_ShouldReturn_Reviews()
{
// Arrange
var repository = fixture.Repository;
var token = new CancellationTokenSource().Token;
using var tokenSource = new CancellationTokenSource();
var token = tokenSource.Token;

// Act
var result = await repository.GetReviews(token);
Expand All @@ -255,7 +269,8 @@ public async Task GetReviewById_ShouldReturn_Review()
{
// Arrange
var repository = fixture.Repository;
var token = new CancellationTokenSource().Token;
using var tokenSource = new CancellationTokenSource();
var token = tokenSource.Token;
var review = fixture.Context.Reviews.FirstOrDefault(m => m.Stars == 5);

// Act
Expand All @@ -279,7 +294,8 @@ public async Task GetReviewById_ShouldReturn_Null()
{
// Arrange
var repository = fixture.Repository;
var token = new CancellationTokenSource().Token;
using var tokenSource = new CancellationTokenSource();
var token = tokenSource.Token;

// Act
var result = await repository.GetReviewById(Guid.Empty, token);
Expand All @@ -293,7 +309,8 @@ public async Task ReviewExists_ShouldReturn_True()
{
// Arrange
var repository = fixture.Repository;
var token = new CancellationTokenSource().Token;
using var tokenSource = new CancellationTokenSource();
var token = tokenSource.Token;
var review = fixture.Context.Reviews.FirstOrDefault(m => m.Stars == 5);

// Act
Expand All @@ -308,7 +325,8 @@ public async Task ReviewExists_ShouldReturn_False()
{
// Arrange
var repository = fixture.Repository;
var token = new CancellationTokenSource().Token;
using var tokenSource = new CancellationTokenSource();
var token = tokenSource.Token;

// Act
var result = await repository.ReviewExists(Guid.Empty, token);
Expand All @@ -328,7 +346,8 @@ public async Task UpdateReview_ShouldReturn_True()
MovieId = fixture.Context.Movies.FirstOrDefault(m => m.Title == "Two").Id,
Stars = 4
};
var token = new CancellationTokenSource().Token;
using var tokenSource = new CancellationTokenSource();
var token = tokenSource.Token;

// Act
var result = await fixture.Repository.UpdateReview(review.Id, review.AuthorId, review.MovieId, review.Stars, token);
Expand Down Expand Up @@ -356,7 +375,8 @@ public async Task UpdateReview_ShouldReturn_False()
MovieId = fixture.Context.Movies.FirstOrDefault(m => m.Title == "One").Id,
Stars = 5
};
var token = new CancellationTokenSource().Token;
using var tokenSource = new CancellationTokenSource();
var token = tokenSource.Token;

// Act
var result = await fixture.Repository.UpdateReview(review.Id, review.AuthorId, review.MovieId, review.Stars, token);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,8 @@ public async Task Database_ShouldBe_Configured()
{
// Arrange
var context = fixture.Context;
var token = new CancellationTokenSource().Token;
using var tokenSource = new CancellationTokenSource();
var token = tokenSource.Token;

// Act
var author = await context.Authors
Expand Down
Loading