Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
22 commits
Select commit Hold shift + click to select a range
cd700ea
Delete empty code file
smfeest Apr 9, 2026
b634468
Add cancellation support to queryable extensions
smfeest Apr 6, 2026
b9c4bba
Add cancellation support to comment manager
smfeest Apr 6, 2026
b71d1a3
Add cancellation support to recipe manager
smfeest Apr 7, 2026
2e7d4e2
Add cancellation support to user manager
smfeest Apr 7, 2026
1da1bf1
Add cancellation support to email sender
smfeest Apr 7, 2026
66b7dc0
Add cancellation support to authentication mailer
smfeest Apr 7, 2026
cfc0b10
Add cancellation support to password authentication service
smfeest Apr 8, 2026
d848b26
Add cancellation support to token authentication service
smfeest Apr 8, 2026
1894691
Add cancellation support to authenticate mutation
smfeest Apr 8, 2026
5922e8d
Add cancellation support to comment mutations
smfeest Apr 8, 2026
f9562bf
Add cancellation support to recipe mutations
smfeest Apr 8, 2026
ad561d8
Add cancellation support to user mutations
smfeest Apr 8, 2026
659b005
Add cancellation support to account controller actions
smfeest Apr 8, 2026
d7be00e
Add cancellation support to authentication controller actions
smfeest Apr 9, 2026
8a86789
Add cancellation support to comments controller actions
smfeest Apr 9, 2026
a73f680
Add cancellation support to home controller action
smfeest Apr 9, 2026
41993d0
Add cancellation support to recipes controller actions
smfeest Apr 9, 2026
d7cb4b7
Add cancellation support to users controller actions
smfeest Apr 9, 2026
d9cfe27
Propagate request cancellation token in cookie authentication service
smfeest Apr 10, 2026
ee38390
Propagate cancellation token in cookie authentication events handler
smfeest Apr 10, 2026
70334e2
Propagate request cancellation token in token authentication handler
smfeest Apr 10, 2026
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
30 changes: 22 additions & 8 deletions src/Buttercup.Application.Tests/CommentManagerTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,8 @@ public async Task CreateComment_InsertsCommentAndRevisionAndReturnsId()
await this.DatabaseFixture.InsertEntities(recipe, currentUser);

var attributes = this.BuildCommentAttributes();
var id = await this.commentManager.CreateComment(recipe.Id, attributes, currentUser.Id);
var id = await this.commentManager.CreateComment(
recipe.Id, attributes, currentUser.Id, TestContext.Current.CancellationToken);

using var dbContext = this.DatabaseFixture.CreateDbContext();

Expand Down Expand Up @@ -77,7 +78,10 @@ public async Task CreateComment_ThrowsIfRecipeNotFound()

var exception = await Assert.ThrowsAsync<NotFoundException>(
() => this.commentManager.CreateComment(
recipeId, this.BuildCommentAttributes(), currentUser.Id));
recipeId,
this.BuildCommentAttributes(),
currentUser.Id,
TestContext.Current.CancellationToken));

Assert.Equal($"Recipe/{recipeId} not found", exception.Message);
}
Expand All @@ -91,7 +95,10 @@ public async Task CreateComment_ThrowsIfRecipeSoftDeleted()

var exception = await Assert.ThrowsAsync<SoftDeletedException>(
() => this.commentManager.CreateComment(
recipe.Id, this.BuildCommentAttributes(), currentUser.Id));
recipe.Id,
this.BuildCommentAttributes(),
currentUser.Id,
TestContext.Current.CancellationToken));

Assert.Equal($"Cannot add comment to soft-deleted recipe {recipe.Id}", exception.Message);
}
Expand All @@ -107,7 +114,8 @@ public async Task DeleteComment_SetsSoftDeleteAttributesAndReturnsTrue()
var currentUser = this.modelFactory.BuildUser();
await this.DatabaseFixture.InsertEntities(original, currentUser);

Assert.True(await this.commentManager.DeleteComment(original.Id, currentUser.Id));
Assert.True(await this.commentManager.DeleteComment(
original.Id, currentUser.Id, TestContext.Current.CancellationToken));

using var dbContext = this.DatabaseFixture.CreateDbContext();

Expand All @@ -129,7 +137,8 @@ public async Task DeleteComment_DoesNotUpdateAttributesAndReturnsFalseIfAlreadyS
var currentUser = this.modelFactory.BuildUser();
await this.DatabaseFixture.InsertEntities(original, currentUser);

Assert.False(await this.commentManager.DeleteComment(original.Id, currentUser.Id));
Assert.False(await this.commentManager.DeleteComment(
original.Id, currentUser.Id, TestContext.Current.CancellationToken));

