Skip to content
Open
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
4 changes: 2 additions & 2 deletions .agents/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ This setup starts from EventSourcing.JVM's shared skills, command pointers and s

## Prerequisites

Use Node.js 24 or newer to run the TypeScript hooks and tests directly, without npm dependencies. Application checks need the .NET SDK used by the projects. The local tool manifest in `.config/dotnet-tools.json` pins Fantomas, Ogooreck.Mcp 1.4.0 and the package-skill installer. Run `dotnet tool restore` to install them.
Use Node.js 24 or newer to run the TypeScript hooks and tests directly, without npm dependencies. Application checks need the .NET SDK used by the projects. The local tool manifest in `.config/dotnet-tools.json` pins Fantomas, Ogooreck.Mcp 1.5.0 and the package-skill installer. Run `dotnet tool restore` to install them.

## Skills

Expand Down Expand Up @@ -90,4 +90,4 @@ dotnet dotnet-package-skills install --source Core.Testing/Core.Testing.csproj -
dotnet dotnet-package-skills install --source Core.Testing/Core.Testing.csproj --destination .claude/skills
```

The library and MCP tool are pinned to 1.4.0. Update both together and refresh the installed skills. The setup follows [Ogooreck’s coding-agent documentation](https://github.com/oskardudycz/Ogooreck/blob/dotnet-1.4.0/docs/coding-agents.md).
The library and MCP tool are pinned to 1.5.0. Update both together and refresh the installed skills. The setup follows [Ogooreck’s coding-agent documentation](https://github.com/oskardudycz/Ogooreck/blob/dotnet-1.5.0/docs/coding-agents.md).
2 changes: 1 addition & 1 deletion .agents/skills/.dotnet-package-skills.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
"packages": {
"ogooreck": {
"versions": {
"1.4.0": {
"1.5.0": {
"skills": [
"ogooreck-tests"
]
Expand Down
3 changes: 2 additions & 1 deletion .agents/skills/ogooreck-tests/SKILL.md
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,8 @@ Then lists the expectations of the When step, run in order; the first that fails
| Body with server-generated ids or values captured in Given or When | `Body(ctx => new { ... })`, or a typed record: `Body(ctx => new Cart(ctx.CreatedId(), [], CartStatus.Open, 0))` |
| Custom assertions on a JSON body | `Body<T>(body => ...)` inside `ExpectResponse` |
| Headers | `Location(...)`, `ETag(WeakETag(n))`, `Headers(...)` inside `ExpectResponse` |
| Redirect or HTML page | `RedirectsTo(...)`, `HtmlContaining(...)` inside `ExpectResponse`; redirects aren't followed |
| Cookies | `SetsCookie(name, parts...)` inside `ExpectResponse`: the last `Set-Cookie` of that name contains every part, ignoring case |
| Redirect or HTML page | `RedirectsTo(...)`, `HtmlContaining(...)` inside `ExpectResponse`; `HtmlContaining(ctx => [...])` for server-generated ids or values captured in Given or When; redirects aren't followed |
| Anything else about the response | `Satisfying(response => ...)` inside `ExpectResponse` |
| Rejected request | `ExpectError(status, problemDetails)` |
| Messages the app published | `ExpectPublished(...)`, exact and in order; `ExpectNothingPublished()` |
Expand Down
2 changes: 1 addition & 1 deletion .claude/skills/.dotnet-package-skills.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
"packages": {
"ogooreck": {
"versions": {
"1.4.0": {
"1.5.0": {
"skills": [
"ogooreck-tests"
]
Expand Down
3 changes: 2 additions & 1 deletion .claude/skills/ogooreck-tests/SKILL.md
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,8 @@ Then lists the expectations of the When step, run in order; the first that fails
| Body with server-generated ids or values captured in Given or When | `Body(ctx => new { ... })`, or a typed record: `Body(ctx => new Cart(ctx.CreatedId(), [], CartStatus.Open, 0))` |
| Custom assertions on a JSON body | `Body<T>(body => ...)` inside `ExpectResponse` |
| Headers | `Location(...)`, `ETag(WeakETag(n))`, `Headers(...)` inside `ExpectResponse` |
| Redirect or HTML page | `RedirectsTo(...)`, `HtmlContaining(...)` inside `ExpectResponse`; redirects aren't followed |
| Cookies | `SetsCookie(name, parts...)` inside `ExpectResponse`: the last `Set-Cookie` of that name contains every part, ignoring case |
| Redirect or HTML page | `RedirectsTo(...)`, `HtmlContaining(...)` inside `ExpectResponse`; `HtmlContaining(ctx => [...])` for server-generated ids or values captured in Given or When; redirects aren't followed |
| Anything else about the response | `Satisfying(response => ...)` inside `ExpectResponse` |
| Rejected request | `ExpectError(status, problemDetails)` |
| Messages the app published | `ExpectPublished(...)`, exact and in order; `ExpectNothingPublished()` |
Expand Down
2 changes: 1 addition & 1 deletion .config/dotnet-tools.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
"rollForward": false
},
"ogooreck.mcp": {
"version": "1.4.0",
"version": "1.5.0",
"commands": [
"ogooreck-mcp"
],
Expand Down
9 changes: 5 additions & 4 deletions Directory.Packages.props
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
<PackageVersion Include="Dapper.Contrib" Version="2.0.78" />
<PackageVersion Include="Elastic.Clients.Elasticsearch" Version="9.5.3" />
<PackageVersion Include="GitHubActionsTestLogger" Version="3.0.5" />
<PackageVersion Include="Htmx.TagHelpers" Version="2.0.0-preview.2" />
<PackageVersion Include="KurrentDB.Client" Version="1.6.1" />
<PackageVersion Include="Marten" Version="9.64.0" />
<PackageVersion Include="Marten.AspNetCore" Version="9.64.0" />
Expand Down Expand Up @@ -56,10 +57,10 @@
<PackageVersion Include="Npgsql.EntityFrameworkCore.PostgreSQL" Version="10.0.3" />
<PackageVersion Include="Npgsql.OpenTelemetry" Version="10.0.3" />
<PackageVersion Include="NSubstitute" Version="6.2.0" />
<PackageVersion Include="Ogooreck" Version="1.4.0" />
<PackageVersion Include="Ogooreck.Kafka" Version="1.4.0" />
<PackageVersion Include="Ogooreck.Marten" Version="1.4.0" />
<PackageVersion Include="Ogooreck.Wolverine" Version="1.4.0" />
<PackageVersion Include="Ogooreck" Version="1.5.0" />
<PackageVersion Include="Ogooreck.Kafka" Version="1.5.0" />
<PackageVersion Include="Ogooreck.Marten" Version="1.5.0" />
<PackageVersion Include="Ogooreck.Wolverine" Version="1.5.0" />
<PackageVersion Include="Open.ChannelExtensions" Version="10.0.0" />
<PackageVersion Include="OpenTelemetry.Exporter.Console" Version="1.20.1" />
<PackageVersion Include="OpenTelemetry.Exporter.OpenTelemetryProtocol" Version="1.20.1" />
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,26 +34,62 @@ public static TestStep GetCart(Guid customerId) =>
Get($"/customers/{customerId}/shopping-carts/current");

public static TestStep ProductsPage(Guid customerId) =>
Get($"/shop/customers/{customerId}/products");
ProductsPage(_ => customerId);

public static TestStep ProductsPage(
Func<StepContext, Guid> customerId,
Action<HttpRequestMessage, StepContext>? loggedIn = null
) =>
Get(ctx => $"/shop/customers/{customerId(ctx)}/products", Options(loggedIn));

public static TestStep CartPage(Guid customerId) =>
Get($"/shop/customers/{customerId}/cart");
CartPage(_ => customerId);

public static TestStep CartPage(
Func<StepContext, Guid> customerId,
Action<HttpRequestMessage, StepContext>? loggedIn = null
) =>
Get(ctx => $"/shop/customers/{customerId(ctx)}/cart", Options(loggedIn));

public static TestStep AddToCartOnPage(Guid customerId, Guid productId, int quantity) =>
Post($"/shop/customers/{customerId}/cart/items",
Form(("productId", productId.ToString()), ("quantity", quantity.ToString())));
AddToCartOnPage(_ => customerId, productId, quantity);

public static TestStep AddToCartOnPage(
Func<StepContext, Guid> customerId,
Guid productId,
int quantity,
Action<HttpRequestMessage, StepContext>? loggedIn = null
) =>
Post(ctx => $"/shop/customers/{customerId(ctx)}/cart/items",
Options(loggedIn, ("productId", productId.ToString()), ("quantity", quantity.ToString())));

public static TestStep RemoveFromCartOnPage(Guid customerId, Guid productId, int quantity, long version) =>
Post($"/shop/customers/{customerId}/cart/items/{productId}/remove",
Form(("quantity", quantity.ToString()), ("version", version.ToString())));
Options(null, ("quantity", quantity.ToString()), ("version", version.ToString())));

public static TestStep CheckOutOnPage(Guid customerId, long version) =>
Post($"/shop/customers/{customerId}/cart/checkout", Form(("version", version.ToString())));
CheckOutOnPage(_ => customerId, version);

public static TestStep CheckOutOnPage(
Func<StepContext, Guid> customerId,
long version,
Action<HttpRequestMessage, StepContext>? loggedIn = null
) =>
Post(ctx => $"/shop/customers/{customerId(ctx)}/cart/checkout",
Options(loggedIn, ("version", version.ToString())));

private static RequestOptions Form(params (string Name, string Value)[] fields) =>
private static RequestOptions Options(
Action<HttpRequestMessage, StepContext>? loggedIn,
params (string Name, string Value)[] fields
) =>
new()
{
Configure = (request, _) => request.Content = new FormUrlEncodedContent(
fields.Select(field => new KeyValuePair<string, string>(field.Name, field.Value)))
Configure = (request, ctx) =>
{
loggedIn?.Invoke(request, ctx);
if (fields.Length > 0)
request.Content = new FormUrlEncodedContent(
fields.Select(field => new KeyValuePair<string, string>(field.Name, field.Value)));
}
};
}
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
using Carts.Api.Tests.Shop;
using Carts.CurrentShoppingCarts;
using Carts.Messaging;
using Ogooreck.API;
Expand All @@ -11,8 +12,6 @@ namespace Carts.Api.Tests.CurrentShoppingCarts;

public abstract class ShoppingCartsApiTests: ApiTest
{
private const string NotImplemented = "Not implemented: shop pages";

private const string IfMatchNeedsTheVersion =
"If-Match must hold the version of the cart you read, such as W/\"2\", from the cart's ETag.";

Expand Down Expand Up @@ -274,8 +273,8 @@ public class CartPages: ShoppingCartsApiTests
public CartPages(ApiFixture fixture) : base(fixture) =>
cart = $"/shop/customers/{customerId}/cart";

[Fact(Skip = NotImplemented)]
public Task TheProductsPageOffersEveryDemoProduct() =>
[Fact]
public Task OpeningTheProductsPage_OffersEveryDemoProduct() =>
API.Given()
.When(ProductsPage(customerId))
.Then([
Expand All @@ -284,51 +283,74 @@ public Task TheProductsPageOffersEveryDemoProduct() =>
HtmlContaining($"action=\"{cart}/items\""))
], ct);

[Fact(Skip = NotImplemented)]
public Task AnEmptyCartSaysSo() =>
[Fact]
public Task OpeningAnEmptyCart_SaysItIsEmpty() =>
API.Given()
.When(CartPage(customerId))
.Then([ExpectResponse(OK, HtmlContaining("Your cart is empty"))], ct);

[Fact(Skip = NotImplemented)]
public Task AddingAProductOnTheProductsPageOpensTheCart() =>
[Fact]
public Task AddingAProductOnTheProductsPage_OpensTheCart() =>
API.Given()
.When(AddToCartOnPage(customerId, tShirt.Id, 1))
.Then([ExpectResponse(Found, RedirectsTo(cart))], ct);

[Fact(Skip = NotImplemented)]
public Task TheCartPageListsTheAddedProductAndOffersCheckout() =>
[Fact]
public Task OpeningTheCartAfterAddingAProduct_ListsItAndOffersCheckout() =>
API.Given(AddToCartOnPage(customerId, tShirt.Id, 1))
.When(CartPage(customerId))
.Then([ExpectResponse(OK, HtmlContaining(tShirt.Name, "Check out"))], ct);

[Fact(Skip = NotImplemented)]
public Task RemovingAProductOnTheCartPageReturnsToTheCart() =>
[Fact]
public Task RemovingAProductOnTheCartPage_ReturnsToTheCart() =>
API.Given(AddToCartOnPage(customerId, tShirt.Id, 1))
.When(RemoveFromCartOnPage(customerId, tShirt.Id, 1, 1))
.Then([ExpectResponse(Found, RedirectsTo(cart))], ct);

[Fact(Skip = NotImplemented)]
public Task RemovingTheLastProductEmptiesTheCart() =>
[Fact]
public Task RemovingTheLastProduct_EmptiesTheCart() =>
API.Given(
AddToCartOnPage(customerId, tShirt.Id, 1),
RemoveFromCartOnPage(customerId, tShirt.Id, 1, 1))
.When(CartPage(customerId))
.Then([ExpectResponse(OK, HtmlContaining("Your cart is empty"))], ct);

[Fact(Skip = NotImplemented)]
public Task CheckingOutOnTheCartPageOpensTheOrderPage() =>
[Fact]
public Task CheckingOutOnTheCartPage_OpensTheOrderPage() =>
API.Given(AddToCartOnPage(customerId, tShirt.Id, 1))
.When(CheckOutOnPage(customerId, 1))
.Then([
ExpectResponse(Found, RedirectsTo($"/shop/customers/{customerId}/orders/{cartId.Tail}"))
], ct);

[Fact(Skip = NotImplemented)]
public Task CheckingOutAfterAPriceChangeReturnsToTheCart() =>
[Fact]
public Task CheckingOutAfterAPriceChange_ReturnsToTheCart() =>
API.Given(AddToCartOnPage(customerId, tShirt.Id, 1), prices.PriceOf(tShirt.Id, 60))
.When(CheckOutOnPage(customerId, 1))
.Then([ExpectResponse(Found, RedirectsTo(cart))], ct);

[Fact]
public Task CheckingOutAfterAPriceChange_AsksToCheckTheNewPrices() =>
API.Given(
prices.PriceOf(shoes, 50),
ShopVisitor.LogsInAs("Marty McFly"),
ShopVisitor.AddsToCart(shoes),
prices.PriceOf(shoes, 60),
ShopVisitor.ChecksOutOnTheCartPage(1))
.When(ShopVisitor.OpensTheCartPage())
.Then([
ExpectResponse(OK,
HtmlContaining("Some prices have changed. Check the new prices and check out again."))
], ct);

[Fact]
public Task CheckingOutAChangedCart_AsksToCheckTheCart() =>
API.Given(
ShopVisitor.LogsInAs("Marty McFly"),
ShopVisitor.AddsToCart(shoes),
ShopVisitor.ChecksOutOnTheCartPage(5))
.When(ShopVisitor.OpensTheCartPage())
.Then([ExpectResponse(OK, HtmlContaining("Your cart has changed. Check it and try again."))], ct);
}

public class ReceivingMessages(ApiFixture fixture): ShoppingCartsApiTests(fixture)
Expand Down
Loading
Loading