-
Notifications
You must be signed in to change notification settings - Fork 0
concepts.md
Core mental models, terminology, and design principles for the 0.1.x alpha release.
Mission:
Provide a DX‑first, minimal‑ceremony toolkit for writing Arrange → Act → Assert tests without requiring a full DI container or external mocking framework.
Scope in Alpha:
- Core scenario DSL (
ITestScenario) - Lightweight, per‑test harness (
ITestHarness) - Built‑in minimal mock engine (
IMockBuilder) - Fluent result assertions (
IResultAssertions) - No dependency on
Zentient.DependencyInjectionyet - No adapters — mocking and DI are internal only
- DX‑first — APIs are terse, discoverable, and read like the test flow.
- Non‑invasive — Public API does not expose concrete DI/mocking framework types.
- Test‑scoped isolation — Each test gets its own harness; all resources disposed after use.
- Fail‑fast diagnostics — Exceptions are descriptive and actionable.
- Progressive enhancement — Alpha focuses on core flow; DI adapters, analyzers, and advanced diagnostics come later.
The orchestrator for a single test scenario.
ITestScenario<TInput, TResult> Arrange(Action<ITestHarnessBuilder> configure);
Task<TResult> ActAsync(TInput input, CancellationToken ct = default);
ITestScenario<TInput, TResult> Assert(Action<IResultAssertions<TResult>> assertions);- Arrange — Configure dependencies and mocks.
- ActAsync — Execute the system under test (SUT) using harness resolution rules.
- Assert — Verify the result with fluent assertions.
Configures the per‑scenario harness.
-
WithDependency<TService>(TService instance)— Register a concrete instance. -
WithMock<TService>(Action<IMockBuilder<TService>> configure)— Configure a mock. -
Replace<TService>(TService instance)— Replace an existing registration. -
Build()— Produce the harness (internal type in alpha).
Minimal built‑in mock DSL.
mb.Given(s => s.Do(It.IsAny<int>())).ThenReturns(42);
mb.Given(s => s.Do("bad")).ThenThrows(new InvalidOperationException("boom"));-
Given(...)— Identify a method/property call to stub. -
ThenReturns(...)— Return a specified value. -
ThenThrows(...)— Throw a specified exception.
Fluent assertions for scenario results.
NotBeNull()HaveValue(TResult expected)With<TProperty>(Expression<Func<TResult, TProperty>> selector, TProperty expected)- Supports chaining via
.And
- Lightweight service registry:
Type → instance - Resolution rules:
- Return registered instance if found.
- Otherwise, construct via reflection if all constructor parameters are registered.
- Otherwise, throw descriptive exception.
- SUT Resolution — Prefers explicit registrations; falls back to reflection‑based construction.
- Mocks — Stored behaviors keyed by expression; return configured values or throw.
-
Context — No typed
IContextyet; useWithDependencyfor contextual data.
var scenario = TestScenario.ForHandler<MyHandler, string, string>(
(h, input, ct) => Task.FromResult(h.Handle(input))
);
scenario.Arrange(b => b.WithMock<IMyService>(mb =>
mb.Given(s => s.Do(It.IsAny<string>())).ThenReturns("mocked")
));
var result = await scenario.ActAsync("in");
scenario.Assert(a => a.HaveValue("mocked"));- No external DI container integration.
- No mocking framework adapters.
- No typed context or envelope abstractions.
- No diagnostics API or analyzers.
The Beta release will add:
- Integration with
Zentient.DependencyInjection - Hosting adapters (e.g., Microsoft DI)
- Mock adapters (e.g., Moq)
- Basic DI diagnostics
- [Getting Started](getting-started.md)
- [Usage Examples](usage-examples.md)
- [Architecture](architecture.md)
- [Release Notes](release-notes.md)
- [Roadmap](roadmap.md)
Licensed under the MIT License. See the LICENSE file for more details.
- Zentient.Testing Home (Wiki Main Page)
- Main Repository (GitHub)
- Report an Issue / Feature Request
- Contributing Guidelines
- Code of Conduct
- Latest Release Notes
- [Discussions]: Ask questions, share ideas, or showcase your projects.
Thank you for exploring the Zentient.Testing documentation! We hope it helps you build elegant, maintainable, and contributor‑friendly .NET testing solutions.
Last updated: 19 Sep 2025
📚 Zentient.Testing Docs
Quick links to all major sections of the documentation.
- Landing Page — What Zentient.Testing is and why it exists.
- Release Notes — Changes in the current version.
- Roadmap — Planned features and milestones.
- Concepts — Mental model and terminology.
- Architecture — Components, relationships, and flow.
- Architecture Diagram — Visual Mermaid diagram.
- Getting Started — Install and run your first scenario.
-
Usage Examples — Recipes from
samples/Features.
- API Reference (alfa) — Public API for v0.1.0‑alfa.
- Adapters & Integration Points — (future) DI and mocking adapters.
- Diagnostics — (future) DI graph and validation tools.
- Contributing Guide — How to contribute.
- Testing Strategy — How Zentient.Testing is tested.
- Changelog — Full version history.
💡 Tip: Use the Architecture page as your hub — it links to Getting Started, Usage Examples, API Reference, and Concepts.