using var dbContext = this.DatabaseFixture.CreateDbContext();

Expand All @@ -146,7 +155,10 @@ await this.DatabaseFixture.InsertEntities(
this.modelFactory.BuildComment(setRecipe: true), currentUser);

Assert.False(
await this.commentManager.DeleteComment(this.modelFactory.NextInt(), currentUser.Id));
await this.commentManager.DeleteComment(
this.modelFactory.NextInt(),
currentUser.Id,
TestContext.Current.CancellationToken));
}

#endregion
Expand All @@ -159,7 +171,8 @@ public async Task HardDeleteComment_HardDeletesCommentAndReturnsTrue()
var comment = this.modelFactory.BuildComment(setRecipe: true);
await this.DatabaseFixture.InsertEntities(comment);

Assert.True(await this.commentManager.HardDeleteComment(comment.Id));
Assert.True(await this.commentManager.HardDeleteComment(
comment.Id, TestContext.Current.CancellationToken));

using var dbContext = this.DatabaseFixture.CreateDbContext();

Expand All @@ -171,7 +184,8 @@ public async Task HardDeleteComment_ReturnsFalseIfRecordNotFound()
{
await this.DatabaseFixture.InsertEntities(this.modelFactory.BuildComment(setRecipe: true));

Assert.False(await this.commentManager.HardDeleteComment(this.modelFactory.NextInt()));
Assert.False(await this.commentManager.HardDeleteComment(
this.modelFactory.NextInt(), TestContext.Current.CancellationToken));
}

#endregion
Expand Down
58 changes: 44 additions & 14 deletions src/Buttercup.Application.Tests/RecipeManagerTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,8 @@ public async Task CreateRecipe_InsertsRecipeAndRevisionAndReturnsId()
this.modelFactory.BuildRecipe(setOptionalAttributes: true));
await this.DatabaseFixture.InsertEntities(currentUser);

var id = await this.recipeManager.CreateRecipe(attributes, currentUser.Id);
var id = await this.recipeManager.CreateRecipe(
attributes, currentUser.Id, TestContext.Current.CancellationToken);

using var dbContext = this.DatabaseFixture.CreateDbContext();

Expand Down Expand Up @@ -86,7 +87,8 @@ public async Task CreateRecipe_AcceptsNullForOptionalAttributes()
this.modelFactory.BuildRecipe(setOptionalAttributes: false));
await this.DatabaseFixture.InsertEntities(currentUser);

var id = await this.recipeManager.CreateRecipe(attributes, currentUser.Id);
var id = await this.recipeManager.CreateRecipe(
attributes, currentUser.Id, TestContext.Current.CancellationToken);

using var dbContext = this.DatabaseFixture.CreateDbContext();

Expand All @@ -112,7 +114,8 @@ public async Task DeleteRecipe_SetsSoftDeleteAttributesAndReturnsTrue()
var currentUser = this.modelFactory.BuildUser();
await this.DatabaseFixture.InsertEntities(original, currentUser);

Assert.True(await this.recipeManager.DeleteRecipe(original.Id, currentUser.Id));
Assert.True(await this.recipeManager.DeleteRecipe(
original.Id, currentUser.Id, TestContext.Current.CancellationToken));

using var dbContext = this.DatabaseFixture.CreateDbContext();

Expand All @@ -133,7 +136,8 @@ public async Task DeleteRecipe_DoesNotUpdateAttributesAndReturnsFalseIfAlreadySo
var currentUser = this.modelFactory.BuildUser();
await this.DatabaseFixture.InsertEntities(original, currentUser);

Assert.False(await this.recipeManager.DeleteRecipe(original.Id, currentUser.Id));
Assert.False(await this.recipeManager.DeleteRecipe(
original.Id, currentUser.Id, TestContext.Current.CancellationToken));

using var dbContext = this.DatabaseFixture.CreateDbContext();

Expand All @@ -148,8 +152,8 @@ public async Task DeleteRecipe_ReturnsFalseIfRecordNotFound()
var currentUser = this.modelFactory.BuildUser();
await this.DatabaseFixture.InsertEntities(this.modelFactory.BuildRecipe(), currentUser);

Assert.False(
await this.recipeManager.DeleteRecipe(this.modelFactory.NextInt(), currentUser.Id));
Assert.False(await this.recipeManager.DeleteRecipe(
this.modelFactory.NextInt(), currentUser.Id, TestContext.Current.CancellationToken));
}

