presentation-integration-tests
Skill0 starsChanged 10 days agoMITView on GitHub
How this Lambda function is tested end to end - calling Handler methods with a TestLambdaContext, services from Startup with a private in-memory database per test class, the generated handler classes, the HTTP API functions, and asserting exceptions. Use when writing or fixing a test in tests/Presentation.Tests.Integration.
4 other projects use a version of this, 2 of them edited.
Adopted by
Most recently taken up by
- LeanMeanCleanApps/CleanWebApiedited, first seen Nov 15, 2026
- LeanMeanCleanApps/CleanGraphQLApitheir own version, first seen Nov 15, 2026
- LeanMeanCleanApps/CleanMinimalApiedited, first seen Nov 15, 2026
- LeanMeanCleanApps/CleanModelContextProtocoltheir own version, first seen Nov 8, 2026
Other versions4 projects use a version of this.
Word for word · 0
None found.
Edited · 2
- LeanMeanCleanApps/CleanMinimalApi★ 40011% same
- LeanMeanCleanApps/CleanWebApi★ 411% same
Wrote their own version · 2
- LeanMeanCleanApps/CleanGraphQLApi★ 13same name
- LeanMeanCleanApps/CleanModelContextProtocol★ 1same name
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
- lambda-emulatorSkill
- mapping-with-mapperlySkill
- mediatorSkill
- 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
4 rules. 0 are common, 1 is distinctive, and 3 are very specific to this project.
0
Common
Most of the 4 edited versions we read keep these.
1
Distinctive
This author's own choices. Worth a look.
3
Very specific
Tied to their project's names, files or tools. Probably skip.
- Common
- Distinctive
- Very specific
- Very specific: line 30
Use the class's handler and context fields.
- Very specific: line 31
Call the function, then assert the result: counts, NextOffset, and that every item matches the filter.
- Very specific: line 36
Write one test per success and per failure the function can return (test-design).
- Distinctive: line 64
Leave an environment variable set after a test.
“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 (Lambda function)
The rule
tests/Presentation.Tests.Integration tests the whole function in memory by calling Handler methods the way Lambda does. Each test class creates one Handler from the services Startup registers, with its own shared-cache in-memory SQLite database and the sample data on, and a TestLambdaContext (from Amazon.Lambda.TestUtilities) with time remaining.
| File | Tests |
HandlerTests.cs | Every function's results, paging, search and filters, the validation failures, and how the handler reads its settings |
HttpApiTests.cs | The Http* functions: the 200 page, each 400 with its problem details and content type, and the generated classes binding an APIGatewayHttpApiV2ProxyRequest query string |
The serializer is tested on its own in tests/Presentation.Tests.Unit (unit-tests, json-serialization).
There are two ways in, and tests use whichever the case needs:
| Way in | Use it to |
CreateHandler(settings) | Most tests. It builds new Startup(settings) with scope validation on and resolves Handler, so settings such as ConnectionStrings:MovieReviews and Database:SeedSampleData override the environment |
new Handler_<Method>_Generated() | The environment variable test, which calls each generated class exactly as Lambda does, then clears the variables |
Steps
- Use the class's
handlerandcontextfields. Create a second handler withCreateHandleronly when the test needs other settings. - Call the function, then assert the result: counts,
NextOffset, and that every item matches the filter. - Failures:
await Should.ThrowAsync<ValidationException>(...)and check the property name in the errors, orNotFoundExceptionand its message. - Find the rows you need through another function (list, then pick one), not by hard-coded ids. Sample data ids are random.
- For an
Http*function, turn theIHttpResultinto the API Gateway response withRead, then read the body withBody<T>. Check the content type withContentType, which reads the raw JSON: Lambda Annotations writes header names in lower case and the SDK's response type doesn't read them back. - A test that sets environment variables clears them in
finally. - Write one test per success and per failure the function can return (
test-design).
Example
// tests/Presentation.Tests.Integration/HandlerTests.cs
private readonly Handler handler = CreateHandler(new()
{
["ConnectionStrings:MovieReviews"] = InMemoryDatabase(),
["Database:SeedSampleData"] = "true"
});
private readonly TestLambdaContext context = new() { RemainingTime = TimeSpan.FromSeconds(30) };
[Fact]
public async Task GetMovies_ShouldThrow_WhenLimitIsNotValid()
{
// Act
var exception = await Should.ThrowAsync<ValidationException>(() => this.handler.GetMovies(new ListRequest { Limit = 0 }, this.context));
// Assert
exception.Errors.ShouldContain(e => e.PropertyName == "Limit" && e.ErrorMessage == "A limit must be between 1 and 50.");
}Don't
- Share a
Handleracross test classes or in astaticfield. Each class gets its own database. - Point a test at
/tmp/movie-reviews.dbor any file. - Leave an environment variable set after a test.
- Depend on the order rows come back in unless the function 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.

