LithoSharp.Testing 1.0.0

dotnet add package LithoSharp.Testing --version 1.0.0
                    
NuGet\Install-Package LithoSharp.Testing -Version 1.0.0
                    
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="LithoSharp.Testing" Version="1.0.0" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="LithoSharp.Testing" Version="1.0.0" />
                    
Directory.Packages.props
<PackageReference Include="LithoSharp.Testing" />
                    
Project file
For projects that support Central Package Management (CPM), copy this XML node into the solution Directory.Packages.props file to version the package.
paket add LithoSharp.Testing --version 1.0.0
                    
#r "nuget: LithoSharp.Testing, 1.0.0"
                    
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
#:package LithoSharp.Testing@1.0.0
                    
#:package directive can be used in C# file-based apps starting in .NET 10 preview 4. Copy this into a .cs file before any lines of code to reference the package.
#addin nuget:?package=LithoSharp.Testing&version=1.0.0
                    
Install as a Cake Addin
#tool nuget:?package=LithoSharp.Testing&version=1.0.0
                    
Install as a Cake Tool

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 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. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.

NuGet packages

This package is not used by any NuGet packages.

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last Updated
1.0.0 41 9/15/2026
0.3.1 86 9/9/2026
0.3.0 82 9/8/2026