#endregion
Expand All @@ -162,7 +166,8 @@ public async Task HardDeleteRecipe_HardDeletesRecipeAndReturnsTrue()
var recipe = this.modelFactory.BuildRecipe();
await this.DatabaseFixture.InsertEntities(recipe);

Assert.True(await this.recipeManager.HardDeleteRecipe(recipe.Id));
Assert.True(await this.recipeManager.HardDeleteRecipe(
recipe.Id, TestContext.Current.CancellationToken));

using var dbContext = this.DatabaseFixture.CreateDbContext();

Expand All @@ -174,7 +179,8 @@ public async Task HardDeleteRecipe_ReturnsFalseIfRecordNotFound()
{
await this.DatabaseFixture.InsertEntities(this.modelFactory.BuildRecipe());

Assert.False(await this.recipeManager.HardDeleteRecipe(this.modelFactory.NextInt()));
Assert.False(await this.recipeManager.HardDeleteRecipe(
this.modelFactory.NextInt(), TestContext.Current.CancellationToken));
}

#endregion
Expand All @@ -192,7 +198,11 @@ public async Task UpdateRecipe_UpdatesRecipeInsertsRevisionAndReturnsTrue()
this.modelFactory.BuildRecipe(setOptionalAttributes: true));

Assert.True(await this.recipeManager.UpdateRecipe(
original.Id, newAttributes, original.Revision, currentUser.Id));
original.Id,
newAttributes,
original.Revision,
currentUser.Id,
TestContext.Current.CancellationToken));

using var dbContext = this.DatabaseFixture.CreateDbContext();

Expand Down Expand Up @@ -250,7 +260,11 @@ public async Task UpdateRecipe_AcceptsNullForOptionalAttributes()
this.modelFactory.BuildRecipe(setOptionalAttributes: false));

Assert.True(await this.recipeManager.UpdateRecipe(
original.Id, newAttributes, original.Revision, currentUser.Id));
original.Id,
newAttributes,
original.Revision,
currentUser.Id,
TestContext.Current.CancellationToken));

using var dbContext = this.DatabaseFixture.CreateDbContext();
var actual = await dbContext.Recipes.FindAsync(
Expand All @@ -273,7 +287,11 @@ public async Task UpdateRecipe_ReturnsFalseAndDoesNotUpdateIfAttributesAlreadyMa
await this.DatabaseFixture.InsertEntities(original, currentUser);

Assert.False(await this.recipeManager.UpdateRecipe(
original.Id, new(original), original.Revision, currentUser.Id));
original.Id,
new(original),
original.Revision,
currentUser.Id,
TestContext.Current.CancellationToken));

using var dbContext = this.DatabaseFixture.CreateDbContext();
var expected = original with { CreatedByUser = null, ModifiedByUser = null };
Expand All @@ -293,7 +311,11 @@ public async Task UpdateRecipe_ThrowsIfRecordNotFound()
var id = this.modelFactory.NextInt();
var exception = await Assert.ThrowsAsync<NotFoundException>(
() => this.recipeManager.UpdateRecipe(
id, new(this.modelFactory.BuildRecipe()), 0, currentUser.Id));
id,
new(this.modelFactory.BuildRecipe()),
0,
currentUser.Id,
TestContext.Current.CancellationToken));

Assert.Equal($"Recipe/{id} not found", exception.Message);
}
Expand All @@ -307,7 +329,11 @@ public async Task UpdateRecipe_ThrowsIfRecipeSoftDeleted()

var exception = await Assert.ThrowsAsync<SoftDeletedException>(
() => this.recipeManager.UpdateRecipe(
recipe.Id, new(this.modelFactory.BuildRecipe()), recipe.Revision, currentUser.Id));
recipe.Id,
new(this.modelFactory.BuildRecipe()),
recipe.Revision,
currentUser.Id,
TestContext.Current.CancellationToken));

Assert.Equal($"Cannot update soft-deleted recipe {recipe.Id}", exception.Message);
}
Expand All @@ -322,7 +348,11 @@ public async Task UpdateRecipe_ThrowsIfRevisionOutOfSync()
var staleRevision = recipe.Revision - 1;
var exception = await Assert.ThrowsAsync<ConcurrencyException>(
() => this.recipeManager.UpdateRecipe(
recipe.Id, new(this.modelFactory.BuildRecipe()), staleRevision, currentUser.Id));
recipe.Id,
new(this.modelFactory.BuildRecipe()),
staleRevision,
currentUser.Id,
TestContext.Current.CancellationToken));

Assert.Equal(
$"Revision {staleRevision} does not match current revision {recipe.Revision}",
Expand Down
Loading
Loading