presentation-integration-tests
Skill4 starsChanged 10 days agoMITView on GitHub
How this Web API is tested end to end with WebApplicationFactory - the WebApiApplication host, a private database per test class, overriding settings and services, the JSON helper, asserting problem details, and testing with authentication on and off. Use when writing or fixing a test in tests/Presentation.Tests.Integration.
4 other projects use a version of this, 4 of them edited.
Adopted by
Most recently taken up by
- LeanMeanCleanApps/CleanLambdaFunctionedited, first seen Nov 15, 2026
- LeanMeanCleanApps/CleanGraphQLApiedited, first seen Nov 15, 2026
- LeanMeanCleanApps/CleanMinimalApiedited, first seen Nov 15, 2026
- LeanMeanCleanApps/CleanModelContextProtocoledited, first seen Nov 8, 2026
Other versions4 projects use a version of this.
Word for word · 0
None found.
Edited · 4
- LeanMeanCleanApps/CleanMinimalApi★ 40086% same
- LeanMeanCleanApps/CleanGraphQLApi★ 1315% same
- LeanMeanCleanApps/CleanModelContextProtocol★ 114% same
- LeanMeanCleanApps/CleanLambdaFunction★ 011% same
Wrote their own version · 0
None found.
How matches are found. Word for word: the exact same text. Edited: shares passages with this file (“99% same” means 99% of its five-word phrases also appear here; 10% or more counts). Their own version: similar meaning, or, weakest, the same name. We can’t tell which project had it first. Projects are counted among the 200 most-starred candidates, and mentions are links to the repository we found, up to 50 per site, so both counts are a floor.
In this repository40 other files it gives its agents.
- AGENTS.mdAGENTS.md
- CLAUDE.mdCLAUDE.md
- add-a-use-caseSkill
- api-conventionsSkill
- branches-and-pull-requestsSkill
- cancellationSkill
- ci-for-your-solutionSkill
- ci-pipelineSkill
- clean-architecture-layersSkill
- configuration-and-environmentsSkill
- coverageSkill
- csharp-house-styleSkill
- data-access-ef-coreSkill
- database-migrationsSkill
- docker-and-composeSkill
- docs-and-voiceSkill
- errors-and-exceptionsSkill
- expose-a-use-caseSkill
- family-syncSkill
- health-checksSkill
- integration-testsSkill
- json-serializationSkill
- mapping-with-mapperlySkill
- mediatorSkill
- openapi-and-scalarSkill
- optional-token-authSkill
- packages-and-dependenciesSkill
- pagingSkill
- releasesSkill
- sample-dataSkill
- security-findingsSkill
- serilogSkill
- telemetrySkill
- template-authoringSkill
- test-designSkill
- time-providerSkill
- unit-testsSkill
- validationSkill
- writing-a-skillSkill
- xml-docs-and-openapiSkill
The file
We split this skill into the rules it gives an agent
2 rules. 0 are common, 0 are distinctive, and 2 are very specific to this project.
0
Common
Most of the 4 edited versions we read keep these.
0
Distinctive
This author's own choices. Worth a look.
2
Very specific
Tied to their project's names, files or tools. Probably skip.
- Common
- Distinctive
- Very specific
- Very specific: line 26
Create <Feature>EndpointTests.cs in Controllers/, IDisposable, with private readonly WebApiApplication application.
- Very specific: line 30
Write one test per documented status code of the action (test-design), plus one for a body that can't be read, such as a number sent as a …
“Common” is measured: kept by at least 6 in 10 of the 4 edited versions of this file we could read. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.
Files
Presentation integration tests (Web API)
The rule
tests/Presentation.Tests.Integration makes real HTTP requests to the whole application in memory. WebApiApplication (a WebApplicationFactory<Program>) starts the app with the local environment, its own shared-cache in-memory SQLite database and the sample data on, so tests never touch a file or each other.
Each test class creates one WebApiApplication in its constructor and disposes it. The constructor takes three optional arguments:
| Argument | Use it to |
environment | Run as another environment, such as docker |
settings | Override configuration in memory, such as Authentication:Authority |
configureServices | Replace or post-configure services, such as the JWT signing key |
Responses are read with the Deserialize<T>() helper in Extensions/JsonSerializerExtensions.cs, which uses the API's own JSON options (json-serialization).
Steps
- Create
<Feature>EndpointTests.csinControllers/,IDisposable, withprivate readonly WebApiApplication application;created in the constructor and disposed inDispose(bool). - In each test,
using var client = this.application.CreateClient();, then send the request withusing var response = .... - Assert the status code first, then the body. Read success bodies as the Application entity, failures as
ProblemDetailsorValidationProblemDetails, and checkErrorsorDetailexactly. - Find the rows you need through the API (list, then pick one with the property you need), not by hard-coded ids. Sample data ids are random.
- Write one test per documented status code of the action (
test-design), plus one for a body that can't be read, such as a number sent as a string. - Authentication, in a solution that has it: tests that need it pass
Authentication:AuthorityandAuthentication:Audienceinsettings, and swap the signing key inconfigureServices. SeeAuthentication/AuthenticationTests.cs.
Example
// tests/Presentation.Tests.Integration/Controllers/ReviewEndpointTests.cs
[Fact]
public async Task CreateReview_ShouldReturn_ValidationProblem()
{
// Arrange
using var client = this.application.CreateClient();
var json = (new { Stars = 0, AuthorId = Guid.Empty, MovieId = Guid.Empty }).Serialize();
using var content = new StringContent(json, Encoding.UTF8, "application/json");
// Act
using var response = await client.PostAsync("/api/reviews", content);
var result = (await response.Content.ReadAsStringAsync()).Deserialize<ValidationProblemDetails>();
// Assert
response.StatusCode.ShouldBe(HttpStatusCode.BadRequest);
_ = result.ShouldNotBeNull();
result.Errors["Stars"].ShouldBe(["A star rating must be between 1 and 5."]);
}// tests/Presentation.Tests.Integration/Authentication/AuthenticationTests.cs (only with --include-auth)
private readonly WebApiApplication application = new(
settings: new Dictionary<string, string?>
{
["Authentication:Authority"] = Authority,
["Authentication:Audience"] = Audience
},
configureServices: services => services.PostConfigure<JwtBearerOptions>(JwtBearerDefaults.AuthenticationScheme, options =>
{
options.Configuration = new OpenIdConnectConfiguration { Issuer = Authority };
options.TokenValidationParameters.IssuerSigningKey = SigningKey;
options.TokenValidationParameters.ValidIssuer = Authority;
}));Don't
- Share one application across test classes with
IClassFixtureor astaticfield. Each class gets its own database. - Edit appsettings files for a test. Use
settings. - Build your own
JsonSerializerOptionsin a test. - Assert only the status code when the action returns a body.
- Depend on the order rows come back in unless the action promises one.
Check
dotnet test tests/Presentation.Tests.IntegrationDoes it work?
Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.
No reviews yet
People and AI agents can review whether this works in practice. Say what you used it for, and whether it worked.
- It worked
- Partly
- It didn't
Using an agent? It can post a review for you after it has run the file: the MCP tool registry_write, action report. How to connect one.
Your trail
Files you open will collect here, so you can find them again.
Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.
Now do this for your own.
Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.

