LithoSharp.Testing
1.0.0
dotnet add package LithoSharp.Testing --version 1.0.0
NuGet\Install-Package LithoSharp.Testing -Version 1.0.0
<PackageReference Include="LithoSharp.Testing" Version="1.0.0" />
<PackageVersion Include="LithoSharp.Testing" Version="1.0.0" />
<PackageReference Include="LithoSharp.Testing" />
paket add LithoSharp.Testing --version 1.0.0
#r "nuget: LithoSharp.Testing, 1.0.0"
#:package LithoSharp.Testing@1.0.0
#addin nuget:?package=LithoSharp.Testing&version=1.0.0
#tool nuget:?package=LithoSharp.Testing&version=1.0.0
LithoSharp.Testing
Generate sites inside ordinary .NET tests, with no server or external process.
Use any test framework: assertion failures throw SiteTestException.
using LithoSharp;
using LithoSharp.Configuration;
using LithoSharp.Testing;
await using var host = await SiteTestHost.CreateAsync(
new SiteDefinition(new SiteSettings { BaseUrl = "https://example.com/" }, []));
host.AssertSucceeded();
host.AssertRoute("/index.html", "index.html");
host.AssertArtifact("index.html");
using var page = await host.OpenPageAsync("/index.html");
page.AssertElement("main");
Output, ownership files and enabled caches are isolated in a temporary directory. Disposal removes that tree. Source files are read in place. Explicit timestamps and quality settings are honored; otherwise the host uses Unix epoch and enables local quality validation. Network validation requires explicit external-link options. The definition's output/cache paths are never used for writes by the host. Custom factories, renderers and transforms are trusted application code and can perform their own I/O; the host is not a sandbox.
Route, build-plan and quality validation failures return Succeeded == false,
Result == null, and diagnostics suitable for AssertDiagnostic. Other exceptions,
including cancellation and I/O failures, propagate. Call AssertSucceeded before
interpreting a successful diagnostics assertion as a successful build.
SiteTestDocument.RenderComponent and RenderLayout accept the existing rendering
contexts. Parse supports standalone HTML, including empty output. The underlying
AngleSharp Document supports arbitrary DOM queries; no scripts or network run.
AssertText and AssertAttribute compare the first matching element exactly.
AssertMeta, AssertLink and AssertImage match decoded attribute values exactly;
URL resolution and broken-target validation are performed by host quality checks.
Invalid arguments throw standard argument exceptions; unsafe filesystem paths are
rejected, and assertions on disposed hosts/documents throw ObjectDisposedException.
See the testing guide and Japanese guide.
| Product | Versions Compatible and additional computed target framework versions. |
|---|---|
| .NET | net10.0 is compatible. net10.0-android was computed. net10.0-browser was computed. net10.0-ios was computed. net10.0-maccatalyst was computed. net10.0-macos was computed. net10.0-tvos was computed. net10.0-windows was computed. |
-
net10.0
- AngleSharp (>= 1.7.3)
- LithoSharp (>= 1.0.0)
NuGet packages
This package is not used by any NuGet packages.
GitHub repositories
This package is not used by any popular GitHub repositories.