From 4ebc5b5b11f156e2c681299c46954508ae6fcbba Mon Sep 17 00:00:00 2001 From: aicia-bot Date: Fri, 20 Nov 2026 03:24:22 +0100 Subject: [PATCH 01/12] =?UTF-8?q?=E2=9C=A8=20add=20run-actions=20viewer=20?= =?UTF-8?q?for=20docfx=20examples?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Generated API examples can now expose native and Docker run scripts next to each example. The DocFX build copies the run-actions folder into the site, and the modern template loads a small script that adds the view links. The settings and index files keep each script tied to its source hash so stale scripts are easy to spot. --- .docfx/docfx.json | 5 + .docfx/run-actions.settings.json | 629 ++++++++++++++++ .../00acdae546dce87b654496e1/docker.ps1 | 86 +++ .../00acdae546dce87b654496e1/native.ps1 | 89 +++ .../0308118a47b5c02daa7b32be/docker.ps1 | 82 +++ .../0308118a47b5c02daa7b32be/native.ps1 | 85 +++ .../038a1c806225b412a6f986c1/docker.ps1 | 82 +++ .../038a1c806225b412a6f986c1/native.ps1 | 85 +++ .../08b911ef79f0b743282e37c9/docker.ps1 | 85 +++ .../08b911ef79f0b743282e37c9/native.ps1 | 88 +++ .../10457ac34cce1cbadb26aee1/docker.ps1 | 82 +++ .../10457ac34cce1cbadb26aee1/native.ps1 | 85 +++ .../1130af506703020850fdadea/docker.ps1 | 83 +++ .../1130af506703020850fdadea/native.ps1 | 86 +++ .../18b0746bf3da1d84f81b5274/docker.ps1 | 83 +++ .../18b0746bf3da1d84f81b5274/native.ps1 | 86 +++ .../1e869fe39c4833386733c21f/docker.ps1 | 86 +++ .../1e869fe39c4833386733c21f/native.ps1 | 89 +++ .../1ec9196292addaca42a7eef1/docker.ps1 | 58 ++ .../1ec9196292addaca42a7eef1/native.ps1 | 50 ++ .../21b422ce67f920d801901db0/docker.ps1 | 86 +++ .../21b422ce67f920d801901db0/native.ps1 | 89 +++ .../38b60f4b4c1a588bbefe92f1/docker.ps1 | 58 ++ .../38b60f4b4c1a588bbefe92f1/native.ps1 | 50 ++ .../3a1dbfc0e010519636b7091e/docker.ps1 | 85 +++ .../3a1dbfc0e010519636b7091e/native.ps1 | 88 +++ .../3c3b98167b30d6985017ec27/docker.ps1 | 87 +++ .../3c3b98167b30d6985017ec27/native.ps1 | 90 +++ .../45fcccef5fc861315b50c55e/docker.ps1 | 82 +++ .../45fcccef5fc861315b50c55e/native.ps1 | 85 +++ .../4c5e94adccd20cab4da52078/docker.ps1 | 58 ++ .../4c5e94adccd20cab4da52078/native.ps1 | 50 ++ .../513a785b0e0abbe2284270b9/docker.ps1 | 83 +++ .../513a785b0e0abbe2284270b9/native.ps1 | 86 +++ .../515575be5bb7683cac9903a5/docker.ps1 | 83 +++ .../515575be5bb7683cac9903a5/native.ps1 | 86 +++ .../545543e49c6bf054a9e06186/docker.ps1 | 82 +++ .../545543e49c6bf054a9e06186/native.ps1 | 85 +++ .../549c3e82bd0bcb99e9f05bfa/docker.ps1 | 86 +++ .../549c3e82bd0bcb99e9f05bfa/native.ps1 | 89 +++ .../578d467fd203f66cc41b0364/docker.ps1 | 82 +++ .../578d467fd203f66cc41b0364/native.ps1 | 85 +++ .../5e35a33e56470f93afbedf19/docker.ps1 | 83 +++ .../5e35a33e56470f93afbedf19/native.ps1 | 86 +++ .../6a59b7744a7d9994ffc04782/docker.ps1 | 83 +++ .../6a59b7744a7d9994ffc04782/native.ps1 | 86 +++ .../782f24d34260070258f6d164/docker.ps1 | 82 +++ .../782f24d34260070258f6d164/native.ps1 | 85 +++ .../812efaa205554c7bdcd80831/docker.ps1 | 82 +++ .../812efaa205554c7bdcd80831/native.ps1 | 85 +++ .../90a8cd444bd08a0115613e58/docker.ps1 | 58 ++ .../90a8cd444bd08a0115613e58/native.ps1 | 50 ++ .../927ca9f6a3bf893bc52887f4/docker.ps1 | 86 +++ .../927ca9f6a3bf893bc52887f4/native.ps1 | 89 +++ .../947406357e3e26b26a71a538/docker.ps1 | 87 +++ .../947406357e3e26b26a71a538/native.ps1 | 90 +++ .../9a558a9a581c6b11ccb28057/docker.ps1 | 83 +++ .../9a558a9a581c6b11ccb28057/native.ps1 | 86 +++ .../9cdeb08f8ba8f3b361a98c58/docker.ps1 | 83 +++ .../9cdeb08f8ba8f3b361a98c58/native.ps1 | 86 +++ .../a31971b360a8c557b87f6684/docker.ps1 | 82 +++ .../a31971b360a8c557b87f6684/native.ps1 | 85 +++ .../aa478d74f298d8c98e6cd1bf/docker.ps1 | 83 +++ .../aa478d74f298d8c98e6cd1bf/native.ps1 | 86 +++ .../b4149382f121a5ffc3c057df/docker.ps1 | 83 +++ .../b4149382f121a5ffc3c057df/native.ps1 | 86 +++ .../becb2fe7446fc1571dc86953/docker.ps1 | 83 +++ .../becb2fe7446fc1571dc86953/native.ps1 | 86 +++ .../d565f9c40d015b247963fdee/docker.ps1 | 86 +++ .../d565f9c40d015b247963fdee/native.ps1 | 89 +++ .../d71e8ed85f1221cb41308b31/docker.ps1 | 86 +++ .../d71e8ed85f1221cb41308b31/native.ps1 | 89 +++ .../dd2fa1a038dbc1220b366a53/docker.ps1 | 86 +++ .../dd2fa1a038dbc1220b366a53/native.ps1 | 89 +++ .../dfdd064179bf4643e1a0b2bf/docker.ps1 | 86 +++ .../dfdd064179bf4643e1a0b2bf/native.ps1 | 89 +++ .../e3f79d1c0f2fa85276cee2fb/docker.ps1 | 82 +++ .../e3f79d1c0f2fa85276cee2fb/native.ps1 | 85 +++ .../e7dbb5ba733b205469239b03/docker.ps1 | 83 +++ .../e7dbb5ba733b205469239b03/native.ps1 | 86 +++ .../f27f77d838407171b56f9073/docker.ps1 | 86 +++ .../f27f77d838407171b56f9073/native.ps1 | 89 +++ .../f3c0856195727da12ff2925f/docker.ps1 | 85 +++ .../f3c0856195727da12ff2925f/native.ps1 | 88 +++ .../f5ed7c321a52580d7ce11408/docker.ps1 | 85 +++ .../f5ed7c321a52580d7ce11408/native.ps1 | 88 +++ .../ff2e361441bdc3028ab188a9/docker.ps1 | 82 +++ .../ff2e361441bdc3028ab188a9/native.ps1 | 85 +++ .docfx/run-actions/index.json | 692 ++++++++++++++++++ .docfx/templates/modern/public/main.js | 2 + .docfx/templates/modern/public/run-actions.js | 269 +++++++ 91 files changed, 8690 insertions(+) create mode 100644 .docfx/run-actions.settings.json create mode 100644 .docfx/run-actions/00acdae546dce87b654496e1/docker.ps1 create mode 100644 .docfx/run-actions/00acdae546dce87b654496e1/native.ps1 create mode 100644 .docfx/run-actions/0308118a47b5c02daa7b32be/docker.ps1 create mode 100644 .docfx/run-actions/0308118a47b5c02daa7b32be/native.ps1 create mode 100644 .docfx/run-actions/038a1c806225b412a6f986c1/docker.ps1 create mode 100644 .docfx/run-actions/038a1c806225b412a6f986c1/native.ps1 create mode 100644 .docfx/run-actions/08b911ef79f0b743282e37c9/docker.ps1 create mode 100644 .docfx/run-actions/08b911ef79f0b743282e37c9/native.ps1 create mode 100644 .docfx/run-actions/10457ac34cce1cbadb26aee1/docker.ps1 create mode 100644 .docfx/run-actions/10457ac34cce1cbadb26aee1/native.ps1 create mode 100644 .docfx/run-actions/1130af506703020850fdadea/docker.ps1 create mode 100644 .docfx/run-actions/1130af506703020850fdadea/native.ps1 create mode 100644 .docfx/run-actions/18b0746bf3da1d84f81b5274/docker.ps1 create mode 100644 .docfx/run-actions/18b0746bf3da1d84f81b5274/native.ps1 create mode 100644 .docfx/run-actions/1e869fe39c4833386733c21f/docker.ps1 create mode 100644 .docfx/run-actions/1e869fe39c4833386733c21f/native.ps1 create mode 100644 .docfx/run-actions/1ec9196292addaca42a7eef1/docker.ps1 create mode 100644 .docfx/run-actions/1ec9196292addaca42a7eef1/native.ps1 create mode 100644 .docfx/run-actions/21b422ce67f920d801901db0/docker.ps1 create mode 100644 .docfx/run-actions/21b422ce67f920d801901db0/native.ps1 create mode 100644 .docfx/run-actions/38b60f4b4c1a588bbefe92f1/docker.ps1 create mode 100644 .docfx/run-actions/38b60f4b4c1a588bbefe92f1/native.ps1 create mode 100644 .docfx/run-actions/3a1dbfc0e010519636b7091e/docker.ps1 create mode 100644 .docfx/run-actions/3a1dbfc0e010519636b7091e/native.ps1 create mode 100644 .docfx/run-actions/3c3b98167b30d6985017ec27/docker.ps1 create mode 100644 .docfx/run-actions/3c3b98167b30d6985017ec27/native.ps1 create mode 100644 .docfx/run-actions/45fcccef5fc861315b50c55e/docker.ps1 create mode 100644 .docfx/run-actions/45fcccef5fc861315b50c55e/native.ps1 create mode 100644 .docfx/run-actions/4c5e94adccd20cab4da52078/docker.ps1 create mode 100644 .docfx/run-actions/4c5e94adccd20cab4da52078/native.ps1 create mode 100644 .docfx/run-actions/513a785b0e0abbe2284270b9/docker.ps1 create mode 100644 .docfx/run-actions/513a785b0e0abbe2284270b9/native.ps1 create mode 100644 .docfx/run-actions/515575be5bb7683cac9903a5/docker.ps1 create mode 100644 .docfx/run-actions/515575be5bb7683cac9903a5/native.ps1 create mode 100644 .docfx/run-actions/545543e49c6bf054a9e06186/docker.ps1 create mode 100644 .docfx/run-actions/545543e49c6bf054a9e06186/native.ps1 create mode 100644 .docfx/run-actions/549c3e82bd0bcb99e9f05bfa/docker.ps1 create mode 100644 .docfx/run-actions/549c3e82bd0bcb99e9f05bfa/native.ps1 create mode 100644 .docfx/run-actions/578d467fd203f66cc41b0364/docker.ps1 create mode 100644 .docfx/run-actions/578d467fd203f66cc41b0364/native.ps1 create mode 100644 .docfx/run-actions/5e35a33e56470f93afbedf19/docker.ps1 create mode 100644 .docfx/run-actions/5e35a33e56470f93afbedf19/native.ps1 create mode 100644 .docfx/run-actions/6a59b7744a7d9994ffc04782/docker.ps1 create mode 100644 .docfx/run-actions/6a59b7744a7d9994ffc04782/native.ps1 create mode 100644 .docfx/run-actions/782f24d34260070258f6d164/docker.ps1 create mode 100644 .docfx/run-actions/782f24d34260070258f6d164/native.ps1 create mode 100644 .docfx/run-actions/812efaa205554c7bdcd80831/docker.ps1 create mode 100644 .docfx/run-actions/812efaa205554c7bdcd80831/native.ps1 create mode 100644 .docfx/run-actions/90a8cd444bd08a0115613e58/docker.ps1 create mode 100644 .docfx/run-actions/90a8cd444bd08a0115613e58/native.ps1 create mode 100644 .docfx/run-actions/927ca9f6a3bf893bc52887f4/docker.ps1 create mode 100644 .docfx/run-actions/927ca9f6a3bf893bc52887f4/native.ps1 create mode 100644 .docfx/run-actions/947406357e3e26b26a71a538/docker.ps1 create mode 100644 .docfx/run-actions/947406357e3e26b26a71a538/native.ps1 create mode 100644 .docfx/run-actions/9a558a9a581c6b11ccb28057/docker.ps1 create mode 100644 .docfx/run-actions/9a558a9a581c6b11ccb28057/native.ps1 create mode 100644 .docfx/run-actions/9cdeb08f8ba8f3b361a98c58/docker.ps1 create mode 100644 .docfx/run-actions/9cdeb08f8ba8f3b361a98c58/native.ps1 create mode 100644 .docfx/run-actions/a31971b360a8c557b87f6684/docker.ps1 create mode 100644 .docfx/run-actions/a31971b360a8c557b87f6684/native.ps1 create mode 100644 .docfx/run-actions/aa478d74f298d8c98e6cd1bf/docker.ps1 create mode 100644 .docfx/run-actions/aa478d74f298d8c98e6cd1bf/native.ps1 create mode 100644 .docfx/run-actions/b4149382f121a5ffc3c057df/docker.ps1 create mode 100644 .docfx/run-actions/b4149382f121a5ffc3c057df/native.ps1 create mode 100644 .docfx/run-actions/becb2fe7446fc1571dc86953/docker.ps1 create mode 100644 .docfx/run-actions/becb2fe7446fc1571dc86953/native.ps1 create mode 100644 .docfx/run-actions/d565f9c40d015b247963fdee/docker.ps1 create mode 100644 .docfx/run-actions/d565f9c40d015b247963fdee/native.ps1 create mode 100644 .docfx/run-actions/d71e8ed85f1221cb41308b31/docker.ps1 create mode 100644 .docfx/run-actions/d71e8ed85f1221cb41308b31/native.ps1 create mode 100644 .docfx/run-actions/dd2fa1a038dbc1220b366a53/docker.ps1 create mode 100644 .docfx/run-actions/dd2fa1a038dbc1220b366a53/native.ps1 create mode 100644 .docfx/run-actions/dfdd064179bf4643e1a0b2bf/docker.ps1 create mode 100644 .docfx/run-actions/dfdd064179bf4643e1a0b2bf/native.ps1 create mode 100644 .docfx/run-actions/e3f79d1c0f2fa85276cee2fb/docker.ps1 create mode 100644 .docfx/run-actions/e3f79d1c0f2fa85276cee2fb/native.ps1 create mode 100644 .docfx/run-actions/e7dbb5ba733b205469239b03/docker.ps1 create mode 100644 .docfx/run-actions/e7dbb5ba733b205469239b03/native.ps1 create mode 100644 .docfx/run-actions/f27f77d838407171b56f9073/docker.ps1 create mode 100644 .docfx/run-actions/f27f77d838407171b56f9073/native.ps1 create mode 100644 .docfx/run-actions/f3c0856195727da12ff2925f/docker.ps1 create mode 100644 .docfx/run-actions/f3c0856195727da12ff2925f/native.ps1 create mode 100644 .docfx/run-actions/f5ed7c321a52580d7ce11408/docker.ps1 create mode 100644 .docfx/run-actions/f5ed7c321a52580d7ce11408/native.ps1 create mode 100644 .docfx/run-actions/ff2e361441bdc3028ab188a9/docker.ps1 create mode 100644 .docfx/run-actions/ff2e361441bdc3028ab188a9/native.ps1 create mode 100644 .docfx/run-actions/index.json create mode 100644 .docfx/templates/modern/public/run-actions.js diff --git a/.docfx/docfx.json b/.docfx/docfx.json index 6164845..275a30c 100644 --- a/.docfx/docfx.json +++ b/.docfx/docfx.json @@ -45,6 +45,11 @@ "files": [ "images/**" ] + }, + { + "files": [ + "run-actions/**" + ] } ], "globalMetadata": { diff --git a/.docfx/run-actions.settings.json b/.docfx/run-actions.settings.json new file mode 100644 index 0000000..7309321 --- /dev/null +++ b/.docfx/run-actions.settings.json @@ -0,0 +1,629 @@ +{ + "examples": [ + { + "uid": "Codebelt.Extensions.Xunit.Hosting.ApplicationFixtureExtensions", + "sourceSha256": "90B08550FC34DE0144BF28F6ADB2577A59AEC596EB8B6060D545A9B56CD34377", + "manifest": { + "schemaVersion": 1, + "mode": "test", + "framework": "net10.0", + "dependsOn": [ + "Codebelt.Extensions.Xunit.Hosting@13.0.0", + "Microsoft.Extensions.Hosting@10.0.15", + "xunit.v3@4.0.3" + ] + } + }, + { + "uid": "Codebelt.Extensions.Xunit.Hosting.ApplicationHostFactory", + "sourceSha256": "42FEDED83B95259C5771DBE3B83C0323599941985C3D71B510F80C1448BB3771", + "manifest": { + "schemaVersion": 1, + "mode": "console", + "framework": "net10.0", + "dependsOn": [ + "Codebelt.Extensions.Xunit.Hosting@13.0.0", + "Microsoft.Extensions.Hosting@10.0.15" + ] + } + }, + { + "uid": "Codebelt.Extensions.Xunit.Hosting.ApplicationTestFactory", + "sourceSha256": "7473E8AE20820AD58942D6212B5A7DCD428922FD0EEF1985E7D05F9CAC6E8D23", + "repository": "codebeltnet/xunit", + "commit": "84b13767cb9484f8f3a36a71875662edfdb3e511", + "project": "test/Codebelt.Extensions.Xunit.Hosting.FunctionalTests/Codebelt.Extensions.Xunit.Hosting.FunctionalTests.csproj", + "test": "Codebelt.Extensions.Xunit.Hosting.ApplicationTestFactoryTest.Create_ShouldBootstrapApplication_WhenEntryPointUsesBootstrapperMinimalWorkerProgram", + "framework": "net11.0", + "image": "mcr.microsoft.com/dotnet/sdk:11.0", + "explanation": "The scripts run the maintained worker integration test and verify its registered marker and Development environment." + }, + { + "uid": "Codebelt.Extensions.Xunit.Hosting.AspNetCore.BlockingManagedWebHostFixture", + "sourceSha256": "CD729B010424B55A26B7607AC78059BC5F610C522C2DCF312E7AD6A8A602E7FC", + "manifest": { + "schemaVersion": 1, + "mode": "test", + "framework": "net10.0", + "dependsOn": [ + "Codebelt.Extensions.Xunit.Hosting.AspNetCore@13.0.0", + "Microsoft.Extensions.Hosting@10.0.15", + "xunit.v3@4.0.3" + ], + "frameworkReferences": [ + "Microsoft.AspNetCore.App" + ] + } + }, + { + "uid": "Codebelt.Extensions.Xunit.Hosting.AspNetCore.HostBuilderApplicationExtensions", + "sourceSha256": "340FBC3BD83E80B5B8AD6FAA66020C285458A08A608961D7D33BFA1B841FEFF4", + "manifest": { + "schemaVersion": 1, + "mode": "test", + "framework": "net10.0", + "dependsOn": [ + "Codebelt.Extensions.Xunit.Hosting.AspNetCore@13.0.0", + "Microsoft.Extensions.Hosting@10.0.15", + "xunit.v3@4.0.3" + ], + "frameworkReferences": [ + "Microsoft.AspNetCore.App" + ] + } + }, + { + "uid": "Codebelt.Extensions.Xunit.Hosting.AspNetCore.Http.FakeHttpContextAccessor", + "sourceSha256": "DCFB8604280E9AC15FFABA700B4055745F26AB9AD9E2F25C3A455EB50AEE7376", + "manifest": { + "schemaVersion": 1, + "mode": "console", + "framework": "net10.0", + "dependsOn": [ + "Codebelt.Extensions.Xunit.Hosting.AspNetCore@13.0.0" + ], + "frameworkReferences": [ + "Microsoft.AspNetCore.App" + ], + "sdk": "Microsoft.NET.Sdk.Web" + } + }, + { + "uid": "Codebelt.Extensions.Xunit.Hosting.AspNetCore.Http.Features.FakeHttpRequestFeature", + "sourceSha256": "A68A4CA3ACD2C8F668D4D343A9B36AB6E84D6CC1B506473700E973B97D053B94", + "manifest": { + "schemaVersion": 1, + "mode": "console", + "framework": "net10.0", + "dependsOn": [ + "Codebelt.Extensions.Xunit.Hosting.AspNetCore@13.0.0" + ], + "frameworkReferences": [ + "Microsoft.AspNetCore.App" + ], + "sdk": "Microsoft.NET.Sdk.Web" + } + }, + { + "uid": "Codebelt.Extensions.Xunit.Hosting.AspNetCore.Http.Features.FakeHttpResponseFeature", + "sourceSha256": "7549EF36EB77D3203099D1DFEF5584A8AAEBD3ED8E537D6BF752D3231191C33D", + "manifest": { + "schemaVersion": 1, + "mode": "console", + "framework": "net10.0", + "dependsOn": [ + "Codebelt.Extensions.Xunit.Hosting.AspNetCore@13.0.0" + ], + "frameworkReferences": [ + "Microsoft.AspNetCore.App" + ], + "sdk": "Microsoft.NET.Sdk.Web" + } + }, + { + "uid": "Codebelt.Extensions.Xunit.Hosting.AspNetCore.HttpClientExtensions", + "sourceSha256": "FABF1EB669FF7CC6B2BDB803E7CC6120EF9FE117823C720690A57522435C1468", + "manifest": { + "schemaVersion": 1, + "mode": "console", + "framework": "net10.0", + "dependsOn": [ + "Codebelt.Extensions.Xunit.Hosting.AspNetCore@13.0.0", + "Microsoft.Extensions.Hosting@10.0.15", + "Microsoft.AspNetCore.TestHost@10.0.15" + ], + "frameworkReferences": [ + "Microsoft.AspNetCore.App" + ], + "sdk": "Microsoft.NET.Sdk.Web" + } + }, + { + "uid": "Codebelt.Extensions.Xunit.Hosting.AspNetCore.ManagedWebApplicationFixture`1", + "sourceSha256": "8A75CECB985C8FCE6F9C0C1211311D40867D82B83ED060008D75E7A3F963EFE3", + "repository": "codebeltnet/xunit", + "commit": "84b13767cb9484f8f3a36a71875662edfdb3e511", + "project": "test/Codebelt.Extensions.Xunit.Hosting.AspNetCore.FunctionalTests/Codebelt.Extensions.Xunit.Hosting.AspNetCore.FunctionalTests.csproj", + "test": "Codebelt.Extensions.Xunit.Hosting.AspNetCore.WebApplicationTestTest.ShouldBootstrapApplication_WhenEntryPointUsesModernProgramPattern", + "framework": "net11.0", + "image": "mcr.microsoft.com/dotnet/sdk:11.0", + "explanation": "The scripts start the maintained ASP.NET Core application through the same fixture and verify its HTTP response." + }, + { + "uid": "Codebelt.Extensions.Xunit.Hosting.AspNetCore.ManagedWebHostFixture", + "sourceSha256": "2CC0B80DE03471AD6DD8210B4FDF2FA037751EF8B38AD43B1C611FC553EDA979", + "manifest": { + "schemaVersion": 1, + "mode": "test", + "framework": "net10.0", + "dependsOn": [ + "Codebelt.Extensions.Xunit.Hosting.AspNetCore@13.0.0", + "Microsoft.Extensions.Hosting@10.0.15", + "xunit.v3@4.0.3" + ], + "frameworkReferences": [ + "Microsoft.AspNetCore.App" + ] + } + }, + { + "uid": "Codebelt.Extensions.Xunit.Hosting.AspNetCore.ManagedWebMinimalHostFixture", + "sourceSha256": "9D12413E06F45213763C5BAD14B3B2796097B1F773D18BDA1F8CBF90F7CF1268", + "manifest": { + "schemaVersion": 1, + "mode": "test", + "framework": "net10.0", + "dependsOn": [ + "Codebelt.Extensions.Xunit.Hosting.AspNetCore@13.0.0", + "Microsoft.Extensions.Hosting@10.0.15", + "xunit.v3@4.0.3" + ], + "frameworkReferences": [ + "Microsoft.AspNetCore.App" + ] + } + }, + { + "uid": "Codebelt.Extensions.Xunit.Hosting.AspNetCore.MinimalWebHostTestFactory", + "sourceSha256": "869F4EDAF75D120A8A7F73B37C8E87002B0B006BABF480ECA0BFDCD5939E1F73", + "manifest": { + "schemaVersion": 1, + "mode": "test", + "framework": "net10.0", + "dependsOn": [ + "Codebelt.Extensions.Xunit.Hosting.AspNetCore@13.0.0", + "Microsoft.Extensions.Hosting@10.0.15", + "xunit.v3@4.0.3" + ], + "frameworkReferences": [ + "Microsoft.AspNetCore.App" + ] + } + }, + { + "uid": "Codebelt.Extensions.Xunit.Hosting.AspNetCore.SelfManagedWebHostFixture", + "sourceSha256": "8C67EA9DD2F57A0DB37E7EE5E5516CE5655B61EE90C4097CFAE7EC8CD9B9F59D", + "manifest": { + "schemaVersion": 1, + "mode": "console", + "framework": "net10.0", + "dependsOn": [ + "Codebelt.Extensions.Xunit.Hosting.AspNetCore@13.0.0", + "Microsoft.AspNetCore.TestHost@10.0.15" + ], + "frameworkReferences": [ + "Microsoft.AspNetCore.App" + ], + "sdk": "Microsoft.NET.Sdk.Web" + } + }, + { + "uid": "Codebelt.Extensions.Xunit.Hosting.AspNetCore.SelfManagedWebMinimalHostFixture", + "sourceSha256": "BD4DED8434BE4E8F5C88402103358DBCC12C4548C89FC48C060587BDB9CE3C5C", + "manifest": { + "schemaVersion": 1, + "mode": "test", + "framework": "net10.0", + "dependsOn": [ + "Codebelt.Extensions.Xunit.Hosting.AspNetCore@13.0.0", + "Microsoft.Extensions.Hosting@10.0.15", + "Microsoft.AspNetCore.TestHost@10.0.15", + "xunit.v3@4.0.3" + ], + "frameworkReferences": [ + "Microsoft.AspNetCore.App" + ] + } + }, + { + "uid": "Codebelt.Extensions.Xunit.Hosting.AspNetCore.ServiceCollectionExtensions", + "sourceSha256": "FFE4DD6394228DC8E7DF1EF37C5377AF341AD84C0E18D3B83CFE51ED671CC8F0", + "manifest": { + "schemaVersion": 1, + "mode": "test", + "framework": "net10.0", + "dependsOn": [ + "Codebelt.Extensions.Xunit.Hosting.AspNetCore@13.0.0", + "xunit.v3@4.0.3" + ], + "frameworkReferences": [ + "Microsoft.AspNetCore.App" + ] + } + }, + { + "uid": "Codebelt.Extensions.Xunit.Hosting.AspNetCore.WebApplicationFixtureExtensions", + "sourceSha256": "9C8A41C5E80934D69DF60798533A7E8BE07CA4210608BBDD2230C757179A8EC5", + "manifest": { + "schemaVersion": 1, + "mode": "test", + "framework": "net10.0", + "dependsOn": [ + "Codebelt.Extensions.Xunit.Hosting.AspNetCore@13.0.0", + "Microsoft.Extensions.Hosting@10.0.15", + "xunit.v3@4.0.3" + ], + "frameworkReferences": [ + "Microsoft.AspNetCore.App" + ] + } + }, + { + "uid": "Codebelt.Extensions.Xunit.Hosting.AspNetCore.WebApplicationTestFactory", + "sourceSha256": "1DB1DAAA9965BF42F736A4BC3788B4261DF4EF52799B83E6F733AB1BD53EA7D3", + "repository": "codebeltnet/xunit", + "commit": "84b13767cb9484f8f3a36a71875662edfdb3e511", + "project": "test/Codebelt.Extensions.Xunit.Hosting.AspNetCore.FunctionalTests/Codebelt.Extensions.Xunit.Hosting.AspNetCore.FunctionalTests.csproj", + "test": "Codebelt.Extensions.Xunit.Hosting.AspNetCore.WebApplicationTestFactoryTest.Create_ShouldApplyWebHostConfiguration_WhenWebHostSetupIsProvided", + "framework": "net11.0", + "image": "mcr.microsoft.com/dotnet/sdk:11.0", + "explanation": "The scripts run the maintained integration test, which overrides services and configuration and verifies the results through HTTP endpoints." + }, + { + "uid": "Codebelt.Extensions.Xunit.Hosting.AspNetCore.WebHostFixtureExtensions", + "sourceSha256": "CEDFFF39E914FF47421AE5A4F37CA1564DCAC8252903585B3B53DB069663492B", + "manifest": { + "schemaVersion": 1, + "mode": "test", + "framework": "net10.0", + "dependsOn": [ + "Codebelt.Extensions.Xunit.Hosting.AspNetCore@13.0.0", + "Microsoft.Extensions.Hosting@10.0.15", + "xunit.v3@4.0.3" + ], + "frameworkReferences": [ + "Microsoft.AspNetCore.App" + ] + } + }, + { + "uid": "Codebelt.Extensions.Xunit.Hosting.AspNetCore.WebHostTestFactory", + "sourceSha256": "F2DCAE2A6B67B77ADED3A2B726B4ABA20276D3C0FBDFB57F153447D8312005EE", + "manifest": { + "schemaVersion": 1, + "mode": "test", + "framework": "net10.0", + "dependsOn": [ + "Codebelt.Extensions.Xunit.Hosting.AspNetCore@13.0.0", + "Microsoft.Extensions.Hosting@10.0.15", + "xunit.v3@4.0.3" + ], + "frameworkReferences": [ + "Microsoft.AspNetCore.App" + ] + } + }, + { + "uid": "Codebelt.Extensions.Xunit.Hosting.AspNetCore.WebMinimalHostFixtureExtensions", + "sourceSha256": "F30F392FC9E68CBA4BCCB949F0CF36307DCC6A0FFF2DEA05F4641ACB4EA13900", + "manifest": { + "schemaVersion": 1, + "mode": "test", + "framework": "net10.0", + "dependsOn": [ + "Codebelt.Extensions.Xunit.Hosting.AspNetCore@13.0.0", + "Microsoft.Extensions.Hosting@10.0.15", + "xunit.v3@4.0.3" + ], + "frameworkReferences": [ + "Microsoft.AspNetCore.App" + ] + } + }, + { + "uid": "Codebelt.Extensions.Xunit.Hosting.GenericHostFixtureExtensions", + "sourceSha256": "6DA99A91947A5C64953DDD8F7B42EC74AE39C3EDFBF9F2DB69A31B9B2D0B90AC", + "manifest": { + "schemaVersion": 1, + "mode": "test", + "framework": "net10.0", + "dependsOn": [ + "Codebelt.Extensions.Xunit.Hosting@13.0.0", + "Microsoft.Extensions.Hosting@10.0.15", + "xunit.v3@4.0.3" + ] + } + }, + { + "uid": "Codebelt.Extensions.Xunit.Hosting.HostTestFactory", + "sourceSha256": "DBB1A94CF50D0C71616D4482DFD2FF1A4D5F8EA387340B6D4C98A5A4F84E6652", + "manifest": { + "schemaVersion": 1, + "mode": "test", + "framework": "net10.0", + "dependsOn": [ + "Codebelt.Extensions.Xunit.Hosting@13.0.0", + "Microsoft.Extensions.Hosting@10.0.15", + "xunit.v3@4.0.3" + ] + } + }, + { + "uid": "Codebelt.Extensions.Xunit.Hosting.LoggerExtensions", + "sourceSha256": "D2C65C928AF86623AF7F8B754C254F1A64B7FEB61F6168559FD1FC1862A08DEB", + "manifest": { + "schemaVersion": 1, + "mode": "test", + "framework": "net10.0", + "dependsOn": [ + "Codebelt.Extensions.Xunit.Hosting@13.0.0", + "Microsoft.Extensions.Hosting@10.0.15", + "xunit.v3@4.0.3" + ] + } + }, + { + "uid": "Codebelt.Extensions.Xunit.Hosting.ManagedApplicationFixture`1", + "sourceSha256": "47B0C1FBA94E7B43C8753D0A8242801B328E6B463B6EEDAEB640D4F8A262633E", + "repository": "codebeltnet/xunit", + "commit": "84b13767cb9484f8f3a36a71875662edfdb3e511", + "project": "test/Codebelt.Extensions.Xunit.Hosting.FunctionalTests/Codebelt.Extensions.Xunit.Hosting.FunctionalTests.csproj", + "test": "Codebelt.Extensions.Xunit.Hosting.BootstrapperMinimalWorkerApplicationTestTest.ShouldBootstrapMinimalWorkerProgram", + "framework": "net11.0", + "image": "mcr.microsoft.com/dotnet/sdk:11.0", + "explanation": "The scripts run this test in its original application and test projects." + }, + { + "uid": "Codebelt.Extensions.Xunit.Hosting.ManagedHostFixture", + "sourceSha256": "6F9E6E2F82AB916A7A36CC2259AA97366A800843E8B1913EE7C2D79580861DA8", + "manifest": { + "schemaVersion": 1, + "mode": "test", + "framework": "net10.0", + "dependsOn": [ + "Codebelt.Extensions.Xunit.Hosting@13.0.0", + "Microsoft.Extensions.Hosting@10.0.15", + "xunit.v3@4.0.3" + ] + } + }, + { + "uid": "Codebelt.Extensions.Xunit.Hosting.ManagedMinimalHostFixture", + "sourceSha256": "D0D64093FAF614E7658650534934F6771BB45486D43E7A241D573347840E6DBE", + "manifest": { + "schemaVersion": 1, + "mode": "test", + "framework": "net10.0", + "dependsOn": [ + "Codebelt.Extensions.Xunit.Hosting@13.0.0", + "Microsoft.Extensions.Hosting@10.0.15", + "xunit.v3@4.0.3" + ] + } + }, + { + "uid": "Codebelt.Extensions.Xunit.Hosting.MinimalHostFixtureExtensions", + "sourceSha256": "47A5CB15CC0563C81176ADE58748B75704DA88BCA3549BEF914BD63CED52125C", + "manifest": { + "schemaVersion": 1, + "mode": "test", + "framework": "net10.0", + "dependsOn": [ + "Codebelt.Extensions.Xunit.Hosting@13.0.0", + "Microsoft.Extensions.Hosting@10.0.15", + "xunit.v3@4.0.3" + ] + } + }, + { + "uid": "Codebelt.Extensions.Xunit.Hosting.MinimalHostTestFactory", + "sourceSha256": "45A7CCD7F1EF9A48A33565AEAC7B5A005AD4AA11E12ADD506911B10614205E87", + "manifest": { + "schemaVersion": 1, + "mode": "console", + "framework": "net10.0", + "dependsOn": [ + "Codebelt.Extensions.Xunit.Hosting@13.0.0", + "Microsoft.Extensions.Hosting@10.0.15" + ] + } + }, + { + "uid": "Codebelt.Extensions.Xunit.Hosting.SelfManagedHostFixture", + "sourceSha256": "7B4FC8E01BFCFACAF488EB329E5F50B3F9EEB7F42BF26D59D54C6F69754FB32B", + "manifest": { + "schemaVersion": 1, + "mode": "test", + "framework": "net10.0", + "dependsOn": [ + "Codebelt.Extensions.Xunit.Hosting@13.0.0", + "Microsoft.Extensions.Hosting@10.0.15", + "xunit.v3@4.0.3" + ] + } + }, + { + "uid": "Codebelt.Extensions.Xunit.Hosting.SelfManagedMinimalHostFixture", + "sourceSha256": "E1641265DF178540A21BD769CA1A9CD162901D03813C9D723B18349652B19A6B", + "manifest": { + "schemaVersion": 1, + "mode": "test", + "framework": "net10.0", + "dependsOn": [ + "Codebelt.Extensions.Xunit.Hosting@13.0.0", + "Microsoft.Extensions.Hosting@10.0.15", + "xunit.v3@4.0.3" + ] + } + }, + { + "uid": "Codebelt.Extensions.Xunit.Hosting.ServiceCollectionExtensions", + "sourceSha256": "96463CFB4DADE2AA027CBD21C1A8E380C83914669832CEE2C447DEDDCCAFC9C6", + "manifest": { + "schemaVersion": 1, + "mode": "test", + "framework": "net10.0", + "dependsOn": [ + "Codebelt.Extensions.Xunit.Hosting@13.0.0", + "Microsoft.Extensions.Hosting@10.0.15", + "xunit.v3@4.0.3" + ] + } + }, + { + "uid": "Codebelt.Extensions.Xunit.Hosting.ServiceProviderExtensions", + "sourceSha256": "C9C4438BD3D356FA0C39F5F86FAF6E984D9A1253A0A5D8EAEAD280AAAB31569B", + "manifest": { + "schemaVersion": 1, + "mode": "test", + "framework": "net10.0", + "dependsOn": [ + "Codebelt.Extensions.Xunit.Hosting@13.0.0", + "Microsoft.Extensions.Hosting@10.0.15", + "xunit.v3@4.0.3" + ] + } + }, + { + "uid": "Codebelt.Extensions.Xunit.Hosting.XunitTestLoggerEntry", + "sourceSha256": "5DBC97E4CD56C7D3072FE73E9BBA6F90326CFE7952A57823024464DA85802D3C", + "manifest": { + "schemaVersion": 1, + "mode": "test", + "framework": "net10.0", + "dependsOn": [ + "Codebelt.Extensions.Xunit.Hosting@13.0.0", + "Microsoft.Extensions.Hosting@10.0.15", + "xunit.v3@4.0.3" + ] + } + }, + { + "uid": "Codebelt.Extensions.Xunit.InMemoryTestStore`1", + "sourceSha256": "71987946D4476C5106392E6DB007FE7B11CFE39D4EAA4CA1B04539D1EC7C7F7C", + "manifest": { + "schemaVersion": 1, + "mode": "test", + "framework": "net10.0", + "dependsOn": [ + "Codebelt.Extensions.Xunit@13.0.0", + "xunit.v3@4.0.3" + ] + } + }, + { + "uid": "Codebelt.Extensions.Xunit.PriorityAttribute", + "sourceSha256": "93FF0CA8DBB21BE3475B9DED2131644055C82C6BF81A6D5F51DE91564C44FD78", + "manifest": { + "schemaVersion": 1, + "mode": "test", + "framework": "net10.0", + "dependsOn": [ + "Codebelt.Extensions.Xunit@13.0.0", + "xunit.v3@4.0.3" + ] + } + }, + { + "uid": "Codebelt.Extensions.Xunit.PriorityTestMethodOrderer", + "sourceSha256": "8A21672EB35CB508A5A70D51D8813A009DE6C9B7099E766FDA6BBF8A6DA360BF", + "manifest": { + "schemaVersion": 1, + "mode": "test", + "framework": "net10.0", + "dependsOn": [ + "Codebelt.Extensions.Xunit@13.0.0", + "xunit.v3@4.0.3" + ] + } + }, + { + "uid": "Codebelt.Extensions.Xunit.TestOutputHelperAccessor", + "sourceSha256": "4C6461C6EBDE9468850148117F4972F3C9C25E6F22138521AAB7852B60162109", + "manifest": { + "schemaVersion": 1, + "mode": "test", + "framework": "net10.0", + "dependsOn": [ + "Codebelt.Extensions.Xunit@13.0.0", + "xunit.v3@4.0.3" + ] + } + }, + { + "uid": "Codebelt.Extensions.Xunit.TestOutputHelperExtensions", + "sourceSha256": "BE11774854DE0AF823285BDCAD5BF6B02FD6CFF9D1673B10C6F0CE3D043E5799", + "manifest": { + "schemaVersion": 1, + "mode": "test", + "framework": "net10.0", + "dependsOn": [ + "Codebelt.Extensions.Xunit@13.0.0", + "xunit.v3@4.0.3" + ] + } + }, + { + "uid": "Codebelt.Extensions.Xunit.TestOutputHelperExtensions.WriteLines(Xunit.ITestOutputHelper,System.Object[])", + "sourceSha256": "985FBA10ABE737D5BEE72A19B028BCA6739A84C7B790695AEEC66BCC73BE7713", + "manifest": { + "schemaVersion": 1, + "mode": "test", + "framework": "net10.0", + "dependsOn": [ + "Codebelt.Extensions.Xunit@13.0.0", + "xunit.v3@4.0.3" + ] + } + }, + { + "uid": "Codebelt.Extensions.Xunit.TestOutputHelperExtensions.WriteLines``1(Xunit.ITestOutputHelper,``0[])", + "sourceSha256": "32E90B18345F4AF2EDBA67EDA4F5D6B231292147F40B9B541243F22A2DE71426", + "manifest": { + "schemaVersion": 1, + "mode": "test", + "framework": "net10.0", + "dependsOn": [ + "Codebelt.Extensions.Xunit@13.0.0", + "xunit.v3@4.0.3" + ] + } + }, + { + "uid": "Codebelt.Extensions.Xunit.TestOutputHelperExtensions.WriteLines``1(Xunit.ITestOutputHelper,System.Collections.Generic.IEnumerable{``0})", + "sourceSha256": "6BF4CBD17324584A087D6EF92F873474DD288AA42EAB5DB33665CADCFEF49734", + "manifest": { + "schemaVersion": 1, + "mode": "test", + "framework": "net10.0", + "dependsOn": [ + "Codebelt.Extensions.Xunit@13.0.0", + "xunit.v3@4.0.3" + ] + } + }, + { + "uid": "Codebelt.Extensions.Xunit.WildcardOptions", + "sourceSha256": "9E421444D2AB0A979A150637043D0070DCB60D5517C3E595AB902F7C3A7A17E9", + "manifest": { + "schemaVersion": 1, + "mode": "test", + "framework": "net10.0", + "dependsOn": [ + "Codebelt.Extensions.Xunit@13.0.0", + "xunit.v3@4.0.3" + ] + } + } + ] +} diff --git a/.docfx/run-actions/00acdae546dce87b654496e1/docker.ps1 b/.docfx/run-actions/00acdae546dce87b654496e1/docker.ps1 new file mode 100644 index 0000000..d35b2e4 --- /dev/null +++ b/.docfx/run-actions/00acdae546dce87b654496e1/docker.ps1 @@ -0,0 +1,86 @@ +& { +#requires -Version 7.0 +$ErrorActionPreference = 'Stop' +$PSNativeCommandUseErrorActionPreference = $false +$manifest = @' +{ + "dependsOn": [ + "Codebelt.Extensions.Xunit.Hosting.AspNetCore@13.0.0", + "Microsoft.Extensions.Hosting@10.0.15", + "xunit.v3@4.0.3" + ], + "framework": "net10.0", + "frameworkReferences": [ + "Microsoft.AspNetCore.App" + ], + "mode": "test", + "schemaVersion": 1, + "source": "using System.Threading.Tasks;\nusing Codebelt.Extensions.Xunit.Hosting.AspNetCore;\nusing Microsoft.AspNetCore.Builder;\nusing Microsoft.AspNetCore.Http;\nusing Microsoft.Extensions.DependencyInjection;\nusing Microsoft.Extensions.Hosting;\nusing Xunit;\n\nnamespace WebFixtureTests;\n\npublic class MinimalApiTest : MinimalWebHostTest\n{\n public MinimalApiTest(ManagedWebMinimalHostFixture hostFixture, ITestOutputHelper output) : base(hostFixture, output)\n {\n }\n\n protected override void ConfigureHost(IHostApplicationBuilder hb)\n {\n hb.Services.AddFakeHttpContextAccessor();\n }\n\n public override void ConfigureApplication(IApplicationBuilder app)\n {\n app.UseMiddleware();\n }\n}\n\npublic class TestMiddleware(RequestDelegate next)\n{\n public async Task InvokeAsync(HttpContext context)\n {\n context.Response.Headers[\"X-Test\"] = \"true\";\n await next(context);\n }\n}\n\npublic sealed class RunExample(ManagedWebMinimalHostFixture fixture, ITestOutputHelper output) : MinimalApiTest(fixture, output)\n{\n [Fact]\n public async Task BuildsAndInvokesTheConfiguredPipeline()\n {\n var context = new DefaultHttpContext\n {\n RequestServices = Application.ApplicationServices\n };\n await Application.Build()(context);\n Assert.Equal(\"true\", context.Response.Headers[\"X-Test\"].ToString());\n Assert.NotNull(context.RequestServices.GetRequiredService());\n }\n}" +} +'@ +$OutputEncoding = [Text.UTF8Encoding]::new($false) +[Console]::OutputEncoding = $OutputEncoding +$verifyTests = $true +function Assert-CsrunTestOutput([string] $Output) { + $lines = @($Output -split '\r?\n') + $headers = @($lines | Where-Object { $_ -match '^Test run summary: Passed! - .+\)$' }) + if ($headers.Count -ne 1) { throw 'Expected exactly one completed xUnit test summary.' } + $headerIndex = [Array]::IndexOf($lines, $headers[0]) + $summaryLines = @($lines | Select-Object -Skip ($headerIndex + 1) -First 4) + $counts = @{} + foreach ($line in $summaryLines) { + if ($line -match '^\s*(total|failed|succeeded|skipped):\s*(\d+)\s*$') { $counts[$Matches[1]] = [int]$Matches[2] } + } + if ($counts.Count -ne 4) { throw 'The xUnit test summary counts are incomplete or ambiguous.' } + $failed = $counts.failed + $passed = $counts.succeeded + $skipped = $counts.skipped + $total = $counts.total + if ($total -lt 1 -or $passed -lt 1 -or $failed -ne 0 -or $skipped -ne 0 -or $passed -ne $total) { + throw 'Tests must execute at least once, all pass, and none fail or skip.' + } +} +# Downloads and executes the latest stable csrun release with your permissions. +# Source and release history: https://github.com/codebeltnet/csrun +$engineDirectory = Join-Path ([IO.Path]::GetTempPath()) ('csrun-' + [guid]::NewGuid().ToString('N')) +$null = New-Item -ItemType Directory -Path $engineDirectory +$enginePath = Join-Path $engineDirectory 'csrun.ps1' +$process = $null +try { + $release = Invoke-RestMethod 'https://api.github.com/repos/codebeltnet/csrun/releases/latest' + $assets = @($release.assets | Where-Object name -CEQ 'csrun.ps1') + if ($assets.Count -ne 1 -or $assets[0].digest -notmatch '^sha256:[0-9a-f]{64}$') { + throw "csrun release $($release.tag_name) must publish one csrun.ps1 asset with a SHA-256 digest." + } + $asset = $assets[0] + Invoke-WebRequest $asset.browser_download_url -OutFile $enginePath + $actualHash = (Get-FileHash -LiteralPath $enginePath -Algorithm SHA256).Hash + if ("sha256:$actualHash" -ne $asset.digest) { throw "csrun asset checksum mismatch: $actualHash" } +$enginePayload = [Convert]::ToBase64String([IO.File]::ReadAllBytes($enginePath)) +$containerInput = $enginePayload + "`n" + $manifest +$command = ' +$ErrorActionPreference = "Stop" +$enginePath = Join-Path ([IO.Path]::GetTempPath()) ("csrun-release-" + [guid]::NewGuid().ToString("N") + ".ps1") +$engineBytes = [Convert]::FromBase64String([Console]::In.ReadLine()) +[IO.File]::WriteAllBytes($enginePath, $engineBytes) +$manifest = [Console]::In.ReadToEnd() +& $enginePath -ManifestJson $manifest +exit $LASTEXITCODE +' +$output = (@($containerInput | & docker run --rm -i --entrypoint pwsh 'codebeltnet/csrun:10' -NoProfile -NonInteractive -Command $command) -join [Environment]::NewLine) +$process = [pscustomobject]@{ ExitCode = $LASTEXITCODE } +$diagnostics = '' +Write-Output $output +} catch { + [Console]::Error.WriteLine("csrun diagnostics retained in: $engineDirectory") + throw +} finally { + $resolvedTemp = [IO.Path]::TrimEndingDirectorySeparator([IO.Path]::GetFullPath([IO.Path]::GetTempPath())) + $resolvedEngineDirectory = [IO.Path]::GetFullPath($engineDirectory) + if ([IO.Path]::GetDirectoryName($resolvedEngineDirectory) -ne $resolvedTemp -or + [IO.Path]::GetFileName($resolvedEngineDirectory) -cnotmatch '^csrun-[a-f0-9]{32}$') { throw 'Unsafe cleanup path.' } + if ($process -and $process.ExitCode -eq 0) { Remove-Item -LiteralPath $resolvedEngineDirectory -Recurse -Force } +} +if ($process.ExitCode -ne 0) { throw "csrun execution failed with exit code $($process.ExitCode). $diagnostics" } +if ($verifyTests) { Assert-CsrunTestOutput $output } +} \ No newline at end of file diff --git a/.docfx/run-actions/00acdae546dce87b654496e1/native.ps1 b/.docfx/run-actions/00acdae546dce87b654496e1/native.ps1 new file mode 100644 index 0000000..40d9529 --- /dev/null +++ b/.docfx/run-actions/00acdae546dce87b654496e1/native.ps1 @@ -0,0 +1,89 @@ +& { +#requires -Version 7.0 +$ErrorActionPreference = 'Stop' +$PSNativeCommandUseErrorActionPreference = $false +$manifest = @' +{ + "dependsOn": [ + "Codebelt.Extensions.Xunit.Hosting.AspNetCore@13.0.0", + "Microsoft.Extensions.Hosting@10.0.15", + "xunit.v3@4.0.3" + ], + "framework": "net10.0", + "frameworkReferences": [ + "Microsoft.AspNetCore.App" + ], + "mode": "test", + "schemaVersion": 1, + "source": "using System.Threading.Tasks;\nusing Codebelt.Extensions.Xunit.Hosting.AspNetCore;\nusing Microsoft.AspNetCore.Builder;\nusing Microsoft.AspNetCore.Http;\nusing Microsoft.Extensions.DependencyInjection;\nusing Microsoft.Extensions.Hosting;\nusing Xunit;\n\nnamespace WebFixtureTests;\n\npublic class MinimalApiTest : MinimalWebHostTest\n{\n public MinimalApiTest(ManagedWebMinimalHostFixture hostFixture, ITestOutputHelper output) : base(hostFixture, output)\n {\n }\n\n protected override void ConfigureHost(IHostApplicationBuilder hb)\n {\n hb.Services.AddFakeHttpContextAccessor();\n }\n\n public override void ConfigureApplication(IApplicationBuilder app)\n {\n app.UseMiddleware();\n }\n}\n\npublic class TestMiddleware(RequestDelegate next)\n{\n public async Task InvokeAsync(HttpContext context)\n {\n context.Response.Headers[\"X-Test\"] = \"true\";\n await next(context);\n }\n}\n\npublic sealed class RunExample(ManagedWebMinimalHostFixture fixture, ITestOutputHelper output) : MinimalApiTest(fixture, output)\n{\n [Fact]\n public async Task BuildsAndInvokesTheConfiguredPipeline()\n {\n var context = new DefaultHttpContext\n {\n RequestServices = Application.ApplicationServices\n };\n await Application.Build()(context);\n Assert.Equal(\"true\", context.Response.Headers[\"X-Test\"].ToString());\n Assert.NotNull(context.RequestServices.GetRequiredService());\n }\n}" +} +'@ +$OutputEncoding = [Text.UTF8Encoding]::new($false) +[Console]::OutputEncoding = $OutputEncoding +$verifyTests = $true +function Assert-CsrunTestOutput([string] $Output) { + $lines = @($Output -split '\r?\n') + $headers = @($lines | Where-Object { $_ -match '^Test run summary: Passed! - .+\)$' }) + if ($headers.Count -ne 1) { throw 'Expected exactly one completed xUnit test summary.' } + $headerIndex = [Array]::IndexOf($lines, $headers[0]) + $summaryLines = @($lines | Select-Object -Skip ($headerIndex + 1) -First 4) + $counts = @{} + foreach ($line in $summaryLines) { + if ($line -match '^\s*(total|failed|succeeded|skipped):\s*(\d+)\s*$') { $counts[$Matches[1]] = [int]$Matches[2] } + } + if ($counts.Count -ne 4) { throw 'The xUnit test summary counts are incomplete or ambiguous.' } + $failed = $counts.failed + $passed = $counts.succeeded + $skipped = $counts.skipped + $total = $counts.total + if ($total -lt 1 -or $passed -lt 1 -or $failed -ne 0 -or $skipped -ne 0 -or $passed -ne $total) { + throw 'Tests must execute at least once, all pass, and none fail or skip.' + } +} +# Downloads and executes the latest stable csrun release with your permissions. +# Source and release history: https://github.com/codebeltnet/csrun +$engineDirectory = Join-Path ([IO.Path]::GetTempPath()) ('csrun-' + [guid]::NewGuid().ToString('N')) +$null = New-Item -ItemType Directory -Path $engineDirectory +$enginePath = Join-Path $engineDirectory 'csrun.ps1' +$process = $null +try { + $release = Invoke-RestMethod 'https://api.github.com/repos/codebeltnet/csrun/releases/latest' + $assets = @($release.assets | Where-Object name -CEQ 'csrun.ps1') + if ($assets.Count -ne 1 -or $assets[0].digest -notmatch '^sha256:[0-9a-f]{64}$') { + throw "csrun release $($release.tag_name) must publish one csrun.ps1 asset with a SHA-256 digest." + } + $asset = $assets[0] + Invoke-WebRequest $asset.browser_download_url -OutFile $enginePath + $actualHash = (Get-FileHash -LiteralPath $enginePath -Algorithm SHA256).Hash + if ("sha256:$actualHash" -ne $asset.digest) { throw "csrun asset checksum mismatch: $actualHash" } +$startInfo = [Diagnostics.ProcessStartInfo]::new('pwsh') +foreach ($argument in @('-NoProfile','-NonInteractive','-File')) { $startInfo.ArgumentList.Add($argument) } +$startInfo.ArgumentList.Add($enginePath) +$startInfo.ArgumentList.Add('-ManifestJson') +$startInfo.ArgumentList.Add($manifest) +$startInfo.RedirectStandardOutput = $true +$startInfo.RedirectStandardError = $true +$startInfo.UseShellExecute = $false +$process = [Diagnostics.Process]::new() +$process.StartInfo = $startInfo +if (-not $process.Start()) { throw 'Could not start csrun.' } +$stdoutTask = $process.StandardOutput.ReadToEndAsync() +$stderrTask = $process.StandardError.ReadToEndAsync() +$process.WaitForExit() +$output = $stdoutTask.GetAwaiter().GetResult() +$diagnostics = $stderrTask.GetAwaiter().GetResult() +Write-Output $output +if ($diagnostics) { [Console]::Error.Write($diagnostics) } +} catch { + [Console]::Error.WriteLine("csrun diagnostics retained in: $engineDirectory") + throw +} finally { + $resolvedTemp = [IO.Path]::TrimEndingDirectorySeparator([IO.Path]::GetFullPath([IO.Path]::GetTempPath())) + $resolvedEngineDirectory = [IO.Path]::GetFullPath($engineDirectory) + if ([IO.Path]::GetDirectoryName($resolvedEngineDirectory) -ne $resolvedTemp -or + [IO.Path]::GetFileName($resolvedEngineDirectory) -cnotmatch '^csrun-[a-f0-9]{32}$') { throw 'Unsafe cleanup path.' } + if ($process -and $process.ExitCode -eq 0) { Remove-Item -LiteralPath $resolvedEngineDirectory -Recurse -Force } +} +if ($process.ExitCode -ne 0) { throw "csrun execution failed with exit code $($process.ExitCode). $diagnostics" } +if ($verifyTests) { Assert-CsrunTestOutput $output } +} \ No newline at end of file diff --git a/.docfx/run-actions/0308118a47b5c02daa7b32be/docker.ps1 b/.docfx/run-actions/0308118a47b5c02daa7b32be/docker.ps1 new file mode 100644 index 0000000..681fa8d --- /dev/null +++ b/.docfx/run-actions/0308118a47b5c02daa7b32be/docker.ps1 @@ -0,0 +1,82 @@ +& { +#requires -Version 7.0 +$ErrorActionPreference = 'Stop' +$PSNativeCommandUseErrorActionPreference = $false +$manifest = @' +{ + "dependsOn": [ + "Codebelt.Extensions.Xunit@13.0.0", + "xunit.v3@4.0.3" + ], + "framework": "net10.0", + "mode": "test", + "schemaVersion": 1, + "source": "using System.Collections.Generic;\nusing Codebelt.Extensions.Xunit;\nusing Xunit;\n\nnamespace Example.Tests;\n\npublic class EnumerableOutputTest : Test\n{\n public EnumerableOutputTest(ITestOutputHelper output) : base(output) { }\n\n [Fact]\n public void ShouldWriteSequenceItems()\n {\n IEnumerable values = new List { 1, 2, 3 };\n TestOutput.WriteLines(values);\n Assert.True(HasTestOutput);\n }\n}" +} +'@ +$OutputEncoding = [Text.UTF8Encoding]::new($false) +[Console]::OutputEncoding = $OutputEncoding +$verifyTests = $true +function Assert-CsrunTestOutput([string] $Output) { + $lines = @($Output -split '\r?\n') + $headers = @($lines | Where-Object { $_ -match '^Test run summary: Passed! - .+\)$' }) + if ($headers.Count -ne 1) { throw 'Expected exactly one completed xUnit test summary.' } + $headerIndex = [Array]::IndexOf($lines, $headers[0]) + $summaryLines = @($lines | Select-Object -Skip ($headerIndex + 1) -First 4) + $counts = @{} + foreach ($line in $summaryLines) { + if ($line -match '^\s*(total|failed|succeeded|skipped):\s*(\d+)\s*$') { $counts[$Matches[1]] = [int]$Matches[2] } + } + if ($counts.Count -ne 4) { throw 'The xUnit test summary counts are incomplete or ambiguous.' } + $failed = $counts.failed + $passed = $counts.succeeded + $skipped = $counts.skipped + $total = $counts.total + if ($total -lt 1 -or $passed -lt 1 -or $failed -ne 0 -or $skipped -ne 0 -or $passed -ne $total) { + throw 'Tests must execute at least once, all pass, and none fail or skip.' + } +} +# Downloads and executes the latest stable csrun release with your permissions. +# Source and release history: https://github.com/codebeltnet/csrun +$engineDirectory = Join-Path ([IO.Path]::GetTempPath()) ('csrun-' + [guid]::NewGuid().ToString('N')) +$null = New-Item -ItemType Directory -Path $engineDirectory +$enginePath = Join-Path $engineDirectory 'csrun.ps1' +$process = $null +try { + $release = Invoke-RestMethod 'https://api.github.com/repos/codebeltnet/csrun/releases/latest' + $assets = @($release.assets | Where-Object name -CEQ 'csrun.ps1') + if ($assets.Count -ne 1 -or $assets[0].digest -notmatch '^sha256:[0-9a-f]{64}$') { + throw "csrun release $($release.tag_name) must publish one csrun.ps1 asset with a SHA-256 digest." + } + $asset = $assets[0] + Invoke-WebRequest $asset.browser_download_url -OutFile $enginePath + $actualHash = (Get-FileHash -LiteralPath $enginePath -Algorithm SHA256).Hash + if ("sha256:$actualHash" -ne $asset.digest) { throw "csrun asset checksum mismatch: $actualHash" } +$enginePayload = [Convert]::ToBase64String([IO.File]::ReadAllBytes($enginePath)) +$containerInput = $enginePayload + "`n" + $manifest +$command = ' +$ErrorActionPreference = "Stop" +$enginePath = Join-Path ([IO.Path]::GetTempPath()) ("csrun-release-" + [guid]::NewGuid().ToString("N") + ".ps1") +$engineBytes = [Convert]::FromBase64String([Console]::In.ReadLine()) +[IO.File]::WriteAllBytes($enginePath, $engineBytes) +$manifest = [Console]::In.ReadToEnd() +& $enginePath -ManifestJson $manifest +exit $LASTEXITCODE +' +$output = (@($containerInput | & docker run --rm -i --entrypoint pwsh 'codebeltnet/csrun:10' -NoProfile -NonInteractive -Command $command) -join [Environment]::NewLine) +$process = [pscustomobject]@{ ExitCode = $LASTEXITCODE } +$diagnostics = '' +Write-Output $output +} catch { + [Console]::Error.WriteLine("csrun diagnostics retained in: $engineDirectory") + throw +} finally { + $resolvedTemp = [IO.Path]::TrimEndingDirectorySeparator([IO.Path]::GetFullPath([IO.Path]::GetTempPath())) + $resolvedEngineDirectory = [IO.Path]::GetFullPath($engineDirectory) + if ([IO.Path]::GetDirectoryName($resolvedEngineDirectory) -ne $resolvedTemp -or + [IO.Path]::GetFileName($resolvedEngineDirectory) -cnotmatch '^csrun-[a-f0-9]{32}$') { throw 'Unsafe cleanup path.' } + if ($process -and $process.ExitCode -eq 0) { Remove-Item -LiteralPath $resolvedEngineDirectory -Recurse -Force } +} +if ($process.ExitCode -ne 0) { throw "csrun execution failed with exit code $($process.ExitCode). $diagnostics" } +if ($verifyTests) { Assert-CsrunTestOutput $output } +} \ No newline at end of file diff --git a/.docfx/run-actions/0308118a47b5c02daa7b32be/native.ps1 b/.docfx/run-actions/0308118a47b5c02daa7b32be/native.ps1 new file mode 100644 index 0000000..0ca375d --- /dev/null +++ b/.docfx/run-actions/0308118a47b5c02daa7b32be/native.ps1 @@ -0,0 +1,85 @@ +& { +#requires -Version 7.0 +$ErrorActionPreference = 'Stop' +$PSNativeCommandUseErrorActionPreference = $false +$manifest = @' +{ + "dependsOn": [ + "Codebelt.Extensions.Xunit@13.0.0", + "xunit.v3@4.0.3" + ], + "framework": "net10.0", + "mode": "test", + "schemaVersion": 1, + "source": "using System.Collections.Generic;\nusing Codebelt.Extensions.Xunit;\nusing Xunit;\n\nnamespace Example.Tests;\n\npublic class EnumerableOutputTest : Test\n{\n public EnumerableOutputTest(ITestOutputHelper output) : base(output) { }\n\n [Fact]\n public void ShouldWriteSequenceItems()\n {\n IEnumerable values = new List { 1, 2, 3 };\n TestOutput.WriteLines(values);\n Assert.True(HasTestOutput);\n }\n}" +} +'@ +$OutputEncoding = [Text.UTF8Encoding]::new($false) +[Console]::OutputEncoding = $OutputEncoding +$verifyTests = $true +function Assert-CsrunTestOutput([string] $Output) { + $lines = @($Output -split '\r?\n') + $headers = @($lines | Where-Object { $_ -match '^Test run summary: Passed! - .+\)$' }) + if ($headers.Count -ne 1) { throw 'Expected exactly one completed xUnit test summary.' } + $headerIndex = [Array]::IndexOf($lines, $headers[0]) + $summaryLines = @($lines | Select-Object -Skip ($headerIndex + 1) -First 4) + $counts = @{} + foreach ($line in $summaryLines) { + if ($line -match '^\s*(total|failed|succeeded|skipped):\s*(\d+)\s*$') { $counts[$Matches[1]] = [int]$Matches[2] } + } + if ($counts.Count -ne 4) { throw 'The xUnit test summary counts are incomplete or ambiguous.' } + $failed = $counts.failed + $passed = $counts.succeeded + $skipped = $counts.skipped + $total = $counts.total + if ($total -lt 1 -or $passed -lt 1 -or $failed -ne 0 -or $skipped -ne 0 -or $passed -ne $total) { + throw 'Tests must execute at least once, all pass, and none fail or skip.' + } +} +# Downloads and executes the latest stable csrun release with your permissions. +# Source and release history: https://github.com/codebeltnet/csrun +$engineDirectory = Join-Path ([IO.Path]::GetTempPath()) ('csrun-' + [guid]::NewGuid().ToString('N')) +$null = New-Item -ItemType Directory -Path $engineDirectory +$enginePath = Join-Path $engineDirectory 'csrun.ps1' +$process = $null +try { + $release = Invoke-RestMethod 'https://api.github.com/repos/codebeltnet/csrun/releases/latest' + $assets = @($release.assets | Where-Object name -CEQ 'csrun.ps1') + if ($assets.Count -ne 1 -or $assets[0].digest -notmatch '^sha256:[0-9a-f]{64}$') { + throw "csrun release $($release.tag_name) must publish one csrun.ps1 asset with a SHA-256 digest." + } + $asset = $assets[0] + Invoke-WebRequest $asset.browser_download_url -OutFile $enginePath + $actualHash = (Get-FileHash -LiteralPath $enginePath -Algorithm SHA256).Hash + if ("sha256:$actualHash" -ne $asset.digest) { throw "csrun asset checksum mismatch: $actualHash" } +$startInfo = [Diagnostics.ProcessStartInfo]::new('pwsh') +foreach ($argument in @('-NoProfile','-NonInteractive','-File')) { $startInfo.ArgumentList.Add($argument) } +$startInfo.ArgumentList.Add($enginePath) +$startInfo.ArgumentList.Add('-ManifestJson') +$startInfo.ArgumentList.Add($manifest) +$startInfo.RedirectStandardOutput = $true +$startInfo.RedirectStandardError = $true +$startInfo.UseShellExecute = $false +$process = [Diagnostics.Process]::new() +$process.StartInfo = $startInfo +if (-not $process.Start()) { throw 'Could not start csrun.' } +$stdoutTask = $process.StandardOutput.ReadToEndAsync() +$stderrTask = $process.StandardError.ReadToEndAsync() +$process.WaitForExit() +$output = $stdoutTask.GetAwaiter().GetResult() +$diagnostics = $stderrTask.GetAwaiter().GetResult() +Write-Output $output +if ($diagnostics) { [Console]::Error.Write($diagnostics) } +} catch { + [Console]::Error.WriteLine("csrun diagnostics retained in: $engineDirectory") + throw +} finally { + $resolvedTemp = [IO.Path]::TrimEndingDirectorySeparator([IO.Path]::GetFullPath([IO.Path]::GetTempPath())) + $resolvedEngineDirectory = [IO.Path]::GetFullPath($engineDirectory) + if ([IO.Path]::GetDirectoryName($resolvedEngineDirectory) -ne $resolvedTemp -or + [IO.Path]::GetFileName($resolvedEngineDirectory) -cnotmatch '^csrun-[a-f0-9]{32}$') { throw 'Unsafe cleanup path.' } + if ($process -and $process.ExitCode -eq 0) { Remove-Item -LiteralPath $resolvedEngineDirectory -Recurse -Force } +} +if ($process.ExitCode -ne 0) { throw "csrun execution failed with exit code $($process.ExitCode). $diagnostics" } +if ($verifyTests) { Assert-CsrunTestOutput $output } +} \ No newline at end of file diff --git a/.docfx/run-actions/038a1c806225b412a6f986c1/docker.ps1 b/.docfx/run-actions/038a1c806225b412a6f986c1/docker.ps1 new file mode 100644 index 0000000..caaabc5 --- /dev/null +++ b/.docfx/run-actions/038a1c806225b412a6f986c1/docker.ps1 @@ -0,0 +1,82 @@ +& { +#requires -Version 7.0 +$ErrorActionPreference = 'Stop' +$PSNativeCommandUseErrorActionPreference = $false +$manifest = @' +{ + "dependsOn": [ + "Codebelt.Extensions.Xunit@13.0.0", + "xunit.v3@4.0.3" + ], + "framework": "net10.0", + "mode": "test", + "schemaVersion": 1, + "source": "using Codebelt.Extensions.Xunit;\nusing Xunit;\n\nnamespace Example.Tests;\n\npublic class WildcardExampleTest : Test\n{\n public WildcardExampleTest(ITestOutputHelper output) : base(output) { }\n\n [Fact]\n public void ShouldMatchConfiguredPattern()\n {\n var options = new WildcardOptions { ThrowOnNoMatch = true };\n Assert.True(Match(\"cache*\", \"cached\", setup => setup.ThrowOnNoMatch = options.ThrowOnNoMatch));\n }\n}" +} +'@ +$OutputEncoding = [Text.UTF8Encoding]::new($false) +[Console]::OutputEncoding = $OutputEncoding +$verifyTests = $true +function Assert-CsrunTestOutput([string] $Output) { + $lines = @($Output -split '\r?\n') + $headers = @($lines | Where-Object { $_ -match '^Test run summary: Passed! - .+\)$' }) + if ($headers.Count -ne 1) { throw 'Expected exactly one completed xUnit test summary.' } + $headerIndex = [Array]::IndexOf($lines, $headers[0]) + $summaryLines = @($lines | Select-Object -Skip ($headerIndex + 1) -First 4) + $counts = @{} + foreach ($line in $summaryLines) { + if ($line -match '^\s*(total|failed|succeeded|skipped):\s*(\d+)\s*$') { $counts[$Matches[1]] = [int]$Matches[2] } + } + if ($counts.Count -ne 4) { throw 'The xUnit test summary counts are incomplete or ambiguous.' } + $failed = $counts.failed + $passed = $counts.succeeded + $skipped = $counts.skipped + $total = $counts.total + if ($total -lt 1 -or $passed -lt 1 -or $failed -ne 0 -or $skipped -ne 0 -or $passed -ne $total) { + throw 'Tests must execute at least once, all pass, and none fail or skip.' + } +} +# Downloads and executes the latest stable csrun release with your permissions. +# Source and release history: https://github.com/codebeltnet/csrun +$engineDirectory = Join-Path ([IO.Path]::GetTempPath()) ('csrun-' + [guid]::NewGuid().ToString('N')) +$null = New-Item -ItemType Directory -Path $engineDirectory +$enginePath = Join-Path $engineDirectory 'csrun.ps1' +$process = $null +try { + $release = Invoke-RestMethod 'https://api.github.com/repos/codebeltnet/csrun/releases/latest' + $assets = @($release.assets | Where-Object name -CEQ 'csrun.ps1') + if ($assets.Count -ne 1 -or $assets[0].digest -notmatch '^sha256:[0-9a-f]{64}$') { + throw "csrun release $($release.tag_name) must publish one csrun.ps1 asset with a SHA-256 digest." + } + $asset = $assets[0] + Invoke-WebRequest $asset.browser_download_url -OutFile $enginePath + $actualHash = (Get-FileHash -LiteralPath $enginePath -Algorithm SHA256).Hash + if ("sha256:$actualHash" -ne $asset.digest) { throw "csrun asset checksum mismatch: $actualHash" } +$enginePayload = [Convert]::ToBase64String([IO.File]::ReadAllBytes($enginePath)) +$containerInput = $enginePayload + "`n" + $manifest +$command = ' +$ErrorActionPreference = "Stop" +$enginePath = Join-Path ([IO.Path]::GetTempPath()) ("csrun-release-" + [guid]::NewGuid().ToString("N") + ".ps1") +$engineBytes = [Convert]::FromBase64String([Console]::In.ReadLine()) +[IO.File]::WriteAllBytes($enginePath, $engineBytes) +$manifest = [Console]::In.ReadToEnd() +& $enginePath -ManifestJson $manifest +exit $LASTEXITCODE +' +$output = (@($containerInput | & docker run --rm -i --entrypoint pwsh 'codebeltnet/csrun:10' -NoProfile -NonInteractive -Command $command) -join [Environment]::NewLine) +$process = [pscustomobject]@{ ExitCode = $LASTEXITCODE } +$diagnostics = '' +Write-Output $output +} catch { + [Console]::Error.WriteLine("csrun diagnostics retained in: $engineDirectory") + throw +} finally { + $resolvedTemp = [IO.Path]::TrimEndingDirectorySeparator([IO.Path]::GetFullPath([IO.Path]::GetTempPath())) + $resolvedEngineDirectory = [IO.Path]::GetFullPath($engineDirectory) + if ([IO.Path]::GetDirectoryName($resolvedEngineDirectory) -ne $resolvedTemp -or + [IO.Path]::GetFileName($resolvedEngineDirectory) -cnotmatch '^csrun-[a-f0-9]{32}$') { throw 'Unsafe cleanup path.' } + if ($process -and $process.ExitCode -eq 0) { Remove-Item -LiteralPath $resolvedEngineDirectory -Recurse -Force } +} +if ($process.ExitCode -ne 0) { throw "csrun execution failed with exit code $($process.ExitCode). $diagnostics" } +if ($verifyTests) { Assert-CsrunTestOutput $output } +} \ No newline at end of file diff --git a/.docfx/run-actions/038a1c806225b412a6f986c1/native.ps1 b/.docfx/run-actions/038a1c806225b412a6f986c1/native.ps1 new file mode 100644 index 0000000..6da1af7 --- /dev/null +++ b/.docfx/run-actions/038a1c806225b412a6f986c1/native.ps1 @@ -0,0 +1,85 @@ +& { +#requires -Version 7.0 +$ErrorActionPreference = 'Stop' +$PSNativeCommandUseErrorActionPreference = $false +$manifest = @' +{ + "dependsOn": [ + "Codebelt.Extensions.Xunit@13.0.0", + "xunit.v3@4.0.3" + ], + "framework": "net10.0", + "mode": "test", + "schemaVersion": 1, + "source": "using Codebelt.Extensions.Xunit;\nusing Xunit;\n\nnamespace Example.Tests;\n\npublic class WildcardExampleTest : Test\n{\n public WildcardExampleTest(ITestOutputHelper output) : base(output) { }\n\n [Fact]\n public void ShouldMatchConfiguredPattern()\n {\n var options = new WildcardOptions { ThrowOnNoMatch = true };\n Assert.True(Match(\"cache*\", \"cached\", setup => setup.ThrowOnNoMatch = options.ThrowOnNoMatch));\n }\n}" +} +'@ +$OutputEncoding = [Text.UTF8Encoding]::new($false) +[Console]::OutputEncoding = $OutputEncoding +$verifyTests = $true +function Assert-CsrunTestOutput([string] $Output) { + $lines = @($Output -split '\r?\n') + $headers = @($lines | Where-Object { $_ -match '^Test run summary: Passed! - .+\)$' }) + if ($headers.Count -ne 1) { throw 'Expected exactly one completed xUnit test summary.' } + $headerIndex = [Array]::IndexOf($lines, $headers[0]) + $summaryLines = @($lines | Select-Object -Skip ($headerIndex + 1) -First 4) + $counts = @{} + foreach ($line in $summaryLines) { + if ($line -match '^\s*(total|failed|succeeded|skipped):\s*(\d+)\s*$') { $counts[$Matches[1]] = [int]$Matches[2] } + } + if ($counts.Count -ne 4) { throw 'The xUnit test summary counts are incomplete or ambiguous.' } + $failed = $counts.failed + $passed = $counts.succeeded + $skipped = $counts.skipped + $total = $counts.total + if ($total -lt 1 -or $passed -lt 1 -or $failed -ne 0 -or $skipped -ne 0 -or $passed -ne $total) { + throw 'Tests must execute at least once, all pass, and none fail or skip.' + } +} +# Downloads and executes the latest stable csrun release with your permissions. +# Source and release history: https://github.com/codebeltnet/csrun +$engineDirectory = Join-Path ([IO.Path]::GetTempPath()) ('csrun-' + [guid]::NewGuid().ToString('N')) +$null = New-Item -ItemType Directory -Path $engineDirectory +$enginePath = Join-Path $engineDirectory 'csrun.ps1' +$process = $null +try { + $release = Invoke-RestMethod 'https://api.github.com/repos/codebeltnet/csrun/releases/latest' + $assets = @($release.assets | Where-Object name -CEQ 'csrun.ps1') + if ($assets.Count -ne 1 -or $assets[0].digest -notmatch '^sha256:[0-9a-f]{64}$') { + throw "csrun release $($release.tag_name) must publish one csrun.ps1 asset with a SHA-256 digest." + } + $asset = $assets[0] + Invoke-WebRequest $asset.browser_download_url -OutFile $enginePath + $actualHash = (Get-FileHash -LiteralPath $enginePath -Algorithm SHA256).Hash + if ("sha256:$actualHash" -ne $asset.digest) { throw "csrun asset checksum mismatch: $actualHash" } +$startInfo = [Diagnostics.ProcessStartInfo]::new('pwsh') +foreach ($argument in @('-NoProfile','-NonInteractive','-File')) { $startInfo.ArgumentList.Add($argument) } +$startInfo.ArgumentList.Add($enginePath) +$startInfo.ArgumentList.Add('-ManifestJson') +$startInfo.ArgumentList.Add($manifest) +$startInfo.RedirectStandardOutput = $true +$startInfo.RedirectStandardError = $true +$startInfo.UseShellExecute = $false +$process = [Diagnostics.Process]::new() +$process.StartInfo = $startInfo +if (-not $process.Start()) { throw 'Could not start csrun.' } +$stdoutTask = $process.StandardOutput.ReadToEndAsync() +$stderrTask = $process.StandardError.ReadToEndAsync() +$process.WaitForExit() +$output = $stdoutTask.GetAwaiter().GetResult() +$diagnostics = $stderrTask.GetAwaiter().GetResult() +Write-Output $output +if ($diagnostics) { [Console]::Error.Write($diagnostics) } +} catch { + [Console]::Error.WriteLine("csrun diagnostics retained in: $engineDirectory") + throw +} finally { + $resolvedTemp = [IO.Path]::TrimEndingDirectorySeparator([IO.Path]::GetFullPath([IO.Path]::GetTempPath())) + $resolvedEngineDirectory = [IO.Path]::GetFullPath($engineDirectory) + if ([IO.Path]::GetDirectoryName($resolvedEngineDirectory) -ne $resolvedTemp -or + [IO.Path]::GetFileName($resolvedEngineDirectory) -cnotmatch '^csrun-[a-f0-9]{32}$') { throw 'Unsafe cleanup path.' } + if ($process -and $process.ExitCode -eq 0) { Remove-Item -LiteralPath $resolvedEngineDirectory -Recurse -Force } +} +if ($process.ExitCode -ne 0) { throw "csrun execution failed with exit code $($process.ExitCode). $diagnostics" } +if ($verifyTests) { Assert-CsrunTestOutput $output } +} \ No newline at end of file diff --git a/.docfx/run-actions/08b911ef79f0b743282e37c9/docker.ps1 b/.docfx/run-actions/08b911ef79f0b743282e37c9/docker.ps1 new file mode 100644 index 0000000..b7058b7 --- /dev/null +++ b/.docfx/run-actions/08b911ef79f0b743282e37c9/docker.ps1 @@ -0,0 +1,85 @@ +& { +#requires -Version 7.0 +$ErrorActionPreference = 'Stop' +$PSNativeCommandUseErrorActionPreference = $false +$manifest = @' +{ + "dependsOn": [ + "Codebelt.Extensions.Xunit.Hosting.AspNetCore@13.0.0" + ], + "framework": "net10.0", + "frameworkReferences": [ + "Microsoft.AspNetCore.App" + ], + "mode": "console", + "schemaVersion": 1, + "sdk": "Microsoft.NET.Sdk.Web", + "source": "using System;\nusing Codebelt.Extensions.Xunit.Hosting.AspNetCore.Http.Features;\n\nnamespace WebFixtureTests;\n\npublic class ResponseFeatureExample\n{\n public void Demonstrate()\n {\n var response = new FakeHttpResponseFeature();\n Console.WriteLine(response.StatusCode);\n }\n}\n\ninternal static class RunExample\n{\n static void Main()\n {\n new ResponseFeatureExample().Demonstrate();\n }\n}" +} +'@ +$OutputEncoding = [Text.UTF8Encoding]::new($false) +[Console]::OutputEncoding = $OutputEncoding +$verifyTests = $false +function Assert-CsrunTestOutput([string] $Output) { + $lines = @($Output -split '\r?\n') + $headers = @($lines | Where-Object { $_ -match '^Test run summary: Passed! - .+\)$' }) + if ($headers.Count -ne 1) { throw 'Expected exactly one completed xUnit test summary.' } + $headerIndex = [Array]::IndexOf($lines, $headers[0]) + $summaryLines = @($lines | Select-Object -Skip ($headerIndex + 1) -First 4) + $counts = @{} + foreach ($line in $summaryLines) { + if ($line -match '^\s*(total|failed|succeeded|skipped):\s*(\d+)\s*$') { $counts[$Matches[1]] = [int]$Matches[2] } + } + if ($counts.Count -ne 4) { throw 'The xUnit test summary counts are incomplete or ambiguous.' } + $failed = $counts.failed + $passed = $counts.succeeded + $skipped = $counts.skipped + $total = $counts.total + if ($total -lt 1 -or $passed -lt 1 -or $failed -ne 0 -or $skipped -ne 0 -or $passed -ne $total) { + throw 'Tests must execute at least once, all pass, and none fail or skip.' + } +} +# Downloads and executes the latest stable csrun release with your permissions. +# Source and release history: https://github.com/codebeltnet/csrun +$engineDirectory = Join-Path ([IO.Path]::GetTempPath()) ('csrun-' + [guid]::NewGuid().ToString('N')) +$null = New-Item -ItemType Directory -Path $engineDirectory +$enginePath = Join-Path $engineDirectory 'csrun.ps1' +$process = $null +try { + $release = Invoke-RestMethod 'https://api.github.com/repos/codebeltnet/csrun/releases/latest' + $assets = @($release.assets | Where-Object name -CEQ 'csrun.ps1') + if ($assets.Count -ne 1 -or $assets[0].digest -notmatch '^sha256:[0-9a-f]{64}$') { + throw "csrun release $($release.tag_name) must publish one csrun.ps1 asset with a SHA-256 digest." + } + $asset = $assets[0] + Invoke-WebRequest $asset.browser_download_url -OutFile $enginePath + $actualHash = (Get-FileHash -LiteralPath $enginePath -Algorithm SHA256).Hash + if ("sha256:$actualHash" -ne $asset.digest) { throw "csrun asset checksum mismatch: $actualHash" } +$enginePayload = [Convert]::ToBase64String([IO.File]::ReadAllBytes($enginePath)) +$containerInput = $enginePayload + "`n" + $manifest +$command = ' +$ErrorActionPreference = "Stop" +$enginePath = Join-Path ([IO.Path]::GetTempPath()) ("csrun-release-" + [guid]::NewGuid().ToString("N") + ".ps1") +$engineBytes = [Convert]::FromBase64String([Console]::In.ReadLine()) +[IO.File]::WriteAllBytes($enginePath, $engineBytes) +$manifest = [Console]::In.ReadToEnd() +& $enginePath -ManifestJson $manifest +exit $LASTEXITCODE +' +$output = (@($containerInput | & docker run --rm -i --entrypoint pwsh 'codebeltnet/csrun:10' -NoProfile -NonInteractive -Command $command) -join [Environment]::NewLine) +$process = [pscustomobject]@{ ExitCode = $LASTEXITCODE } +$diagnostics = '' +Write-Output $output +} catch { + [Console]::Error.WriteLine("csrun diagnostics retained in: $engineDirectory") + throw +} finally { + $resolvedTemp = [IO.Path]::TrimEndingDirectorySeparator([IO.Path]::GetFullPath([IO.Path]::GetTempPath())) + $resolvedEngineDirectory = [IO.Path]::GetFullPath($engineDirectory) + if ([IO.Path]::GetDirectoryName($resolvedEngineDirectory) -ne $resolvedTemp -or + [IO.Path]::GetFileName($resolvedEngineDirectory) -cnotmatch '^csrun-[a-f0-9]{32}$') { throw 'Unsafe cleanup path.' } + if ($process -and $process.ExitCode -eq 0) { Remove-Item -LiteralPath $resolvedEngineDirectory -Recurse -Force } +} +if ($process.ExitCode -ne 0) { throw "csrun execution failed with exit code $($process.ExitCode). $diagnostics" } +if ($verifyTests) { Assert-CsrunTestOutput $output } +} \ No newline at end of file diff --git a/.docfx/run-actions/08b911ef79f0b743282e37c9/native.ps1 b/.docfx/run-actions/08b911ef79f0b743282e37c9/native.ps1 new file mode 100644 index 0000000..3bbc696 --- /dev/null +++ b/.docfx/run-actions/08b911ef79f0b743282e37c9/native.ps1 @@ -0,0 +1,88 @@ +& { +#requires -Version 7.0 +$ErrorActionPreference = 'Stop' +$PSNativeCommandUseErrorActionPreference = $false +$manifest = @' +{ + "dependsOn": [ + "Codebelt.Extensions.Xunit.Hosting.AspNetCore@13.0.0" + ], + "framework": "net10.0", + "frameworkReferences": [ + "Microsoft.AspNetCore.App" + ], + "mode": "console", + "schemaVersion": 1, + "sdk": "Microsoft.NET.Sdk.Web", + "source": "using System;\nusing Codebelt.Extensions.Xunit.Hosting.AspNetCore.Http.Features;\n\nnamespace WebFixtureTests;\n\npublic class ResponseFeatureExample\n{\n public void Demonstrate()\n {\n var response = new FakeHttpResponseFeature();\n Console.WriteLine(response.StatusCode);\n }\n}\n\ninternal static class RunExample\n{\n static void Main()\n {\n new ResponseFeatureExample().Demonstrate();\n }\n}" +} +'@ +$OutputEncoding = [Text.UTF8Encoding]::new($false) +[Console]::OutputEncoding = $OutputEncoding +$verifyTests = $false +function Assert-CsrunTestOutput([string] $Output) { + $lines = @($Output -split '\r?\n') + $headers = @($lines | Where-Object { $_ -match '^Test run summary: Passed! - .+\)$' }) + if ($headers.Count -ne 1) { throw 'Expected exactly one completed xUnit test summary.' } + $headerIndex = [Array]::IndexOf($lines, $headers[0]) + $summaryLines = @($lines | Select-Object -Skip ($headerIndex + 1) -First 4) + $counts = @{} + foreach ($line in $summaryLines) { + if ($line -match '^\s*(total|failed|succeeded|skipped):\s*(\d+)\s*$') { $counts[$Matches[1]] = [int]$Matches[2] } + } + if ($counts.Count -ne 4) { throw 'The xUnit test summary counts are incomplete or ambiguous.' } + $failed = $counts.failed + $passed = $counts.succeeded + $skipped = $counts.skipped + $total = $counts.total + if ($total -lt 1 -or $passed -lt 1 -or $failed -ne 0 -or $skipped -ne 0 -or $passed -ne $total) { + throw 'Tests must execute at least once, all pass, and none fail or skip.' + } +} +# Downloads and executes the latest stable csrun release with your permissions. +# Source and release history: https://github.com/codebeltnet/csrun +$engineDirectory = Join-Path ([IO.Path]::GetTempPath()) ('csrun-' + [guid]::NewGuid().ToString('N')) +$null = New-Item -ItemType Directory -Path $engineDirectory +$enginePath = Join-Path $engineDirectory 'csrun.ps1' +$process = $null +try { + $release = Invoke-RestMethod 'https://api.github.com/repos/codebeltnet/csrun/releases/latest' + $assets = @($release.assets | Where-Object name -CEQ 'csrun.ps1') + if ($assets.Count -ne 1 -or $assets[0].digest -notmatch '^sha256:[0-9a-f]{64}$') { + throw "csrun release $($release.tag_name) must publish one csrun.ps1 asset with a SHA-256 digest." + } + $asset = $assets[0] + Invoke-WebRequest $asset.browser_download_url -OutFile $enginePath + $actualHash = (Get-FileHash -LiteralPath $enginePath -Algorithm SHA256).Hash + if ("sha256:$actualHash" -ne $asset.digest) { throw "csrun asset checksum mismatch: $actualHash" } +$startInfo = [Diagnostics.ProcessStartInfo]::new('pwsh') +foreach ($argument in @('-NoProfile','-NonInteractive','-File')) { $startInfo.ArgumentList.Add($argument) } +$startInfo.ArgumentList.Add($enginePath) +$startInfo.ArgumentList.Add('-ManifestJson') +$startInfo.ArgumentList.Add($manifest) +$startInfo.RedirectStandardOutput = $true +$startInfo.RedirectStandardError = $true +$startInfo.UseShellExecute = $false +$process = [Diagnostics.Process]::new() +$process.StartInfo = $startInfo +if (-not $process.Start()) { throw 'Could not start csrun.' } +$stdoutTask = $process.StandardOutput.ReadToEndAsync() +$stderrTask = $process.StandardError.ReadToEndAsync() +$process.WaitForExit() +$output = $stdoutTask.GetAwaiter().GetResult() +$diagnostics = $stderrTask.GetAwaiter().GetResult() +Write-Output $output +if ($diagnostics) { [Console]::Error.Write($diagnostics) } +} catch { + [Console]::Error.WriteLine("csrun diagnostics retained in: $engineDirectory") + throw +} finally { + $resolvedTemp = [IO.Path]::TrimEndingDirectorySeparator([IO.Path]::GetFullPath([IO.Path]::GetTempPath())) + $resolvedEngineDirectory = [IO.Path]::GetFullPath($engineDirectory) + if ([IO.Path]::GetDirectoryName($resolvedEngineDirectory) -ne $resolvedTemp -or + [IO.Path]::GetFileName($resolvedEngineDirectory) -cnotmatch '^csrun-[a-f0-9]{32}$') { throw 'Unsafe cleanup path.' } + if ($process -and $process.ExitCode -eq 0) { Remove-Item -LiteralPath $resolvedEngineDirectory -Recurse -Force } +} +if ($process.ExitCode -ne 0) { throw "csrun execution failed with exit code $($process.ExitCode). $diagnostics" } +if ($verifyTests) { Assert-CsrunTestOutput $output } +} \ No newline at end of file diff --git a/.docfx/run-actions/10457ac34cce1cbadb26aee1/docker.ps1 b/.docfx/run-actions/10457ac34cce1cbadb26aee1/docker.ps1 new file mode 100644 index 0000000..44986ad --- /dev/null +++ b/.docfx/run-actions/10457ac34cce1cbadb26aee1/docker.ps1 @@ -0,0 +1,82 @@ +& { +#requires -Version 7.0 +$ErrorActionPreference = 'Stop' +$PSNativeCommandUseErrorActionPreference = $false +$manifest = @' +{ + "dependsOn": [ + "Codebelt.Extensions.Xunit@13.0.0", + "xunit.v3@4.0.3" + ], + "framework": "net10.0", + "mode": "test", + "schemaVersion": 1, + "source": "using Codebelt.Extensions.Xunit;\nusing Xunit;\n\nnamespace Example.Tests;\n\npublic class ArrayOutputTest : Test\n{\n public ArrayOutputTest(ITestOutputHelper output) : base(output) { }\n\n [Fact]\n public void ShouldWriteArrayItems()\n {\n TestOutput.WriteLines(new int[] { 1, 2, 3 });\n Assert.True(HasTestOutput);\n }\n}" +} +'@ +$OutputEncoding = [Text.UTF8Encoding]::new($false) +[Console]::OutputEncoding = $OutputEncoding +$verifyTests = $true +function Assert-CsrunTestOutput([string] $Output) { + $lines = @($Output -split '\r?\n') + $headers = @($lines | Where-Object { $_ -match '^Test run summary: Passed! - .+\)$' }) + if ($headers.Count -ne 1) { throw 'Expected exactly one completed xUnit test summary.' } + $headerIndex = [Array]::IndexOf($lines, $headers[0]) + $summaryLines = @($lines | Select-Object -Skip ($headerIndex + 1) -First 4) + $counts = @{} + foreach ($line in $summaryLines) { + if ($line -match '^\s*(total|failed|succeeded|skipped):\s*(\d+)\s*$') { $counts[$Matches[1]] = [int]$Matches[2] } + } + if ($counts.Count -ne 4) { throw 'The xUnit test summary counts are incomplete or ambiguous.' } + $failed = $counts.failed + $passed = $counts.succeeded + $skipped = $counts.skipped + $total = $counts.total + if ($total -lt 1 -or $passed -lt 1 -or $failed -ne 0 -or $skipped -ne 0 -or $passed -ne $total) { + throw 'Tests must execute at least once, all pass, and none fail or skip.' + } +} +# Downloads and executes the latest stable csrun release with your permissions. +# Source and release history: https://github.com/codebeltnet/csrun +$engineDirectory = Join-Path ([IO.Path]::GetTempPath()) ('csrun-' + [guid]::NewGuid().ToString('N')) +$null = New-Item -ItemType Directory -Path $engineDirectory +$enginePath = Join-Path $engineDirectory 'csrun.ps1' +$process = $null +try { + $release = Invoke-RestMethod 'https://api.github.com/repos/codebeltnet/csrun/releases/latest' + $assets = @($release.assets | Where-Object name -CEQ 'csrun.ps1') + if ($assets.Count -ne 1 -or $assets[0].digest -notmatch '^sha256:[0-9a-f]{64}$') { + throw "csrun release $($release.tag_name) must publish one csrun.ps1 asset with a SHA-256 digest." + } + $asset = $assets[0] + Invoke-WebRequest $asset.browser_download_url -OutFile $enginePath + $actualHash = (Get-FileHash -LiteralPath $enginePath -Algorithm SHA256).Hash + if ("sha256:$actualHash" -ne $asset.digest) { throw "csrun asset checksum mismatch: $actualHash" } +$enginePayload = [Convert]::ToBase64String([IO.File]::ReadAllBytes($enginePath)) +$containerInput = $enginePayload + "`n" + $manifest +$command = ' +$ErrorActionPreference = "Stop" +$enginePath = Join-Path ([IO.Path]::GetTempPath()) ("csrun-release-" + [guid]::NewGuid().ToString("N") + ".ps1") +$engineBytes = [Convert]::FromBase64String([Console]::In.ReadLine()) +[IO.File]::WriteAllBytes($enginePath, $engineBytes) +$manifest = [Console]::In.ReadToEnd() +& $enginePath -ManifestJson $manifest +exit $LASTEXITCODE +' +$output = (@($containerInput | & docker run --rm -i --entrypoint pwsh 'codebeltnet/csrun:10' -NoProfile -NonInteractive -Command $command) -join [Environment]::NewLine) +$process = [pscustomobject]@{ ExitCode = $LASTEXITCODE } +$diagnostics = '' +Write-Output $output +} catch { + [Console]::Error.WriteLine("csrun diagnostics retained in: $engineDirectory") + throw +} finally { + $resolvedTemp = [IO.Path]::TrimEndingDirectorySeparator([IO.Path]::GetFullPath([IO.Path]::GetTempPath())) + $resolvedEngineDirectory = [IO.Path]::GetFullPath($engineDirectory) + if ([IO.Path]::GetDirectoryName($resolvedEngineDirectory) -ne $resolvedTemp -or + [IO.Path]::GetFileName($resolvedEngineDirectory) -cnotmatch '^csrun-[a-f0-9]{32}$') { throw 'Unsafe cleanup path.' } + if ($process -and $process.ExitCode -eq 0) { Remove-Item -LiteralPath $resolvedEngineDirectory -Recurse -Force } +} +if ($process.ExitCode -ne 0) { throw "csrun execution failed with exit code $($process.ExitCode). $diagnostics" } +if ($verifyTests) { Assert-CsrunTestOutput $output } +} \ No newline at end of file diff --git a/.docfx/run-actions/10457ac34cce1cbadb26aee1/native.ps1 b/.docfx/run-actions/10457ac34cce1cbadb26aee1/native.ps1 new file mode 100644 index 0000000..79e8752 --- /dev/null +++ b/.docfx/run-actions/10457ac34cce1cbadb26aee1/native.ps1 @@ -0,0 +1,85 @@ +& { +#requires -Version 7.0 +$ErrorActionPreference = 'Stop' +$PSNativeCommandUseErrorActionPreference = $false +$manifest = @' +{ + "dependsOn": [ + "Codebelt.Extensions.Xunit@13.0.0", + "xunit.v3@4.0.3" + ], + "framework": "net10.0", + "mode": "test", + "schemaVersion": 1, + "source": "using Codebelt.Extensions.Xunit;\nusing Xunit;\n\nnamespace Example.Tests;\n\npublic class ArrayOutputTest : Test\n{\n public ArrayOutputTest(ITestOutputHelper output) : base(output) { }\n\n [Fact]\n public void ShouldWriteArrayItems()\n {\n TestOutput.WriteLines(new int[] { 1, 2, 3 });\n Assert.True(HasTestOutput);\n }\n}" +} +'@ +$OutputEncoding = [Text.UTF8Encoding]::new($false) +[Console]::OutputEncoding = $OutputEncoding +$verifyTests = $true +function Assert-CsrunTestOutput([string] $Output) { + $lines = @($Output -split '\r?\n') + $headers = @($lines | Where-Object { $_ -match '^Test run summary: Passed! - .+\)$' }) + if ($headers.Count -ne 1) { throw 'Expected exactly one completed xUnit test summary.' } + $headerIndex = [Array]::IndexOf($lines, $headers[0]) + $summaryLines = @($lines | Select-Object -Skip ($headerIndex + 1) -First 4) + $counts = @{} + foreach ($line in $summaryLines) { + if ($line -match '^\s*(total|failed|succeeded|skipped):\s*(\d+)\s*$') { $counts[$Matches[1]] = [int]$Matches[2] } + } + if ($counts.Count -ne 4) { throw 'The xUnit test summary counts are incomplete or ambiguous.' } + $failed = $counts.failed + $passed = $counts.succeeded + $skipped = $counts.skipped + $total = $counts.total + if ($total -lt 1 -or $passed -lt 1 -or $failed -ne 0 -or $skipped -ne 0 -or $passed -ne $total) { + throw 'Tests must execute at least once, all pass, and none fail or skip.' + } +} +# Downloads and executes the latest stable csrun release with your permissions. +# Source and release history: https://github.com/codebeltnet/csrun +$engineDirectory = Join-Path ([IO.Path]::GetTempPath()) ('csrun-' + [guid]::NewGuid().ToString('N')) +$null = New-Item -ItemType Directory -Path $engineDirectory +$enginePath = Join-Path $engineDirectory 'csrun.ps1' +$process = $null +try { + $release = Invoke-RestMethod 'https://api.github.com/repos/codebeltnet/csrun/releases/latest' + $assets = @($release.assets | Where-Object name -CEQ 'csrun.ps1') + if ($assets.Count -ne 1 -or $assets[0].digest -notmatch '^sha256:[0-9a-f]{64}$') { + throw "csrun release $($release.tag_name) must publish one csrun.ps1 asset with a SHA-256 digest." + } + $asset = $assets[0] + Invoke-WebRequest $asset.browser_download_url -OutFile $enginePath + $actualHash = (Get-FileHash -LiteralPath $enginePath -Algorithm SHA256).Hash + if ("sha256:$actualHash" -ne $asset.digest) { throw "csrun asset checksum mismatch: $actualHash" } +$startInfo = [Diagnostics.ProcessStartInfo]::new('pwsh') +foreach ($argument in @('-NoProfile','-NonInteractive','-File')) { $startInfo.ArgumentList.Add($argument) } +$startInfo.ArgumentList.Add($enginePath) +$startInfo.ArgumentList.Add('-ManifestJson') +$startInfo.ArgumentList.Add($manifest) +$startInfo.RedirectStandardOutput = $true +$startInfo.RedirectStandardError = $true +$startInfo.UseShellExecute = $false +$process = [Diagnostics.Process]::new() +$process.StartInfo = $startInfo +if (-not $process.Start()) { throw 'Could not start csrun.' } +$stdoutTask = $process.StandardOutput.ReadToEndAsync() +$stderrTask = $process.StandardError.ReadToEndAsync() +$process.WaitForExit() +$output = $stdoutTask.GetAwaiter().GetResult() +$diagnostics = $stderrTask.GetAwaiter().GetResult() +Write-Output $output +if ($diagnostics) { [Console]::Error.Write($diagnostics) } +} catch { + [Console]::Error.WriteLine("csrun diagnostics retained in: $engineDirectory") + throw +} finally { + $resolvedTemp = [IO.Path]::TrimEndingDirectorySeparator([IO.Path]::GetFullPath([IO.Path]::GetTempPath())) + $resolvedEngineDirectory = [IO.Path]::GetFullPath($engineDirectory) + if ([IO.Path]::GetDirectoryName($resolvedEngineDirectory) -ne $resolvedTemp -or + [IO.Path]::GetFileName($resolvedEngineDirectory) -cnotmatch '^csrun-[a-f0-9]{32}$') { throw 'Unsafe cleanup path.' } + if ($process -and $process.ExitCode -eq 0) { Remove-Item -LiteralPath $resolvedEngineDirectory -Recurse -Force } +} +if ($process.ExitCode -ne 0) { throw "csrun execution failed with exit code $($process.ExitCode). $diagnostics" } +if ($verifyTests) { Assert-CsrunTestOutput $output } +} \ No newline at end of file diff --git a/.docfx/run-actions/1130af506703020850fdadea/docker.ps1 b/.docfx/run-actions/1130af506703020850fdadea/docker.ps1 new file mode 100644 index 0000000..1c8d571 --- /dev/null +++ b/.docfx/run-actions/1130af506703020850fdadea/docker.ps1 @@ -0,0 +1,83 @@ +& { +#requires -Version 7.0 +$ErrorActionPreference = 'Stop' +$PSNativeCommandUseErrorActionPreference = $false +$manifest = @' +{ + "dependsOn": [ + "Codebelt.Extensions.Xunit.Hosting@13.0.0", + "Microsoft.Extensions.Hosting@10.0.15", + "xunit.v3@4.0.3" + ], + "framework": "net10.0", + "mode": "test", + "schemaVersion": 1, + "source": "using Codebelt.Extensions.Xunit.Hosting;\nusing Xunit;\n\nnamespace HostFixtureTests;\n\npublic class HostStateGuard\n{\n public bool EnsureFixtureIsReady(IGenericHostFixture fixture)\n {\n return fixture.HasValidState();\n }\n}\n\npublic sealed class RunExample\n{\n [Fact]\n public void ExercisesExample()\n {\n using var fixture = new ManagedHostFixture();\n Assert.False(new HostStateGuard().EnsureFixtureIsReady(fixture));\n using var app = HostTestFactory.Create(hostFixture: fixture);\n Assert.True(new HostStateGuard().EnsureFixtureIsReady(fixture));\n }\n}" +} +'@ +$OutputEncoding = [Text.UTF8Encoding]::new($false) +[Console]::OutputEncoding = $OutputEncoding +$verifyTests = $true +function Assert-CsrunTestOutput([string] $Output) { + $lines = @($Output -split '\r?\n') + $headers = @($lines | Where-Object { $_ -match '^Test run summary: Passed! - .+\)$' }) + if ($headers.Count -ne 1) { throw 'Expected exactly one completed xUnit test summary.' } + $headerIndex = [Array]::IndexOf($lines, $headers[0]) + $summaryLines = @($lines | Select-Object -Skip ($headerIndex + 1) -First 4) + $counts = @{} + foreach ($line in $summaryLines) { + if ($line -match '^\s*(total|failed|succeeded|skipped):\s*(\d+)\s*$') { $counts[$Matches[1]] = [int]$Matches[2] } + } + if ($counts.Count -ne 4) { throw 'The xUnit test summary counts are incomplete or ambiguous.' } + $failed = $counts.failed + $passed = $counts.succeeded + $skipped = $counts.skipped + $total = $counts.total + if ($total -lt 1 -or $passed -lt 1 -or $failed -ne 0 -or $skipped -ne 0 -or $passed -ne $total) { + throw 'Tests must execute at least once, all pass, and none fail or skip.' + } +} +# Downloads and executes the latest stable csrun release with your permissions. +# Source and release history: https://github.com/codebeltnet/csrun +$engineDirectory = Join-Path ([IO.Path]::GetTempPath()) ('csrun-' + [guid]::NewGuid().ToString('N')) +$null = New-Item -ItemType Directory -Path $engineDirectory +$enginePath = Join-Path $engineDirectory 'csrun.ps1' +$process = $null +try { + $release = Invoke-RestMethod 'https://api.github.com/repos/codebeltnet/csrun/releases/latest' + $assets = @($release.assets | Where-Object name -CEQ 'csrun.ps1') + if ($assets.Count -ne 1 -or $assets[0].digest -notmatch '^sha256:[0-9a-f]{64}$') { + throw "csrun release $($release.tag_name) must publish one csrun.ps1 asset with a SHA-256 digest." + } + $asset = $assets[0] + Invoke-WebRequest $asset.browser_download_url -OutFile $enginePath + $actualHash = (Get-FileHash -LiteralPath $enginePath -Algorithm SHA256).Hash + if ("sha256:$actualHash" -ne $asset.digest) { throw "csrun asset checksum mismatch: $actualHash" } +$enginePayload = [Convert]::ToBase64String([IO.File]::ReadAllBytes($enginePath)) +$containerInput = $enginePayload + "`n" + $manifest +$command = ' +$ErrorActionPreference = "Stop" +$enginePath = Join-Path ([IO.Path]::GetTempPath()) ("csrun-release-" + [guid]::NewGuid().ToString("N") + ".ps1") +$engineBytes = [Convert]::FromBase64String([Console]::In.ReadLine()) +[IO.File]::WriteAllBytes($enginePath, $engineBytes) +$manifest = [Console]::In.ReadToEnd() +& $enginePath -ManifestJson $manifest +exit $LASTEXITCODE +' +$output = (@($containerInput | & docker run --rm -i --entrypoint pwsh 'codebeltnet/csrun:10' -NoProfile -NonInteractive -Command $command) -join [Environment]::NewLine) +$process = [pscustomobject]@{ ExitCode = $LASTEXITCODE } +$diagnostics = '' +Write-Output $output +} catch { + [Console]::Error.WriteLine("csrun diagnostics retained in: $engineDirectory") + throw +} finally { + $resolvedTemp = [IO.Path]::TrimEndingDirectorySeparator([IO.Path]::GetFullPath([IO.Path]::GetTempPath())) + $resolvedEngineDirectory = [IO.Path]::GetFullPath($engineDirectory) + if ([IO.Path]::GetDirectoryName($resolvedEngineDirectory) -ne $resolvedTemp -or + [IO.Path]::GetFileName($resolvedEngineDirectory) -cnotmatch '^csrun-[a-f0-9]{32}$') { throw 'Unsafe cleanup path.' } + if ($process -and $process.ExitCode -eq 0) { Remove-Item -LiteralPath $resolvedEngineDirectory -Recurse -Force } +} +if ($process.ExitCode -ne 0) { throw "csrun execution failed with exit code $($process.ExitCode). $diagnostics" } +if ($verifyTests) { Assert-CsrunTestOutput $output } +} \ No newline at end of file diff --git a/.docfx/run-actions/1130af506703020850fdadea/native.ps1 b/.docfx/run-actions/1130af506703020850fdadea/native.ps1 new file mode 100644 index 0000000..5c7c566 --- /dev/null +++ b/.docfx/run-actions/1130af506703020850fdadea/native.ps1 @@ -0,0 +1,86 @@ +& { +#requires -Version 7.0 +$ErrorActionPreference = 'Stop' +$PSNativeCommandUseErrorActionPreference = $false +$manifest = @' +{ + "dependsOn": [ + "Codebelt.Extensions.Xunit.Hosting@13.0.0", + "Microsoft.Extensions.Hosting@10.0.15", + "xunit.v3@4.0.3" + ], + "framework": "net10.0", + "mode": "test", + "schemaVersion": 1, + "source": "using Codebelt.Extensions.Xunit.Hosting;\nusing Xunit;\n\nnamespace HostFixtureTests;\n\npublic class HostStateGuard\n{\n public bool EnsureFixtureIsReady(IGenericHostFixture fixture)\n {\n return fixture.HasValidState();\n }\n}\n\npublic sealed class RunExample\n{\n [Fact]\n public void ExercisesExample()\n {\n using var fixture = new ManagedHostFixture();\n Assert.False(new HostStateGuard().EnsureFixtureIsReady(fixture));\n using var app = HostTestFactory.Create(hostFixture: fixture);\n Assert.True(new HostStateGuard().EnsureFixtureIsReady(fixture));\n }\n}" +} +'@ +$OutputEncoding = [Text.UTF8Encoding]::new($false) +[Console]::OutputEncoding = $OutputEncoding +$verifyTests = $true +function Assert-CsrunTestOutput([string] $Output) { + $lines = @($Output -split '\r?\n') + $headers = @($lines | Where-Object { $_ -match '^Test run summary: Passed! - .+\)$' }) + if ($headers.Count -ne 1) { throw 'Expected exactly one completed xUnit test summary.' } + $headerIndex = [Array]::IndexOf($lines, $headers[0]) + $summaryLines = @($lines | Select-Object -Skip ($headerIndex + 1) -First 4) + $counts = @{} + foreach ($line in $summaryLines) { + if ($line -match '^\s*(total|failed|succeeded|skipped):\s*(\d+)\s*$') { $counts[$Matches[1]] = [int]$Matches[2] } + } + if ($counts.Count -ne 4) { throw 'The xUnit test summary counts are incomplete or ambiguous.' } + $failed = $counts.failed + $passed = $counts.succeeded + $skipped = $counts.skipped + $total = $counts.total + if ($total -lt 1 -or $passed -lt 1 -or $failed -ne 0 -or $skipped -ne 0 -or $passed -ne $total) { + throw 'Tests must execute at least once, all pass, and none fail or skip.' + } +} +# Downloads and executes the latest stable csrun release with your permissions. +# Source and release history: https://github.com/codebeltnet/csrun +$engineDirectory = Join-Path ([IO.Path]::GetTempPath()) ('csrun-' + [guid]::NewGuid().ToString('N')) +$null = New-Item -ItemType Directory -Path $engineDirectory +$enginePath = Join-Path $engineDirectory 'csrun.ps1' +$process = $null +try { + $release = Invoke-RestMethod 'https://api.github.com/repos/codebeltnet/csrun/releases/latest' + $assets = @($release.assets | Where-Object name -CEQ 'csrun.ps1') + if ($assets.Count -ne 1 -or $assets[0].digest -notmatch '^sha256:[0-9a-f]{64}$') { + throw "csrun release $($release.tag_name) must publish one csrun.ps1 asset with a SHA-256 digest." + } + $asset = $assets[0] + Invoke-WebRequest $asset.browser_download_url -OutFile $enginePath + $actualHash = (Get-FileHash -LiteralPath $enginePath -Algorithm SHA256).Hash + if ("sha256:$actualHash" -ne $asset.digest) { throw "csrun asset checksum mismatch: $actualHash" } +$startInfo = [Diagnostics.ProcessStartInfo]::new('pwsh') +foreach ($argument in @('-NoProfile','-NonInteractive','-File')) { $startInfo.ArgumentList.Add($argument) } +$startInfo.ArgumentList.Add($enginePath) +$startInfo.ArgumentList.Add('-ManifestJson') +$startInfo.ArgumentList.Add($manifest) +$startInfo.RedirectStandardOutput = $true +$startInfo.RedirectStandardError = $true +$startInfo.UseShellExecute = $false +$process = [Diagnostics.Process]::new() +$process.StartInfo = $startInfo +if (-not $process.Start()) { throw 'Could not start csrun.' } +$stdoutTask = $process.StandardOutput.ReadToEndAsync() +$stderrTask = $process.StandardError.ReadToEndAsync() +$process.WaitForExit() +$output = $stdoutTask.GetAwaiter().GetResult() +$diagnostics = $stderrTask.GetAwaiter().GetResult() +Write-Output $output +if ($diagnostics) { [Console]::Error.Write($diagnostics) } +} catch { + [Console]::Error.WriteLine("csrun diagnostics retained in: $engineDirectory") + throw +} finally { + $resolvedTemp = [IO.Path]::TrimEndingDirectorySeparator([IO.Path]::GetFullPath([IO.Path]::GetTempPath())) + $resolvedEngineDirectory = [IO.Path]::GetFullPath($engineDirectory) + if ([IO.Path]::GetDirectoryName($resolvedEngineDirectory) -ne $resolvedTemp -or + [IO.Path]::GetFileName($resolvedEngineDirectory) -cnotmatch '^csrun-[a-f0-9]{32}$') { throw 'Unsafe cleanup path.' } + if ($process -and $process.ExitCode -eq 0) { Remove-Item -LiteralPath $resolvedEngineDirectory -Recurse -Force } +} +if ($process.ExitCode -ne 0) { throw "csrun execution failed with exit code $($process.ExitCode). $diagnostics" } +if ($verifyTests) { Assert-CsrunTestOutput $output } +} \ No newline at end of file diff --git a/.docfx/run-actions/18b0746bf3da1d84f81b5274/docker.ps1 b/.docfx/run-actions/18b0746bf3da1d84f81b5274/docker.ps1 new file mode 100644 index 0000000..e7d1d37 --- /dev/null +++ b/.docfx/run-actions/18b0746bf3da1d84f81b5274/docker.ps1 @@ -0,0 +1,83 @@ +& { +#requires -Version 7.0 +$ErrorActionPreference = 'Stop' +$PSNativeCommandUseErrorActionPreference = $false +$manifest = @' +{ + "dependsOn": [ + "Codebelt.Extensions.Xunit.Hosting@13.0.0", + "Microsoft.Extensions.Hosting@10.0.15", + "xunit.v3@4.0.3" + ], + "framework": "net10.0", + "mode": "test", + "schemaVersion": 1, + "source": "using Codebelt.Extensions.Xunit.Hosting;\nusing Microsoft.Extensions.DependencyInjection;\nusing Microsoft.Extensions.Logging;\nusing Xunit;\n\nnamespace HostFixtureTests;\n\npublic class ExampleFixture\n{\n public IServiceCollection ConfigureServices(IServiceCollection services)\n {\n services.AddXunitTestLogging(LogLevel.Information);\n services.AddXunitTestLoggingOutputHelperAccessor();\n return services;\n }\n}\n\npublic sealed class RunExample\n{\n [Fact]\n public void ExercisesExample()\n {\n using var provider = new ExampleFixture().ConfigureServices(new ServiceCollection()).BuildServiceProvider();\n Assert.IsType(provider.GetRequiredService());\n var logger = provider.GetRequiredService>();\n logger.LogInformation(\"storage ready\");\n Assert.Contains(logger.GetTestStore().Query(), entry => entry.Severity == LogLevel.Information && entry.Message == \"Information: storage ready\");\n }\n}" +} +'@ +$OutputEncoding = [Text.UTF8Encoding]::new($false) +[Console]::OutputEncoding = $OutputEncoding +$verifyTests = $true +function Assert-CsrunTestOutput([string] $Output) { + $lines = @($Output -split '\r?\n') + $headers = @($lines | Where-Object { $_ -match '^Test run summary: Passed! - .+\)$' }) + if ($headers.Count -ne 1) { throw 'Expected exactly one completed xUnit test summary.' } + $headerIndex = [Array]::IndexOf($lines, $headers[0]) + $summaryLines = @($lines | Select-Object -Skip ($headerIndex + 1) -First 4) + $counts = @{} + foreach ($line in $summaryLines) { + if ($line -match '^\s*(total|failed|succeeded|skipped):\s*(\d+)\s*$') { $counts[$Matches[1]] = [int]$Matches[2] } + } + if ($counts.Count -ne 4) { throw 'The xUnit test summary counts are incomplete or ambiguous.' } + $failed = $counts.failed + $passed = $counts.succeeded + $skipped = $counts.skipped + $total = $counts.total + if ($total -lt 1 -or $passed -lt 1 -or $failed -ne 0 -or $skipped -ne 0 -or $passed -ne $total) { + throw 'Tests must execute at least once, all pass, and none fail or skip.' + } +} +# Downloads and executes the latest stable csrun release with your permissions. +# Source and release history: https://github.com/codebeltnet/csrun +$engineDirectory = Join-Path ([IO.Path]::GetTempPath()) ('csrun-' + [guid]::NewGuid().ToString('N')) +$null = New-Item -ItemType Directory -Path $engineDirectory +$enginePath = Join-Path $engineDirectory 'csrun.ps1' +$process = $null +try { + $release = Invoke-RestMethod 'https://api.github.com/repos/codebeltnet/csrun/releases/latest' + $assets = @($release.assets | Where-Object name -CEQ 'csrun.ps1') + if ($assets.Count -ne 1 -or $assets[0].digest -notmatch '^sha256:[0-9a-f]{64}$') { + throw "csrun release $($release.tag_name) must publish one csrun.ps1 asset with a SHA-256 digest." + } + $asset = $assets[0] + Invoke-WebRequest $asset.browser_download_url -OutFile $enginePath + $actualHash = (Get-FileHash -LiteralPath $enginePath -Algorithm SHA256).Hash + if ("sha256:$actualHash" -ne $asset.digest) { throw "csrun asset checksum mismatch: $actualHash" } +$enginePayload = [Convert]::ToBase64String([IO.File]::ReadAllBytes($enginePath)) +$containerInput = $enginePayload + "`n" + $manifest +$command = ' +$ErrorActionPreference = "Stop" +$enginePath = Join-Path ([IO.Path]::GetTempPath()) ("csrun-release-" + [guid]::NewGuid().ToString("N") + ".ps1") +$engineBytes = [Convert]::FromBase64String([Console]::In.ReadLine()) +[IO.File]::WriteAllBytes($enginePath, $engineBytes) +$manifest = [Console]::In.ReadToEnd() +& $enginePath -ManifestJson $manifest +exit $LASTEXITCODE +' +$output = (@($containerInput | & docker run --rm -i --entrypoint pwsh 'codebeltnet/csrun:10' -NoProfile -NonInteractive -Command $command) -join [Environment]::NewLine) +$process = [pscustomobject]@{ ExitCode = $LASTEXITCODE } +$diagnostics = '' +Write-Output $output +} catch { + [Console]::Error.WriteLine("csrun diagnostics retained in: $engineDirectory") + throw +} finally { + $resolvedTemp = [IO.Path]::TrimEndingDirectorySeparator([IO.Path]::GetFullPath([IO.Path]::GetTempPath())) + $resolvedEngineDirectory = [IO.Path]::GetFullPath($engineDirectory) + if ([IO.Path]::GetDirectoryName($resolvedEngineDirectory) -ne $resolvedTemp -or + [IO.Path]::GetFileName($resolvedEngineDirectory) -cnotmatch '^csrun-[a-f0-9]{32}$') { throw 'Unsafe cleanup path.' } + if ($process -and $process.ExitCode -eq 0) { Remove-Item -LiteralPath $resolvedEngineDirectory -Recurse -Force } +} +if ($process.ExitCode -ne 0) { throw "csrun execution failed with exit code $($process.ExitCode). $diagnostics" } +if ($verifyTests) { Assert-CsrunTestOutput $output } +} \ No newline at end of file diff --git a/.docfx/run-actions/18b0746bf3da1d84f81b5274/native.ps1 b/.docfx/run-actions/18b0746bf3da1d84f81b5274/native.ps1 new file mode 100644 index 0000000..6a762c4 --- /dev/null +++ b/.docfx/run-actions/18b0746bf3da1d84f81b5274/native.ps1 @@ -0,0 +1,86 @@ +& { +#requires -Version 7.0 +$ErrorActionPreference = 'Stop' +$PSNativeCommandUseErrorActionPreference = $false +$manifest = @' +{ + "dependsOn": [ + "Codebelt.Extensions.Xunit.Hosting@13.0.0", + "Microsoft.Extensions.Hosting@10.0.15", + "xunit.v3@4.0.3" + ], + "framework": "net10.0", + "mode": "test", + "schemaVersion": 1, + "source": "using Codebelt.Extensions.Xunit.Hosting;\nusing Microsoft.Extensions.DependencyInjection;\nusing Microsoft.Extensions.Logging;\nusing Xunit;\n\nnamespace HostFixtureTests;\n\npublic class ExampleFixture\n{\n public IServiceCollection ConfigureServices(IServiceCollection services)\n {\n services.AddXunitTestLogging(LogLevel.Information);\n services.AddXunitTestLoggingOutputHelperAccessor();\n return services;\n }\n}\n\npublic sealed class RunExample\n{\n [Fact]\n public void ExercisesExample()\n {\n using var provider = new ExampleFixture().ConfigureServices(new ServiceCollection()).BuildServiceProvider();\n Assert.IsType(provider.GetRequiredService());\n var logger = provider.GetRequiredService>();\n logger.LogInformation(\"storage ready\");\n Assert.Contains(logger.GetTestStore().Query(), entry => entry.Severity == LogLevel.Information && entry.Message == \"Information: storage ready\");\n }\n}" +} +'@ +$OutputEncoding = [Text.UTF8Encoding]::new($false) +[Console]::OutputEncoding = $OutputEncoding +$verifyTests = $true +function Assert-CsrunTestOutput([string] $Output) { + $lines = @($Output -split '\r?\n') + $headers = @($lines | Where-Object { $_ -match '^Test run summary: Passed! - .+\)$' }) + if ($headers.Count -ne 1) { throw 'Expected exactly one completed xUnit test summary.' } + $headerIndex = [Array]::IndexOf($lines, $headers[0]) + $summaryLines = @($lines | Select-Object -Skip ($headerIndex + 1) -First 4) + $counts = @{} + foreach ($line in $summaryLines) { + if ($line -match '^\s*(total|failed|succeeded|skipped):\s*(\d+)\s*$') { $counts[$Matches[1]] = [int]$Matches[2] } + } + if ($counts.Count -ne 4) { throw 'The xUnit test summary counts are incomplete or ambiguous.' } + $failed = $counts.failed + $passed = $counts.succeeded + $skipped = $counts.skipped + $total = $counts.total + if ($total -lt 1 -or $passed -lt 1 -or $failed -ne 0 -or $skipped -ne 0 -or $passed -ne $total) { + throw 'Tests must execute at least once, all pass, and none fail or skip.' + } +} +# Downloads and executes the latest stable csrun release with your permissions. +# Source and release history: https://github.com/codebeltnet/csrun +$engineDirectory = Join-Path ([IO.Path]::GetTempPath()) ('csrun-' + [guid]::NewGuid().ToString('N')) +$null = New-Item -ItemType Directory -Path $engineDirectory +$enginePath = Join-Path $engineDirectory 'csrun.ps1' +$process = $null +try { + $release = Invoke-RestMethod 'https://api.github.com/repos/codebeltnet/csrun/releases/latest' + $assets = @($release.assets | Where-Object name -CEQ 'csrun.ps1') + if ($assets.Count -ne 1 -or $assets[0].digest -notmatch '^sha256:[0-9a-f]{64}$') { + throw "csrun release $($release.tag_name) must publish one csrun.ps1 asset with a SHA-256 digest." + } + $asset = $assets[0] + Invoke-WebRequest $asset.browser_download_url -OutFile $enginePath + $actualHash = (Get-FileHash -LiteralPath $enginePath -Algorithm SHA256).Hash + if ("sha256:$actualHash" -ne $asset.digest) { throw "csrun asset checksum mismatch: $actualHash" } +$startInfo = [Diagnostics.ProcessStartInfo]::new('pwsh') +foreach ($argument in @('-NoProfile','-NonInteractive','-File')) { $startInfo.ArgumentList.Add($argument) } +$startInfo.ArgumentList.Add($enginePath) +$startInfo.ArgumentList.Add('-ManifestJson') +$startInfo.ArgumentList.Add($manifest) +$startInfo.RedirectStandardOutput = $true +$startInfo.RedirectStandardError = $true +$startInfo.UseShellExecute = $false +$process = [Diagnostics.Process]::new() +$process.StartInfo = $startInfo +if (-not $process.Start()) { throw 'Could not start csrun.' } +$stdoutTask = $process.StandardOutput.ReadToEndAsync() +$stderrTask = $process.StandardError.ReadToEndAsync() +$process.WaitForExit() +$output = $stdoutTask.GetAwaiter().GetResult() +$diagnostics = $stderrTask.GetAwaiter().GetResult() +Write-Output $output +if ($diagnostics) { [Console]::Error.Write($diagnostics) } +} catch { + [Console]::Error.WriteLine("csrun diagnostics retained in: $engineDirectory") + throw +} finally { + $resolvedTemp = [IO.Path]::TrimEndingDirectorySeparator([IO.Path]::GetFullPath([IO.Path]::GetTempPath())) + $resolvedEngineDirectory = [IO.Path]::GetFullPath($engineDirectory) + if ([IO.Path]::GetDirectoryName($resolvedEngineDirectory) -ne $resolvedTemp -or + [IO.Path]::GetFileName($resolvedEngineDirectory) -cnotmatch '^csrun-[a-f0-9]{32}$') { throw 'Unsafe cleanup path.' } + if ($process -and $process.ExitCode -eq 0) { Remove-Item -LiteralPath $resolvedEngineDirectory -Recurse -Force } +} +if ($process.ExitCode -ne 0) { throw "csrun execution failed with exit code $($process.ExitCode). $diagnostics" } +if ($verifyTests) { Assert-CsrunTestOutput $output } +} \ No newline at end of file diff --git a/.docfx/run-actions/1e869fe39c4833386733c21f/docker.ps1 b/.docfx/run-actions/1e869fe39c4833386733c21f/docker.ps1 new file mode 100644 index 0000000..fe6d588 --- /dev/null +++ b/.docfx/run-actions/1e869fe39c4833386733c21f/docker.ps1 @@ -0,0 +1,86 @@ +& { +#requires -Version 7.0 +$ErrorActionPreference = 'Stop' +$PSNativeCommandUseErrorActionPreference = $false +$manifest = @' +{ + "dependsOn": [ + "Codebelt.Extensions.Xunit.Hosting.AspNetCore@13.0.0", + "Microsoft.Extensions.Hosting@10.0.15", + "xunit.v3@4.0.3" + ], + "framework": "net10.0", + "frameworkReferences": [ + "Microsoft.AspNetCore.App" + ], + "mode": "test", + "schemaVersion": 1, + "source": "using System.Threading.Tasks;\nusing Codebelt.Extensions.Xunit.Hosting.AspNetCore;\nusing Microsoft.AspNetCore.Builder;\nusing Microsoft.AspNetCore.Http;\nusing Microsoft.Extensions.DependencyInjection;\nusing Xunit;\n\nnamespace HealthEndpoint.Tests;\n\npublic sealed class MinimalWebHostTestFactoryExample\n{\n public async Task ReadHealthStateAsync()\n {\n using var response = await MinimalWebHostTestFactory.RunAsync(\n services => services.AddSingleton(new HealthState(\"healthy\")),\n app => app.Run(context =>\n {\n var health = context.RequestServices.GetRequiredService();\n return context.Response.WriteAsync(health.Value);\n })).ConfigureAwait(false);\n\n return await response.Content.ReadAsStringAsync().ConfigureAwait(false);\n }\n}\n\npublic sealed record HealthState(string Value);\n\npublic sealed class RunExample\n{\n [Fact]\n public async Task ExercisesExample()\n {\n Assert.Equal(\"healthy\", await new MinimalWebHostTestFactoryExample().ReadHealthStateAsync());\n }\n}" +} +'@ +$OutputEncoding = [Text.UTF8Encoding]::new($false) +[Console]::OutputEncoding = $OutputEncoding +$verifyTests = $true +function Assert-CsrunTestOutput([string] $Output) { + $lines = @($Output -split '\r?\n') + $headers = @($lines | Where-Object { $_ -match '^Test run summary: Passed! - .+\)$' }) + if ($headers.Count -ne 1) { throw 'Expected exactly one completed xUnit test summary.' } + $headerIndex = [Array]::IndexOf($lines, $headers[0]) + $summaryLines = @($lines | Select-Object -Skip ($headerIndex + 1) -First 4) + $counts = @{} + foreach ($line in $summaryLines) { + if ($line -match '^\s*(total|failed|succeeded|skipped):\s*(\d+)\s*$') { $counts[$Matches[1]] = [int]$Matches[2] } + } + if ($counts.Count -ne 4) { throw 'The xUnit test summary counts are incomplete or ambiguous.' } + $failed = $counts.failed + $passed = $counts.succeeded + $skipped = $counts.skipped + $total = $counts.total + if ($total -lt 1 -or $passed -lt 1 -or $failed -ne 0 -or $skipped -ne 0 -or $passed -ne $total) { + throw 'Tests must execute at least once, all pass, and none fail or skip.' + } +} +# Downloads and executes the latest stable csrun release with your permissions. +# Source and release history: https://github.com/codebeltnet/csrun +$engineDirectory = Join-Path ([IO.Path]::GetTempPath()) ('csrun-' + [guid]::NewGuid().ToString('N')) +$null = New-Item -ItemType Directory -Path $engineDirectory +$enginePath = Join-Path $engineDirectory 'csrun.ps1' +$process = $null +try { + $release = Invoke-RestMethod 'https://api.github.com/repos/codebeltnet/csrun/releases/latest' + $assets = @($release.assets | Where-Object name -CEQ 'csrun.ps1') + if ($assets.Count -ne 1 -or $assets[0].digest -notmatch '^sha256:[0-9a-f]{64}$') { + throw "csrun release $($release.tag_name) must publish one csrun.ps1 asset with a SHA-256 digest." + } + $asset = $assets[0] + Invoke-WebRequest $asset.browser_download_url -OutFile $enginePath + $actualHash = (Get-FileHash -LiteralPath $enginePath -Algorithm SHA256).Hash + if ("sha256:$actualHash" -ne $asset.digest) { throw "csrun asset checksum mismatch: $actualHash" } +$enginePayload = [Convert]::ToBase64String([IO.File]::ReadAllBytes($enginePath)) +$containerInput = $enginePayload + "`n" + $manifest +$command = ' +$ErrorActionPreference = "Stop" +$enginePath = Join-Path ([IO.Path]::GetTempPath()) ("csrun-release-" + [guid]::NewGuid().ToString("N") + ".ps1") +$engineBytes = [Convert]::FromBase64String([Console]::In.ReadLine()) +[IO.File]::WriteAllBytes($enginePath, $engineBytes) +$manifest = [Console]::In.ReadToEnd() +& $enginePath -ManifestJson $manifest +exit $LASTEXITCODE +' +$output = (@($containerInput | & docker run --rm -i --entrypoint pwsh 'codebeltnet/csrun:10' -NoProfile -NonInteractive -Command $command) -join [Environment]::NewLine) +$process = [pscustomobject]@{ ExitCode = $LASTEXITCODE } +$diagnostics = '' +Write-Output $output +} catch { + [Console]::Error.WriteLine("csrun diagnostics retained in: $engineDirectory") + throw +} finally { + $resolvedTemp = [IO.Path]::TrimEndingDirectorySeparator([IO.Path]::GetFullPath([IO.Path]::GetTempPath())) + $resolvedEngineDirectory = [IO.Path]::GetFullPath($engineDirectory) + if ([IO.Path]::GetDirectoryName($resolvedEngineDirectory) -ne $resolvedTemp -or + [IO.Path]::GetFileName($resolvedEngineDirectory) -cnotmatch '^csrun-[a-f0-9]{32}$') { throw 'Unsafe cleanup path.' } + if ($process -and $process.ExitCode -eq 0) { Remove-Item -LiteralPath $resolvedEngineDirectory -Recurse -Force } +} +if ($process.ExitCode -ne 0) { throw "csrun execution failed with exit code $($process.ExitCode). $diagnostics" } +if ($verifyTests) { Assert-CsrunTestOutput $output } +} \ No newline at end of file diff --git a/.docfx/run-actions/1e869fe39c4833386733c21f/native.ps1 b/.docfx/run-actions/1e869fe39c4833386733c21f/native.ps1 new file mode 100644 index 0000000..8e89972 --- /dev/null +++ b/.docfx/run-actions/1e869fe39c4833386733c21f/native.ps1 @@ -0,0 +1,89 @@ +& { +#requires -Version 7.0 +$ErrorActionPreference = 'Stop' +$PSNativeCommandUseErrorActionPreference = $false +$manifest = @' +{ + "dependsOn": [ + "Codebelt.Extensions.Xunit.Hosting.AspNetCore@13.0.0", + "Microsoft.Extensions.Hosting@10.0.15", + "xunit.v3@4.0.3" + ], + "framework": "net10.0", + "frameworkReferences": [ + "Microsoft.AspNetCore.App" + ], + "mode": "test", + "schemaVersion": 1, + "source": "using System.Threading.Tasks;\nusing Codebelt.Extensions.Xunit.Hosting.AspNetCore;\nusing Microsoft.AspNetCore.Builder;\nusing Microsoft.AspNetCore.Http;\nusing Microsoft.Extensions.DependencyInjection;\nusing Xunit;\n\nnamespace HealthEndpoint.Tests;\n\npublic sealed class MinimalWebHostTestFactoryExample\n{\n public async Task ReadHealthStateAsync()\n {\n using var response = await MinimalWebHostTestFactory.RunAsync(\n services => services.AddSingleton(new HealthState(\"healthy\")),\n app => app.Run(context =>\n {\n var health = context.RequestServices.GetRequiredService();\n return context.Response.WriteAsync(health.Value);\n })).ConfigureAwait(false);\n\n return await response.Content.ReadAsStringAsync().ConfigureAwait(false);\n }\n}\n\npublic sealed record HealthState(string Value);\n\npublic sealed class RunExample\n{\n [Fact]\n public async Task ExercisesExample()\n {\n Assert.Equal(\"healthy\", await new MinimalWebHostTestFactoryExample().ReadHealthStateAsync());\n }\n}" +} +'@ +$OutputEncoding = [Text.UTF8Encoding]::new($false) +[Console]::OutputEncoding = $OutputEncoding +$verifyTests = $true +function Assert-CsrunTestOutput([string] $Output) { + $lines = @($Output -split '\r?\n') + $headers = @($lines | Where-Object { $_ -match '^Test run summary: Passed! - .+\)$' }) + if ($headers.Count -ne 1) { throw 'Expected exactly one completed xUnit test summary.' } + $headerIndex = [Array]::IndexOf($lines, $headers[0]) + $summaryLines = @($lines | Select-Object -Skip ($headerIndex + 1) -First 4) + $counts = @{} + foreach ($line in $summaryLines) { + if ($line -match '^\s*(total|failed|succeeded|skipped):\s*(\d+)\s*$') { $counts[$Matches[1]] = [int]$Matches[2] } + } + if ($counts.Count -ne 4) { throw 'The xUnit test summary counts are incomplete or ambiguous.' } + $failed = $counts.failed + $passed = $counts.succeeded + $skipped = $counts.skipped + $total = $counts.total + if ($total -lt 1 -or $passed -lt 1 -or $failed -ne 0 -or $skipped -ne 0 -or $passed -ne $total) { + throw 'Tests must execute at least once, all pass, and none fail or skip.' + } +} +# Downloads and executes the latest stable csrun release with your permissions. +# Source and release history: https://github.com/codebeltnet/csrun +$engineDirectory = Join-Path ([IO.Path]::GetTempPath()) ('csrun-' + [guid]::NewGuid().ToString('N')) +$null = New-Item -ItemType Directory -Path $engineDirectory +$enginePath = Join-Path $engineDirectory 'csrun.ps1' +$process = $null +try { + $release = Invoke-RestMethod 'https://api.github.com/repos/codebeltnet/csrun/releases/latest' + $assets = @($release.assets | Where-Object name -CEQ 'csrun.ps1') + if ($assets.Count -ne 1 -or $assets[0].digest -notmatch '^sha256:[0-9a-f]{64}$') { + throw "csrun release $($release.tag_name) must publish one csrun.ps1 asset with a SHA-256 digest." + } + $asset = $assets[0] + Invoke-WebRequest $asset.browser_download_url -OutFile $enginePath + $actualHash = (Get-FileHash -LiteralPath $enginePath -Algorithm SHA256).Hash + if ("sha256:$actualHash" -ne $asset.digest) { throw "csrun asset checksum mismatch: $actualHash" } +$startInfo = [Diagnostics.ProcessStartInfo]::new('pwsh') +foreach ($argument in @('-NoProfile','-NonInteractive','-File')) { $startInfo.ArgumentList.Add($argument) } +$startInfo.ArgumentList.Add($enginePath) +$startInfo.ArgumentList.Add('-ManifestJson') +$startInfo.ArgumentList.Add($manifest) +$startInfo.RedirectStandardOutput = $true +$startInfo.RedirectStandardError = $true +$startInfo.UseShellExecute = $false +$process = [Diagnostics.Process]::new() +$process.StartInfo = $startInfo +if (-not $process.Start()) { throw 'Could not start csrun.' } +$stdoutTask = $process.StandardOutput.ReadToEndAsync() +$stderrTask = $process.StandardError.ReadToEndAsync() +$process.WaitForExit() +$output = $stdoutTask.GetAwaiter().GetResult() +$diagnostics = $stderrTask.GetAwaiter().GetResult() +Write-Output $output +if ($diagnostics) { [Console]::Error.Write($diagnostics) } +} catch { + [Console]::Error.WriteLine("csrun diagnostics retained in: $engineDirectory") + throw +} finally { + $resolvedTemp = [IO.Path]::TrimEndingDirectorySeparator([IO.Path]::GetFullPath([IO.Path]::GetTempPath())) + $resolvedEngineDirectory = [IO.Path]::GetFullPath($engineDirectory) + if ([IO.Path]::GetDirectoryName($resolvedEngineDirectory) -ne $resolvedTemp -or + [IO.Path]::GetFileName($resolvedEngineDirectory) -cnotmatch '^csrun-[a-f0-9]{32}$') { throw 'Unsafe cleanup path.' } + if ($process -and $process.ExitCode -eq 0) { Remove-Item -LiteralPath $resolvedEngineDirectory -Recurse -Force } +} +if ($process.ExitCode -ne 0) { throw "csrun execution failed with exit code $($process.ExitCode). $diagnostics" } +if ($verifyTests) { Assert-CsrunTestOutput $output } +} \ No newline at end of file diff --git a/.docfx/run-actions/1ec9196292addaca42a7eef1/docker.ps1 b/.docfx/run-actions/1ec9196292addaca42a7eef1/docker.ps1 new file mode 100644 index 0000000..d968ec5 --- /dev/null +++ b/.docfx/run-actions/1ec9196292addaca42a7eef1/docker.ps1 @@ -0,0 +1,58 @@ +& { +#requires -Version 7.0 + $ErrorActionPreference = 'Stop' + $PSNativeCommandUseErrorActionPreference = $false + # Executes trusted repository build tasks and NuGet packages with your permissions. + # Review the pinned source before running; a container is not a security sandbox. + $null = Get-Command docker -ErrorAction Stop + docker info *> $null + if ($LASTEXITCODE -ne 0) { throw 'Docker daemon unavailable.' } + $work = Join-Path ([IO.Path]::GetTempPath()) ('dx-' + [guid]::NewGuid().ToString('N').Substring(0, 8)) + $null = New-Item -ItemType Directory -Path $work + try { + $commit = '84b13767cb9484f8f3a36a71875662edfdb3e511' + Invoke-WebRequest "https://codeload.github.com/codebeltnet/xunit/zip/$commit" -OutFile "$work/source.zip" + Expand-Archive -LiteralPath "$work/source.zip" -DestinationPath "$work/extracted" + Move-Item -LiteralPath "$work/extracted/xunit-$commit" -Destination "$work/repo" + $project = 'test/Codebelt.Extensions.Xunit.Hosting.FunctionalTests/Codebelt.Extensions.Xunit.Hosting.FunctionalTests.csproj' + $test = 'Codebelt.Extensions.Xunit.Hosting.BootstrapperMinimalWorkerApplicationTestTest.ShouldBootstrapMinimalWorkerProgram' + $dockerUser = @() + if ($IsLinux) { + # Keep bind-mounted build output removable by the host user. + $hostUid = id -u + if ($LASTEXITCODE -ne 0) { throw 'Cannot resolve host UID.' } + $hostGid = id -g + if ($LASTEXITCODE -ne 0) { throw 'Cannot resolve host GID.' } + $dockerUser = @('--user', "${hostUid}:${hostGid}") + } + # Let Docker's init reap orphaned build processes and keep build servers disposable. + docker run --rm --init @dockerUser --env HOME=/tmp --env DOTNET_CLI_HOME=/tmp --env MSBUILDDISABLENODEREUSE=1 --mount "type=bind,source=$work,target=/work" --workdir /work/repo mcr.microsoft.com/dotnet/sdk:11.0 dotnet run --disable-build-servers --project $project --framework net11.0 -p:SkipSignAssembly=true -- --filter-method $test --report-xunit-xml --report-xunit-xml-filename result.xml --results-directory /work/results 2>&1 | Tee-Object -FilePath "$work/run.log" + $code = $LASTEXITCODE + if ($code -ne 0) { throw "Repository test failed with exit code $code. See $work/run.log" } + # Require exactly the original test, executed and passing, with no runner errors. + [xml] $report = Get-Content -LiteralPath "$work/results/result.xml" -Raw + $tests = @($report.SelectNodes('/assemblies/assembly/collection/test')) + $assemblies = @($report.SelectNodes('/assemblies/assembly')) + if ($assemblies.Count -ne 1 -or $assemblies[0].total -ne '1' -or $assemblies[0].passed -ne '1' -or + $assemblies[0].errors -ne '0' -or $tests.Count -ne 1 -or $tests[0].name -cne $test -or $tests[0].result -cne 'Pass') { + throw "Expected exactly one passing $test; inspect $work/results/result.xml" + } + Write-Host "Verified: $test (1 executed, 1 passed)." + } + catch { + # Preserve diagnostics outside the repository even though downloaded source is cleaned. + $diagnostics = "$work-diagnostics" + $null = New-Item -ItemType Directory -Path $diagnostics -Force + foreach ($name in @('run.log', 'results')) { + if (Test-Path -LiteralPath "$work/$name") { Copy-Item -LiteralPath "$work/$name" -Destination $diagnostics -Recurse } + } + Write-Warning "Execution not verified. Diagnostics: $diagnostics" + throw + } + finally { + $resolved = [IO.Path]::GetFullPath($work) + $temp = [IO.Path]::GetFullPath([IO.Path]::GetTempPath()).TrimEnd('/','\') + [IO.Path]::DirectorySeparatorChar + if (-not $resolved.StartsWith($temp, [StringComparison]::OrdinalIgnoreCase)) { throw 'Unsafe cleanup path.' } + Remove-Item -LiteralPath $resolved -Recurse -Force + } +} \ No newline at end of file diff --git a/.docfx/run-actions/1ec9196292addaca42a7eef1/native.ps1 b/.docfx/run-actions/1ec9196292addaca42a7eef1/native.ps1 new file mode 100644 index 0000000..39f3020 --- /dev/null +++ b/.docfx/run-actions/1ec9196292addaca42a7eef1/native.ps1 @@ -0,0 +1,50 @@ +& { +#requires -Version 7.0 + $ErrorActionPreference = 'Stop' + $PSNativeCommandUseErrorActionPreference = $false + # Executes trusted repository build tasks and NuGet packages with your permissions. + # Review the pinned source before running; a container is not a security sandbox. + $null = Get-Command dotnet -ErrorAction Stop + $work = Join-Path ([IO.Path]::GetTempPath()) ('dx-' + [guid]::NewGuid().ToString('N').Substring(0, 8)) + $null = New-Item -ItemType Directory -Path $work + try { + $commit = '84b13767cb9484f8f3a36a71875662edfdb3e511' + Invoke-WebRequest "https://codeload.github.com/codebeltnet/xunit/zip/$commit" -OutFile "$work/source.zip" + Expand-Archive -LiteralPath "$work/source.zip" -DestinationPath "$work/extracted" + Move-Item -LiteralPath "$work/extracted/xunit-$commit" -Destination "$work/repo" + $project = 'test/Codebelt.Extensions.Xunit.Hosting.FunctionalTests/Codebelt.Extensions.Xunit.Hosting.FunctionalTests.csproj' + $test = 'Codebelt.Extensions.Xunit.Hosting.BootstrapperMinimalWorkerApplicationTestTest.ShouldBootstrapMinimalWorkerProgram' + Push-Location "$work/repo" + try { + dotnet run --project $project --framework net11.0 -p:SkipSignAssembly=true -- --filter-method $test --report-xunit-xml --report-xunit-xml-filename result.xml --results-directory "$work/results" 2>&1 | Tee-Object -FilePath "$work/run.log" + } + finally { Pop-Location } + $code = $LASTEXITCODE + if ($code -ne 0) { throw "Repository test failed with exit code $code. See $work/run.log" } + # Require exactly the original test, executed and passing, with no runner errors. + [xml] $report = Get-Content -LiteralPath "$work/results/result.xml" -Raw + $tests = @($report.SelectNodes('/assemblies/assembly/collection/test')) + $assemblies = @($report.SelectNodes('/assemblies/assembly')) + if ($assemblies.Count -ne 1 -or $assemblies[0].total -ne '1' -or $assemblies[0].passed -ne '1' -or + $assemblies[0].errors -ne '0' -or $tests.Count -ne 1 -or $tests[0].name -cne $test -or $tests[0].result -cne 'Pass') { + throw "Expected exactly one passing $test; inspect $work/results/result.xml" + } + Write-Host "Verified: $test (1 executed, 1 passed)." + } + catch { + # Preserve diagnostics outside the repository even though downloaded source is cleaned. + $diagnostics = "$work-diagnostics" + $null = New-Item -ItemType Directory -Path $diagnostics -Force + foreach ($name in @('run.log', 'results')) { + if (Test-Path -LiteralPath "$work/$name") { Copy-Item -LiteralPath "$work/$name" -Destination $diagnostics -Recurse } + } + Write-Warning "Execution not verified. Diagnostics: $diagnostics" + throw + } + finally { + $resolved = [IO.Path]::GetFullPath($work) + $temp = [IO.Path]::GetFullPath([IO.Path]::GetTempPath()).TrimEnd('/','\') + [IO.Path]::DirectorySeparatorChar + if (-not $resolved.StartsWith($temp, [StringComparison]::OrdinalIgnoreCase)) { throw 'Unsafe cleanup path.' } + Remove-Item -LiteralPath $resolved -Recurse -Force + } +} \ No newline at end of file diff --git a/.docfx/run-actions/21b422ce67f920d801901db0/docker.ps1 b/.docfx/run-actions/21b422ce67f920d801901db0/docker.ps1 new file mode 100644 index 0000000..29b67e4 --- /dev/null +++ b/.docfx/run-actions/21b422ce67f920d801901db0/docker.ps1 @@ -0,0 +1,86 @@ +& { +#requires -Version 7.0 +$ErrorActionPreference = 'Stop' +$PSNativeCommandUseErrorActionPreference = $false +$manifest = @' +{ + "dependsOn": [ + "Codebelt.Extensions.Xunit.Hosting.AspNetCore@13.0.0", + "Microsoft.Extensions.Hosting@10.0.15", + "xunit.v3@4.0.3" + ], + "framework": "net10.0", + "frameworkReferences": [ + "Microsoft.AspNetCore.App" + ], + "mode": "test", + "schemaVersion": 1, + "source": "using Codebelt.Extensions.Xunit.Hosting.AspNetCore;\nusing Microsoft.Extensions.DependencyInjection;\nusing Microsoft.Extensions.Hosting;\nusing Xunit;\n\nnamespace WebFixtureTests;\n\npublic class WebHostIntegrationTest\n{\n [Fact]\n public void HostShouldBeStarted()\n {\n using var fixture = new BlockingManagedWebHostFixture();\n using var app = WebHostTestFactory.Create(hostFixture: fixture);\n\n Assert.True(fixture.HasValidState());\n var lifetime = app.Host.Services.GetRequiredService();\n Assert.True(lifetime.ApplicationStarted.IsCancellationRequested);\n }\n}" +} +'@ +$OutputEncoding = [Text.UTF8Encoding]::new($false) +[Console]::OutputEncoding = $OutputEncoding +$verifyTests = $true +function Assert-CsrunTestOutput([string] $Output) { + $lines = @($Output -split '\r?\n') + $headers = @($lines | Where-Object { $_ -match '^Test run summary: Passed! - .+\)$' }) + if ($headers.Count -ne 1) { throw 'Expected exactly one completed xUnit test summary.' } + $headerIndex = [Array]::IndexOf($lines, $headers[0]) + $summaryLines = @($lines | Select-Object -Skip ($headerIndex + 1) -First 4) + $counts = @{} + foreach ($line in $summaryLines) { + if ($line -match '^\s*(total|failed|succeeded|skipped):\s*(\d+)\s*$') { $counts[$Matches[1]] = [int]$Matches[2] } + } + if ($counts.Count -ne 4) { throw 'The xUnit test summary counts are incomplete or ambiguous.' } + $failed = $counts.failed + $passed = $counts.succeeded + $skipped = $counts.skipped + $total = $counts.total + if ($total -lt 1 -or $passed -lt 1 -or $failed -ne 0 -or $skipped -ne 0 -or $passed -ne $total) { + throw 'Tests must execute at least once, all pass, and none fail or skip.' + } +} +# Downloads and executes the latest stable csrun release with your permissions. +# Source and release history: https://github.com/codebeltnet/csrun +$engineDirectory = Join-Path ([IO.Path]::GetTempPath()) ('csrun-' + [guid]::NewGuid().ToString('N')) +$null = New-Item -ItemType Directory -Path $engineDirectory +$enginePath = Join-Path $engineDirectory 'csrun.ps1' +$process = $null +try { + $release = Invoke-RestMethod 'https://api.github.com/repos/codebeltnet/csrun/releases/latest' + $assets = @($release.assets | Where-Object name -CEQ 'csrun.ps1') + if ($assets.Count -ne 1 -or $assets[0].digest -notmatch '^sha256:[0-9a-f]{64}$') { + throw "csrun release $($release.tag_name) must publish one csrun.ps1 asset with a SHA-256 digest." + } + $asset = $assets[0] + Invoke-WebRequest $asset.browser_download_url -OutFile $enginePath + $actualHash = (Get-FileHash -LiteralPath $enginePath -Algorithm SHA256).Hash + if ("sha256:$actualHash" -ne $asset.digest) { throw "csrun asset checksum mismatch: $actualHash" } +$enginePayload = [Convert]::ToBase64String([IO.File]::ReadAllBytes($enginePath)) +$containerInput = $enginePayload + "`n" + $manifest +$command = ' +$ErrorActionPreference = "Stop" +$enginePath = Join-Path ([IO.Path]::GetTempPath()) ("csrun-release-" + [guid]::NewGuid().ToString("N") + ".ps1") +$engineBytes = [Convert]::FromBase64String([Console]::In.ReadLine()) +[IO.File]::WriteAllBytes($enginePath, $engineBytes) +$manifest = [Console]::In.ReadToEnd() +& $enginePath -ManifestJson $manifest +exit $LASTEXITCODE +' +$output = (@($containerInput | & docker run --rm -i --entrypoint pwsh 'codebeltnet/csrun:10' -NoProfile -NonInteractive -Command $command) -join [Environment]::NewLine) +$process = [pscustomobject]@{ ExitCode = $LASTEXITCODE } +$diagnostics = '' +Write-Output $output +} catch { + [Console]::Error.WriteLine("csrun diagnostics retained in: $engineDirectory") + throw +} finally { + $resolvedTemp = [IO.Path]::TrimEndingDirectorySeparator([IO.Path]::GetFullPath([IO.Path]::GetTempPath())) + $resolvedEngineDirectory = [IO.Path]::GetFullPath($engineDirectory) + if ([IO.Path]::GetDirectoryName($resolvedEngineDirectory) -ne $resolvedTemp -or + [IO.Path]::GetFileName($resolvedEngineDirectory) -cnotmatch '^csrun-[a-f0-9]{32}$') { throw 'Unsafe cleanup path.' } + if ($process -and $process.ExitCode -eq 0) { Remove-Item -LiteralPath $resolvedEngineDirectory -Recurse -Force } +} +if ($process.ExitCode -ne 0) { throw "csrun execution failed with exit code $($process.ExitCode). $diagnostics" } +if ($verifyTests) { Assert-CsrunTestOutput $output } +} \ No newline at end of file diff --git a/.docfx/run-actions/21b422ce67f920d801901db0/native.ps1 b/.docfx/run-actions/21b422ce67f920d801901db0/native.ps1 new file mode 100644 index 0000000..a01584e --- /dev/null +++ b/.docfx/run-actions/21b422ce67f920d801901db0/native.ps1 @@ -0,0 +1,89 @@ +& { +#requires -Version 7.0 +$ErrorActionPreference = 'Stop' +$PSNativeCommandUseErrorActionPreference = $false +$manifest = @' +{ + "dependsOn": [ + "Codebelt.Extensions.Xunit.Hosting.AspNetCore@13.0.0", + "Microsoft.Extensions.Hosting@10.0.15", + "xunit.v3@4.0.3" + ], + "framework": "net10.0", + "frameworkReferences": [ + "Microsoft.AspNetCore.App" + ], + "mode": "test", + "schemaVersion": 1, + "source": "using Codebelt.Extensions.Xunit.Hosting.AspNetCore;\nusing Microsoft.Extensions.DependencyInjection;\nusing Microsoft.Extensions.Hosting;\nusing Xunit;\n\nnamespace WebFixtureTests;\n\npublic class WebHostIntegrationTest\n{\n [Fact]\n public void HostShouldBeStarted()\n {\n using var fixture = new BlockingManagedWebHostFixture();\n using var app = WebHostTestFactory.Create(hostFixture: fixture);\n\n Assert.True(fixture.HasValidState());\n var lifetime = app.Host.Services.GetRequiredService();\n Assert.True(lifetime.ApplicationStarted.IsCancellationRequested);\n }\n}" +} +'@ +$OutputEncoding = [Text.UTF8Encoding]::new($false) +[Console]::OutputEncoding = $OutputEncoding +$verifyTests = $true +function Assert-CsrunTestOutput([string] $Output) { + $lines = @($Output -split '\r?\n') + $headers = @($lines | Where-Object { $_ -match '^Test run summary: Passed! - .+\)$' }) + if ($headers.Count -ne 1) { throw 'Expected exactly one completed xUnit test summary.' } + $headerIndex = [Array]::IndexOf($lines, $headers[0]) + $summaryLines = @($lines | Select-Object -Skip ($headerIndex + 1) -First 4) + $counts = @{} + foreach ($line in $summaryLines) { + if ($line -match '^\s*(total|failed|succeeded|skipped):\s*(\d+)\s*$') { $counts[$Matches[1]] = [int]$Matches[2] } + } + if ($counts.Count -ne 4) { throw 'The xUnit test summary counts are incomplete or ambiguous.' } + $failed = $counts.failed + $passed = $counts.succeeded + $skipped = $counts.skipped + $total = $counts.total + if ($total -lt 1 -or $passed -lt 1 -or $failed -ne 0 -or $skipped -ne 0 -or $passed -ne $total) { + throw 'Tests must execute at least once, all pass, and none fail or skip.' + } +} +# Downloads and executes the latest stable csrun release with your permissions. +# Source and release history: https://github.com/codebeltnet/csrun +$engineDirectory = Join-Path ([IO.Path]::GetTempPath()) ('csrun-' + [guid]::NewGuid().ToString('N')) +$null = New-Item -ItemType Directory -Path $engineDirectory +$enginePath = Join-Path $engineDirectory 'csrun.ps1' +$process = $null +try { + $release = Invoke-RestMethod 'https://api.github.com/repos/codebeltnet/csrun/releases/latest' + $assets = @($release.assets | Where-Object name -CEQ 'csrun.ps1') + if ($assets.Count -ne 1 -or $assets[0].digest -notmatch '^sha256:[0-9a-f]{64}$') { + throw "csrun release $($release.tag_name) must publish one csrun.ps1 asset with a SHA-256 digest." + } + $asset = $assets[0] + Invoke-WebRequest $asset.browser_download_url -OutFile $enginePath + $actualHash = (Get-FileHash -LiteralPath $enginePath -Algorithm SHA256).Hash + if ("sha256:$actualHash" -ne $asset.digest) { throw "csrun asset checksum mismatch: $actualHash" } +$startInfo = [Diagnostics.ProcessStartInfo]::new('pwsh') +foreach ($argument in @('-NoProfile','-NonInteractive','-File')) { $startInfo.ArgumentList.Add($argument) } +$startInfo.ArgumentList.Add($enginePath) +$startInfo.ArgumentList.Add('-ManifestJson') +$startInfo.ArgumentList.Add($manifest) +$startInfo.RedirectStandardOutput = $true +$startInfo.RedirectStandardError = $true +$startInfo.UseShellExecute = $false +$process = [Diagnostics.Process]::new() +$process.StartInfo = $startInfo +if (-not $process.Start()) { throw 'Could not start csrun.' } +$stdoutTask = $process.StandardOutput.ReadToEndAsync() +$stderrTask = $process.StandardError.ReadToEndAsync() +$process.WaitForExit() +$output = $stdoutTask.GetAwaiter().GetResult() +$diagnostics = $stderrTask.GetAwaiter().GetResult() +Write-Output $output +if ($diagnostics) { [Console]::Error.Write($diagnostics) } +} catch { + [Console]::Error.WriteLine("csrun diagnostics retained in: $engineDirectory") + throw +} finally { + $resolvedTemp = [IO.Path]::TrimEndingDirectorySeparator([IO.Path]::GetFullPath([IO.Path]::GetTempPath())) + $resolvedEngineDirectory = [IO.Path]::GetFullPath($engineDirectory) + if ([IO.Path]::GetDirectoryName($resolvedEngineDirectory) -ne $resolvedTemp -or + [IO.Path]::GetFileName($resolvedEngineDirectory) -cnotmatch '^csrun-[a-f0-9]{32}$') { throw 'Unsafe cleanup path.' } + if ($process -and $process.ExitCode -eq 0) { Remove-Item -LiteralPath $resolvedEngineDirectory -Recurse -Force } +} +if ($process.ExitCode -ne 0) { throw "csrun execution failed with exit code $($process.ExitCode). $diagnostics" } +if ($verifyTests) { Assert-CsrunTestOutput $output } +} \ No newline at end of file diff --git a/.docfx/run-actions/38b60f4b4c1a588bbefe92f1/docker.ps1 b/.docfx/run-actions/38b60f4b4c1a588bbefe92f1/docker.ps1 new file mode 100644 index 0000000..c68fd3b --- /dev/null +++ b/.docfx/run-actions/38b60f4b4c1a588bbefe92f1/docker.ps1 @@ -0,0 +1,58 @@ +& { +#requires -Version 7.0 + $ErrorActionPreference = 'Stop' + $PSNativeCommandUseErrorActionPreference = $false + # Executes trusted repository build tasks and NuGet packages with your permissions. + # Review the pinned source before running; a container is not a security sandbox. + $null = Get-Command docker -ErrorAction Stop + docker info *> $null + if ($LASTEXITCODE -ne 0) { throw 'Docker daemon unavailable.' } + $work = Join-Path ([IO.Path]::GetTempPath()) ('dx-' + [guid]::NewGuid().ToString('N').Substring(0, 8)) + $null = New-Item -ItemType Directory -Path $work + try { + $commit = '84b13767cb9484f8f3a36a71875662edfdb3e511' + Invoke-WebRequest "https://codeload.github.com/codebeltnet/xunit/zip/$commit" -OutFile "$work/source.zip" + Expand-Archive -LiteralPath "$work/source.zip" -DestinationPath "$work/extracted" + Move-Item -LiteralPath "$work/extracted/xunit-$commit" -Destination "$work/repo" + $project = 'test/Codebelt.Extensions.Xunit.Hosting.AspNetCore.FunctionalTests/Codebelt.Extensions.Xunit.Hosting.AspNetCore.FunctionalTests.csproj' + $test = 'Codebelt.Extensions.Xunit.Hosting.AspNetCore.WebApplicationTestFactoryTest.Create_ShouldApplyWebHostConfiguration_WhenWebHostSetupIsProvided' + $dockerUser = @() + if ($IsLinux) { + # Keep bind-mounted build output removable by the host user. + $hostUid = id -u + if ($LASTEXITCODE -ne 0) { throw 'Cannot resolve host UID.' } + $hostGid = id -g + if ($LASTEXITCODE -ne 0) { throw 'Cannot resolve host GID.' } + $dockerUser = @('--user', "${hostUid}:${hostGid}") + } + # Let Docker's init reap orphaned build processes and keep build servers disposable. + docker run --rm --init @dockerUser --env HOME=/tmp --env DOTNET_CLI_HOME=/tmp --env MSBUILDDISABLENODEREUSE=1 --mount "type=bind,source=$work,target=/work" --workdir /work/repo mcr.microsoft.com/dotnet/sdk:11.0 dotnet run --disable-build-servers --project $project --framework net11.0 -p:SkipSignAssembly=true -- --filter-method $test --report-xunit-xml --report-xunit-xml-filename result.xml --results-directory /work/results 2>&1 | Tee-Object -FilePath "$work/run.log" + $code = $LASTEXITCODE + if ($code -ne 0) { throw "Repository test failed with exit code $code. See $work/run.log" } + # Require exactly the original test, executed and passing, with no runner errors. + [xml] $report = Get-Content -LiteralPath "$work/results/result.xml" -Raw + $tests = @($report.SelectNodes('/assemblies/assembly/collection/test')) + $assemblies = @($report.SelectNodes('/assemblies/assembly')) + if ($assemblies.Count -ne 1 -or $assemblies[0].total -ne '1' -or $assemblies[0].passed -ne '1' -or + $assemblies[0].errors -ne '0' -or $tests.Count -ne 1 -or $tests[0].name -cne $test -or $tests[0].result -cne 'Pass') { + throw "Expected exactly one passing $test; inspect $work/results/result.xml" + } + Write-Host "Verified: $test (1 executed, 1 passed)." + } + catch { + # Preserve diagnostics outside the repository even though downloaded source is cleaned. + $diagnostics = "$work-diagnostics" + $null = New-Item -ItemType Directory -Path $diagnostics -Force + foreach ($name in @('run.log', 'results')) { + if (Test-Path -LiteralPath "$work/$name") { Copy-Item -LiteralPath "$work/$name" -Destination $diagnostics -Recurse } + } + Write-Warning "Execution not verified. Diagnostics: $diagnostics" + throw + } + finally { + $resolved = [IO.Path]::GetFullPath($work) + $temp = [IO.Path]::GetFullPath([IO.Path]::GetTempPath()).TrimEnd('/','\') + [IO.Path]::DirectorySeparatorChar + if (-not $resolved.StartsWith($temp, [StringComparison]::OrdinalIgnoreCase)) { throw 'Unsafe cleanup path.' } + Remove-Item -LiteralPath $resolved -Recurse -Force + } +} \ No newline at end of file diff --git a/.docfx/run-actions/38b60f4b4c1a588bbefe92f1/native.ps1 b/.docfx/run-actions/38b60f4b4c1a588bbefe92f1/native.ps1 new file mode 100644 index 0000000..7de020a --- /dev/null +++ b/.docfx/run-actions/38b60f4b4c1a588bbefe92f1/native.ps1 @@ -0,0 +1,50 @@ +& { +#requires -Version 7.0 + $ErrorActionPreference = 'Stop' + $PSNativeCommandUseErrorActionPreference = $false + # Executes trusted repository build tasks and NuGet packages with your permissions. + # Review the pinned source before running; a container is not a security sandbox. + $null = Get-Command dotnet -ErrorAction Stop + $work = Join-Path ([IO.Path]::GetTempPath()) ('dx-' + [guid]::NewGuid().ToString('N').Substring(0, 8)) + $null = New-Item -ItemType Directory -Path $work + try { + $commit = '84b13767cb9484f8f3a36a71875662edfdb3e511' + Invoke-WebRequest "https://codeload.github.com/codebeltnet/xunit/zip/$commit" -OutFile "$work/source.zip" + Expand-Archive -LiteralPath "$work/source.zip" -DestinationPath "$work/extracted" + Move-Item -LiteralPath "$work/extracted/xunit-$commit" -Destination "$work/repo" + $project = 'test/Codebelt.Extensions.Xunit.Hosting.AspNetCore.FunctionalTests/Codebelt.Extensions.Xunit.Hosting.AspNetCore.FunctionalTests.csproj' + $test = 'Codebelt.Extensions.Xunit.Hosting.AspNetCore.WebApplicationTestFactoryTest.Create_ShouldApplyWebHostConfiguration_WhenWebHostSetupIsProvided' + Push-Location "$work/repo" + try { + dotnet run --project $project --framework net11.0 -p:SkipSignAssembly=true -- --filter-method $test --report-xunit-xml --report-xunit-xml-filename result.xml --results-directory "$work/results" 2>&1 | Tee-Object -FilePath "$work/run.log" + } + finally { Pop-Location } + $code = $LASTEXITCODE + if ($code -ne 0) { throw "Repository test failed with exit code $code. See $work/run.log" } + # Require exactly the original test, executed and passing, with no runner errors. + [xml] $report = Get-Content -LiteralPath "$work/results/result.xml" -Raw + $tests = @($report.SelectNodes('/assemblies/assembly/collection/test')) + $assemblies = @($report.SelectNodes('/assemblies/assembly')) + if ($assemblies.Count -ne 1 -or $assemblies[0].total -ne '1' -or $assemblies[0].passed -ne '1' -or + $assemblies[0].errors -ne '0' -or $tests.Count -ne 1 -or $tests[0].name -cne $test -or $tests[0].result -cne 'Pass') { + throw "Expected exactly one passing $test; inspect $work/results/result.xml" + } + Write-Host "Verified: $test (1 executed, 1 passed)." + } + catch { + # Preserve diagnostics outside the repository even though downloaded source is cleaned. + $diagnostics = "$work-diagnostics" + $null = New-Item -ItemType Directory -Path $diagnostics -Force + foreach ($name in @('run.log', 'results')) { + if (Test-Path -LiteralPath "$work/$name") { Copy-Item -LiteralPath "$work/$name" -Destination $diagnostics -Recurse } + } + Write-Warning "Execution not verified. Diagnostics: $diagnostics" + throw + } + finally { + $resolved = [IO.Path]::GetFullPath($work) + $temp = [IO.Path]::GetFullPath([IO.Path]::GetTempPath()).TrimEnd('/','\') + [IO.Path]::DirectorySeparatorChar + if (-not $resolved.StartsWith($temp, [StringComparison]::OrdinalIgnoreCase)) { throw 'Unsafe cleanup path.' } + Remove-Item -LiteralPath $resolved -Recurse -Force + } +} \ No newline at end of file diff --git a/.docfx/run-actions/3a1dbfc0e010519636b7091e/docker.ps1 b/.docfx/run-actions/3a1dbfc0e010519636b7091e/docker.ps1 new file mode 100644 index 0000000..031a28f --- /dev/null +++ b/.docfx/run-actions/3a1dbfc0e010519636b7091e/docker.ps1 @@ -0,0 +1,85 @@ +& { +#requires -Version 7.0 +$ErrorActionPreference = 'Stop' +$PSNativeCommandUseErrorActionPreference = $false +$manifest = @' +{ + "dependsOn": [ + "Codebelt.Extensions.Xunit.Hosting.AspNetCore@13.0.0" + ], + "framework": "net10.0", + "frameworkReferences": [ + "Microsoft.AspNetCore.App" + ], + "mode": "console", + "schemaVersion": 1, + "sdk": "Microsoft.NET.Sdk.Web", + "source": "using System;\nusing Codebelt.Extensions.Xunit.Hosting.AspNetCore.Http;\n\nnamespace WebFixtureTests;\n\npublic class HttpContextExample\n{\n public void Demonstrate()\n {\n var accessor = new FakeHttpContextAccessor();\n Console.WriteLine(accessor.HttpContext.Request.Method);\n }\n}\n\ninternal static class RunExample\n{\n static void Main()\n {\n new HttpContextExample().Demonstrate();\n }\n}" +} +'@ +$OutputEncoding = [Text.UTF8Encoding]::new($false) +[Console]::OutputEncoding = $OutputEncoding +$verifyTests = $false +function Assert-CsrunTestOutput([string] $Output) { + $lines = @($Output -split '\r?\n') + $headers = @($lines | Where-Object { $_ -match '^Test run summary: Passed! - .+\)$' }) + if ($headers.Count -ne 1) { throw 'Expected exactly one completed xUnit test summary.' } + $headerIndex = [Array]::IndexOf($lines, $headers[0]) + $summaryLines = @($lines | Select-Object -Skip ($headerIndex + 1) -First 4) + $counts = @{} + foreach ($line in $summaryLines) { + if ($line -match '^\s*(total|failed|succeeded|skipped):\s*(\d+)\s*$') { $counts[$Matches[1]] = [int]$Matches[2] } + } + if ($counts.Count -ne 4) { throw 'The xUnit test summary counts are incomplete or ambiguous.' } + $failed = $counts.failed + $passed = $counts.succeeded + $skipped = $counts.skipped + $total = $counts.total + if ($total -lt 1 -or $passed -lt 1 -or $failed -ne 0 -or $skipped -ne 0 -or $passed -ne $total) { + throw 'Tests must execute at least once, all pass, and none fail or skip.' + } +} +# Downloads and executes the latest stable csrun release with your permissions. +# Source and release history: https://github.com/codebeltnet/csrun +$engineDirectory = Join-Path ([IO.Path]::GetTempPath()) ('csrun-' + [guid]::NewGuid().ToString('N')) +$null = New-Item -ItemType Directory -Path $engineDirectory +$enginePath = Join-Path $engineDirectory 'csrun.ps1' +$process = $null +try { + $release = Invoke-RestMethod 'https://api.github.com/repos/codebeltnet/csrun/releases/latest' + $assets = @($release.assets | Where-Object name -CEQ 'csrun.ps1') + if ($assets.Count -ne 1 -or $assets[0].digest -notmatch '^sha256:[0-9a-f]{64}$') { + throw "csrun release $($release.tag_name) must publish one csrun.ps1 asset with a SHA-256 digest." + } + $asset = $assets[0] + Invoke-WebRequest $asset.browser_download_url -OutFile $enginePath + $actualHash = (Get-FileHash -LiteralPath $enginePath -Algorithm SHA256).Hash + if ("sha256:$actualHash" -ne $asset.digest) { throw "csrun asset checksum mismatch: $actualHash" } +$enginePayload = [Convert]::ToBase64String([IO.File]::ReadAllBytes($enginePath)) +$containerInput = $enginePayload + "`n" + $manifest +$command = ' +$ErrorActionPreference = "Stop" +$enginePath = Join-Path ([IO.Path]::GetTempPath()) ("csrun-release-" + [guid]::NewGuid().ToString("N") + ".ps1") +$engineBytes = [Convert]::FromBase64String([Console]::In.ReadLine()) +[IO.File]::WriteAllBytes($enginePath, $engineBytes) +$manifest = [Console]::In.ReadToEnd() +& $enginePath -ManifestJson $manifest +exit $LASTEXITCODE +' +$output = (@($containerInput | & docker run --rm -i --entrypoint pwsh 'codebeltnet/csrun:10' -NoProfile -NonInteractive -Command $command) -join [Environment]::NewLine) +$process = [pscustomobject]@{ ExitCode = $LASTEXITCODE } +$diagnostics = '' +Write-Output $output +} catch { + [Console]::Error.WriteLine("csrun diagnostics retained in: $engineDirectory") + throw +} finally { + $resolvedTemp = [IO.Path]::TrimEndingDirectorySeparator([IO.Path]::GetFullPath([IO.Path]::GetTempPath())) + $resolvedEngineDirectory = [IO.Path]::GetFullPath($engineDirectory) + if ([IO.Path]::GetDirectoryName($resolvedEngineDirectory) -ne $resolvedTemp -or + [IO.Path]::GetFileName($resolvedEngineDirectory) -cnotmatch '^csrun-[a-f0-9]{32}$') { throw 'Unsafe cleanup path.' } + if ($process -and $process.ExitCode -eq 0) { Remove-Item -LiteralPath $resolvedEngineDirectory -Recurse -Force } +} +if ($process.ExitCode -ne 0) { throw "csrun execution failed with exit code $($process.ExitCode). $diagnostics" } +if ($verifyTests) { Assert-CsrunTestOutput $output } +} \ No newline at end of file diff --git a/.docfx/run-actions/3a1dbfc0e010519636b7091e/native.ps1 b/.docfx/run-actions/3a1dbfc0e010519636b7091e/native.ps1 new file mode 100644 index 0000000..0c24017 --- /dev/null +++ b/.docfx/run-actions/3a1dbfc0e010519636b7091e/native.ps1 @@ -0,0 +1,88 @@ +& { +#requires -Version 7.0 +$ErrorActionPreference = 'Stop' +$PSNativeCommandUseErrorActionPreference = $false +$manifest = @' +{ + "dependsOn": [ + "Codebelt.Extensions.Xunit.Hosting.AspNetCore@13.0.0" + ], + "framework": "net10.0", + "frameworkReferences": [ + "Microsoft.AspNetCore.App" + ], + "mode": "console", + "schemaVersion": 1, + "sdk": "Microsoft.NET.Sdk.Web", + "source": "using System;\nusing Codebelt.Extensions.Xunit.Hosting.AspNetCore.Http;\n\nnamespace WebFixtureTests;\n\npublic class HttpContextExample\n{\n public void Demonstrate()\n {\n var accessor = new FakeHttpContextAccessor();\n Console.WriteLine(accessor.HttpContext.Request.Method);\n }\n}\n\ninternal static class RunExample\n{\n static void Main()\n {\n new HttpContextExample().Demonstrate();\n }\n}" +} +'@ +$OutputEncoding = [Text.UTF8Encoding]::new($false) +[Console]::OutputEncoding = $OutputEncoding +$verifyTests = $false +function Assert-CsrunTestOutput([string] $Output) { + $lines = @($Output -split '\r?\n') + $headers = @($lines | Where-Object { $_ -match '^Test run summary: Passed! - .+\)$' }) + if ($headers.Count -ne 1) { throw 'Expected exactly one completed xUnit test summary.' } + $headerIndex = [Array]::IndexOf($lines, $headers[0]) + $summaryLines = @($lines | Select-Object -Skip ($headerIndex + 1) -First 4) + $counts = @{} + foreach ($line in $summaryLines) { + if ($line -match '^\s*(total|failed|succeeded|skipped):\s*(\d+)\s*$') { $counts[$Matches[1]] = [int]$Matches[2] } + } + if ($counts.Count -ne 4) { throw 'The xUnit test summary counts are incomplete or ambiguous.' } + $failed = $counts.failed + $passed = $counts.succeeded + $skipped = $counts.skipped + $total = $counts.total + if ($total -lt 1 -or $passed -lt 1 -or $failed -ne 0 -or $skipped -ne 0 -or $passed -ne $total) { + throw 'Tests must execute at least once, all pass, and none fail or skip.' + } +} +# Downloads and executes the latest stable csrun release with your permissions. +# Source and release history: https://github.com/codebeltnet/csrun +$engineDirectory = Join-Path ([IO.Path]::GetTempPath()) ('csrun-' + [guid]::NewGuid().ToString('N')) +$null = New-Item -ItemType Directory -Path $engineDirectory +$enginePath = Join-Path $engineDirectory 'csrun.ps1' +$process = $null +try { + $release = Invoke-RestMethod 'https://api.github.com/repos/codebeltnet/csrun/releases/latest' + $assets = @($release.assets | Where-Object name -CEQ 'csrun.ps1') + if ($assets.Count -ne 1 -or $assets[0].digest -notmatch '^sha256:[0-9a-f]{64}$') { + throw "csrun release $($release.tag_name) must publish one csrun.ps1 asset with a SHA-256 digest." + } + $asset = $assets[0] + Invoke-WebRequest $asset.browser_download_url -OutFile $enginePath + $actualHash = (Get-FileHash -LiteralPath $enginePath -Algorithm SHA256).Hash + if ("sha256:$actualHash" -ne $asset.digest) { throw "csrun asset checksum mismatch: $actualHash" } +$startInfo = [Diagnostics.ProcessStartInfo]::new('pwsh') +foreach ($argument in @('-NoProfile','-NonInteractive','-File')) { $startInfo.ArgumentList.Add($argument) } +$startInfo.ArgumentList.Add($enginePath) +$startInfo.ArgumentList.Add('-ManifestJson') +$startInfo.ArgumentList.Add($manifest) +$startInfo.RedirectStandardOutput = $true +$startInfo.RedirectStandardError = $true +$startInfo.UseShellExecute = $false +$process = [Diagnostics.Process]::new() +$process.StartInfo = $startInfo +if (-not $process.Start()) { throw 'Could not start csrun.' } +$stdoutTask = $process.StandardOutput.ReadToEndAsync() +$stderrTask = $process.StandardError.ReadToEndAsync() +$process.WaitForExit() +$output = $stdoutTask.GetAwaiter().GetResult() +$diagnostics = $stderrTask.GetAwaiter().GetResult() +Write-Output $output +if ($diagnostics) { [Console]::Error.Write($diagnostics) } +} catch { + [Console]::Error.WriteLine("csrun diagnostics retained in: $engineDirectory") + throw +} finally { + $resolvedTemp = [IO.Path]::TrimEndingDirectorySeparator([IO.Path]::GetFullPath([IO.Path]::GetTempPath())) + $resolvedEngineDirectory = [IO.Path]::GetFullPath($engineDirectory) + if ([IO.Path]::GetDirectoryName($resolvedEngineDirectory) -ne $resolvedTemp -or + [IO.Path]::GetFileName($resolvedEngineDirectory) -cnotmatch '^csrun-[a-f0-9]{32}$') { throw 'Unsafe cleanup path.' } + if ($process -and $process.ExitCode -eq 0) { Remove-Item -LiteralPath $resolvedEngineDirectory -Recurse -Force } +} +if ($process.ExitCode -ne 0) { throw "csrun execution failed with exit code $($process.ExitCode). $diagnostics" } +if ($verifyTests) { Assert-CsrunTestOutput $output } +} \ No newline at end of file diff --git a/.docfx/run-actions/3c3b98167b30d6985017ec27/docker.ps1 b/.docfx/run-actions/3c3b98167b30d6985017ec27/docker.ps1 new file mode 100644 index 0000000..ce7eda5 --- /dev/null +++ b/.docfx/run-actions/3c3b98167b30d6985017ec27/docker.ps1 @@ -0,0 +1,87 @@ +& { +#requires -Version 7.0 +$ErrorActionPreference = 'Stop' +$PSNativeCommandUseErrorActionPreference = $false +$manifest = @' +{ + "dependsOn": [ + "Codebelt.Extensions.Xunit.Hosting.AspNetCore@13.0.0", + "Microsoft.Extensions.Hosting@10.0.15", + "Microsoft.AspNetCore.TestHost@10.0.15", + "xunit.v3@4.0.3" + ], + "framework": "net10.0", + "frameworkReferences": [ + "Microsoft.AspNetCore.App" + ], + "mode": "test", + "schemaVersion": 1, + "source": "using System.Threading.Tasks;\nusing Codebelt.Extensions.Xunit.Hosting.AspNetCore;\nusing Microsoft.AspNetCore.Builder;\nusing Microsoft.AspNetCore.Http;\nusing Microsoft.AspNetCore.TestHost;\nusing Microsoft.Extensions.DependencyInjection;\nusing Microsoft.Extensions.Hosting;\nusing Xunit;\n\nnamespace DeferredHealthEndpoint.Tests;\n\npublic sealed class SelfManagedWebMinimalHostFixtureExample\n{\n public async Task StartHealthEndpointWhenReadyAsync()\n {\n using var host = MinimalWebHostTestFactory.Create(\n services => services.AddSingleton(new HealthState(\"healthy\")),\n pipelineSetup: app => app.Run(context =>\n {\n var health = context.RequestServices.GetRequiredService();\n return context.Response.WriteAsync(health.Value);\n }),\n hostFixture: new SelfManagedWebMinimalHostFixture());\n\n await host.Host.StartAsync().ConfigureAwait(false);\n using var client = host.Host.GetTestClient();\n\n return await client.GetStringAsync(\"/\").ConfigureAwait(false);\n }\n}\n\npublic sealed record HealthState(string Value);\n\npublic sealed class RunExample\n{\n [Fact]\n public async Task ExercisesExample()\n {\n Assert.Equal(\"healthy\", await new SelfManagedWebMinimalHostFixtureExample().StartHealthEndpointWhenReadyAsync());\n }\n}" +} +'@ +$OutputEncoding = [Text.UTF8Encoding]::new($false) +[Console]::OutputEncoding = $OutputEncoding +$verifyTests = $true +function Assert-CsrunTestOutput([string] $Output) { + $lines = @($Output -split '\r?\n') + $headers = @($lines | Where-Object { $_ -match '^Test run summary: Passed! - .+\)$' }) + if ($headers.Count -ne 1) { throw 'Expected exactly one completed xUnit test summary.' } + $headerIndex = [Array]::IndexOf($lines, $headers[0]) + $summaryLines = @($lines | Select-Object -Skip ($headerIndex + 1) -First 4) + $counts = @{} + foreach ($line in $summaryLines) { + if ($line -match '^\s*(total|failed|succeeded|skipped):\s*(\d+)\s*$') { $counts[$Matches[1]] = [int]$Matches[2] } + } + if ($counts.Count -ne 4) { throw 'The xUnit test summary counts are incomplete or ambiguous.' } + $failed = $counts.failed + $passed = $counts.succeeded + $skipped = $counts.skipped + $total = $counts.total + if ($total -lt 1 -or $passed -lt 1 -or $failed -ne 0 -or $skipped -ne 0 -or $passed -ne $total) { + throw 'Tests must execute at least once, all pass, and none fail or skip.' + } +} +# Downloads and executes the latest stable csrun release with your permissions. +# Source and release history: https://github.com/codebeltnet/csrun +$engineDirectory = Join-Path ([IO.Path]::GetTempPath()) ('csrun-' + [guid]::NewGuid().ToString('N')) +$null = New-Item -ItemType Directory -Path $engineDirectory +$enginePath = Join-Path $engineDirectory 'csrun.ps1' +$process = $null +try { + $release = Invoke-RestMethod 'https://api.github.com/repos/codebeltnet/csrun/releases/latest' + $assets = @($release.assets | Where-Object name -CEQ 'csrun.ps1') + if ($assets.Count -ne 1 -or $assets[0].digest -notmatch '^sha256:[0-9a-f]{64}$') { + throw "csrun release $($release.tag_name) must publish one csrun.ps1 asset with a SHA-256 digest." + } + $asset = $assets[0] + Invoke-WebRequest $asset.browser_download_url -OutFile $enginePath + $actualHash = (Get-FileHash -LiteralPath $enginePath -Algorithm SHA256).Hash + if ("sha256:$actualHash" -ne $asset.digest) { throw "csrun asset checksum mismatch: $actualHash" } +$enginePayload = [Convert]::ToBase64String([IO.File]::ReadAllBytes($enginePath)) +$containerInput = $enginePayload + "`n" + $manifest +$command = ' +$ErrorActionPreference = "Stop" +$enginePath = Join-Path ([IO.Path]::GetTempPath()) ("csrun-release-" + [guid]::NewGuid().ToString("N") + ".ps1") +$engineBytes = [Convert]::FromBase64String([Console]::In.ReadLine()) +[IO.File]::WriteAllBytes($enginePath, $engineBytes) +$manifest = [Console]::In.ReadToEnd() +& $enginePath -ManifestJson $manifest +exit $LASTEXITCODE +' +$output = (@($containerInput | & docker run --rm -i --entrypoint pwsh 'codebeltnet/csrun:10' -NoProfile -NonInteractive -Command $command) -join [Environment]::NewLine) +$process = [pscustomobject]@{ ExitCode = $LASTEXITCODE } +$diagnostics = '' +Write-Output $output +} catch { + [Console]::Error.WriteLine("csrun diagnostics retained in: $engineDirectory") + throw +} finally { + $resolvedTemp = [IO.Path]::TrimEndingDirectorySeparator([IO.Path]::GetFullPath([IO.Path]::GetTempPath())) + $resolvedEngineDirectory = [IO.Path]::GetFullPath($engineDirectory) + if ([IO.Path]::GetDirectoryName($resolvedEngineDirectory) -ne $resolvedTemp -or + [IO.Path]::GetFileName($resolvedEngineDirectory) -cnotmatch '^csrun-[a-f0-9]{32}$') { throw 'Unsafe cleanup path.' } + if ($process -and $process.ExitCode -eq 0) { Remove-Item -LiteralPath $resolvedEngineDirectory -Recurse -Force } +} +if ($process.ExitCode -ne 0) { throw "csrun execution failed with exit code $($process.ExitCode). $diagnostics" } +if ($verifyTests) { Assert-CsrunTestOutput $output } +} \ No newline at end of file diff --git a/.docfx/run-actions/3c3b98167b30d6985017ec27/native.ps1 b/.docfx/run-actions/3c3b98167b30d6985017ec27/native.ps1 new file mode 100644 index 0000000..800c9e0 --- /dev/null +++ b/.docfx/run-actions/3c3b98167b30d6985017ec27/native.ps1 @@ -0,0 +1,90 @@ +& { +#requires -Version 7.0 +$ErrorActionPreference = 'Stop' +$PSNativeCommandUseErrorActionPreference = $false +$manifest = @' +{ + "dependsOn": [ + "Codebelt.Extensions.Xunit.Hosting.AspNetCore@13.0.0", + "Microsoft.Extensions.Hosting@10.0.15", + "Microsoft.AspNetCore.TestHost@10.0.15", + "xunit.v3@4.0.3" + ], + "framework": "net10.0", + "frameworkReferences": [ + "Microsoft.AspNetCore.App" + ], + "mode": "test", + "schemaVersion": 1, + "source": "using System.Threading.Tasks;\nusing Codebelt.Extensions.Xunit.Hosting.AspNetCore;\nusing Microsoft.AspNetCore.Builder;\nusing Microsoft.AspNetCore.Http;\nusing Microsoft.AspNetCore.TestHost;\nusing Microsoft.Extensions.DependencyInjection;\nusing Microsoft.Extensions.Hosting;\nusing Xunit;\n\nnamespace DeferredHealthEndpoint.Tests;\n\npublic sealed class SelfManagedWebMinimalHostFixtureExample\n{\n public async Task StartHealthEndpointWhenReadyAsync()\n {\n using var host = MinimalWebHostTestFactory.Create(\n services => services.AddSingleton(new HealthState(\"healthy\")),\n pipelineSetup: app => app.Run(context =>\n {\n var health = context.RequestServices.GetRequiredService();\n return context.Response.WriteAsync(health.Value);\n }),\n hostFixture: new SelfManagedWebMinimalHostFixture());\n\n await host.Host.StartAsync().ConfigureAwait(false);\n using var client = host.Host.GetTestClient();\n\n return await client.GetStringAsync(\"/\").ConfigureAwait(false);\n }\n}\n\npublic sealed record HealthState(string Value);\n\npublic sealed class RunExample\n{\n [Fact]\n public async Task ExercisesExample()\n {\n Assert.Equal(\"healthy\", await new SelfManagedWebMinimalHostFixtureExample().StartHealthEndpointWhenReadyAsync());\n }\n}" +} +'@ +$OutputEncoding = [Text.UTF8Encoding]::new($false) +[Console]::OutputEncoding = $OutputEncoding +$verifyTests = $true +function Assert-CsrunTestOutput([string] $Output) { + $lines = @($Output -split '\r?\n') + $headers = @($lines | Where-Object { $_ -match '^Test run summary: Passed! - .+\)$' }) + if ($headers.Count -ne 1) { throw 'Expected exactly one completed xUnit test summary.' } + $headerIndex = [Array]::IndexOf($lines, $headers[0]) + $summaryLines = @($lines | Select-Object -Skip ($headerIndex + 1) -First 4) + $counts = @{} + foreach ($line in $summaryLines) { + if ($line -match '^\s*(total|failed|succeeded|skipped):\s*(\d+)\s*$') { $counts[$Matches[1]] = [int]$Matches[2] } + } + if ($counts.Count -ne 4) { throw 'The xUnit test summary counts are incomplete or ambiguous.' } + $failed = $counts.failed + $passed = $counts.succeeded + $skipped = $counts.skipped + $total = $counts.total + if ($total -lt 1 -or $passed -lt 1 -or $failed -ne 0 -or $skipped -ne 0 -or $passed -ne $total) { + throw 'Tests must execute at least once, all pass, and none fail or skip.' + } +} +# Downloads and executes the latest stable csrun release with your permissions. +# Source and release history: https://github.com/codebeltnet/csrun +$engineDirectory = Join-Path ([IO.Path]::GetTempPath()) ('csrun-' + [guid]::NewGuid().ToString('N')) +$null = New-Item -ItemType Directory -Path $engineDirectory +$enginePath = Join-Path $engineDirectory 'csrun.ps1' +$process = $null +try { + $release = Invoke-RestMethod 'https://api.github.com/repos/codebeltnet/csrun/releases/latest' + $assets = @($release.assets | Where-Object name -CEQ 'csrun.ps1') + if ($assets.Count -ne 1 -or $assets[0].digest -notmatch '^sha256:[0-9a-f]{64}$') { + throw "csrun release $($release.tag_name) must publish one csrun.ps1 asset with a SHA-256 digest." + } + $asset = $assets[0] + Invoke-WebRequest $asset.browser_download_url -OutFile $enginePath + $actualHash = (Get-FileHash -LiteralPath $enginePath -Algorithm SHA256).Hash + if ("sha256:$actualHash" -ne $asset.digest) { throw "csrun asset checksum mismatch: $actualHash" } +$startInfo = [Diagnostics.ProcessStartInfo]::new('pwsh') +foreach ($argument in @('-NoProfile','-NonInteractive','-File')) { $startInfo.ArgumentList.Add($argument) } +$startInfo.ArgumentList.Add($enginePath) +$startInfo.ArgumentList.Add('-ManifestJson') +$startInfo.ArgumentList.Add($manifest) +$startInfo.RedirectStandardOutput = $true +$startInfo.RedirectStandardError = $true +$startInfo.UseShellExecute = $false +$process = [Diagnostics.Process]::new() +$process.StartInfo = $startInfo +if (-not $process.Start()) { throw 'Could not start csrun.' } +$stdoutTask = $process.StandardOutput.ReadToEndAsync() +$stderrTask = $process.StandardError.ReadToEndAsync() +$process.WaitForExit() +$output = $stdoutTask.GetAwaiter().GetResult() +$diagnostics = $stderrTask.GetAwaiter().GetResult() +Write-Output $output +if ($diagnostics) { [Console]::Error.Write($diagnostics) } +} catch { + [Console]::Error.WriteLine("csrun diagnostics retained in: $engineDirectory") + throw +} finally { + $resolvedTemp = [IO.Path]::TrimEndingDirectorySeparator([IO.Path]::GetFullPath([IO.Path]::GetTempPath())) + $resolvedEngineDirectory = [IO.Path]::GetFullPath($engineDirectory) + if ([IO.Path]::GetDirectoryName($resolvedEngineDirectory) -ne $resolvedTemp -or + [IO.Path]::GetFileName($resolvedEngineDirectory) -cnotmatch '^csrun-[a-f0-9]{32}$') { throw 'Unsafe cleanup path.' } + if ($process -and $process.ExitCode -eq 0) { Remove-Item -LiteralPath $resolvedEngineDirectory -Recurse -Force } +} +if ($process.ExitCode -ne 0) { throw "csrun execution failed with exit code $($process.ExitCode). $diagnostics" } +if ($verifyTests) { Assert-CsrunTestOutput $output } +} \ No newline at end of file diff --git a/.docfx/run-actions/45fcccef5fc861315b50c55e/docker.ps1 b/.docfx/run-actions/45fcccef5fc861315b50c55e/docker.ps1 new file mode 100644 index 0000000..ddc09ef --- /dev/null +++ b/.docfx/run-actions/45fcccef5fc861315b50c55e/docker.ps1 @@ -0,0 +1,82 @@ +& { +#requires -Version 7.0 +$ErrorActionPreference = 'Stop' +$PSNativeCommandUseErrorActionPreference = $false +$manifest = @' +{ + "dependsOn": [ + "Codebelt.Extensions.Xunit@13.0.0", + "xunit.v3@4.0.3" + ], + "framework": "net10.0", + "mode": "test", + "schemaVersion": 1, + "source": "using Codebelt.Extensions.Xunit;\nusing Xunit;\n\nnamespace Example.Tests;\n\npublic class OutputLinesTest : Test\n{\n public OutputLinesTest(ITestOutputHelper output) : base(output) { }\n\n [Fact]\n public void ShouldWriteValuesOnSeparateLines()\n {\n TestOutput.WriteLines(\"started\", 2, \"finished\");\n Assert.True(HasTestOutput);\n }\n}" +} +'@ +$OutputEncoding = [Text.UTF8Encoding]::new($false) +[Console]::OutputEncoding = $OutputEncoding +$verifyTests = $true +function Assert-CsrunTestOutput([string] $Output) { + $lines = @($Output -split '\r?\n') + $headers = @($lines | Where-Object { $_ -match '^Test run summary: Passed! - .+\)$' }) + if ($headers.Count -ne 1) { throw 'Expected exactly one completed xUnit test summary.' } + $headerIndex = [Array]::IndexOf($lines, $headers[0]) + $summaryLines = @($lines | Select-Object -Skip ($headerIndex + 1) -First 4) + $counts = @{} + foreach ($line in $summaryLines) { + if ($line -match '^\s*(total|failed|succeeded|skipped):\s*(\d+)\s*$') { $counts[$Matches[1]] = [int]$Matches[2] } + } + if ($counts.Count -ne 4) { throw 'The xUnit test summary counts are incomplete or ambiguous.' } + $failed = $counts.failed + $passed = $counts.succeeded + $skipped = $counts.skipped + $total = $counts.total + if ($total -lt 1 -or $passed -lt 1 -or $failed -ne 0 -or $skipped -ne 0 -or $passed -ne $total) { + throw 'Tests must execute at least once, all pass, and none fail or skip.' + } +} +# Downloads and executes the latest stable csrun release with your permissions. +# Source and release history: https://github.com/codebeltnet/csrun +$engineDirectory = Join-Path ([IO.Path]::GetTempPath()) ('csrun-' + [guid]::NewGuid().ToString('N')) +$null = New-Item -ItemType Directory -Path $engineDirectory +$enginePath = Join-Path $engineDirectory 'csrun.ps1' +$process = $null +try { + $release = Invoke-RestMethod 'https://api.github.com/repos/codebeltnet/csrun/releases/latest' + $assets = @($release.assets | Where-Object name -CEQ 'csrun.ps1') + if ($assets.Count -ne 1 -or $assets[0].digest -notmatch '^sha256:[0-9a-f]{64}$') { + throw "csrun release $($release.tag_name) must publish one csrun.ps1 asset with a SHA-256 digest." + } + $asset = $assets[0] + Invoke-WebRequest $asset.browser_download_url -OutFile $enginePath + $actualHash = (Get-FileHash -LiteralPath $enginePath -Algorithm SHA256).Hash + if ("sha256:$actualHash" -ne $asset.digest) { throw "csrun asset checksum mismatch: $actualHash" } +$enginePayload = [Convert]::ToBase64String([IO.File]::ReadAllBytes($enginePath)) +$containerInput = $enginePayload + "`n" + $manifest +$command = ' +$ErrorActionPreference = "Stop" +$enginePath = Join-Path ([IO.Path]::GetTempPath()) ("csrun-release-" + [guid]::NewGuid().ToString("N") + ".ps1") +$engineBytes = [Convert]::FromBase64String([Console]::In.ReadLine()) +[IO.File]::WriteAllBytes($enginePath, $engineBytes) +$manifest = [Console]::In.ReadToEnd() +& $enginePath -ManifestJson $manifest +exit $LASTEXITCODE +' +$output = (@($containerInput | & docker run --rm -i --entrypoint pwsh 'codebeltnet/csrun:10' -NoProfile -NonInteractive -Command $command) -join [Environment]::NewLine) +$process = [pscustomobject]@{ ExitCode = $LASTEXITCODE } +$diagnostics = '' +Write-Output $output +} catch { + [Console]::Error.WriteLine("csrun diagnostics retained in: $engineDirectory") + throw +} finally { + $resolvedTemp = [IO.Path]::TrimEndingDirectorySeparator([IO.Path]::GetFullPath([IO.Path]::GetTempPath())) + $resolvedEngineDirectory = [IO.Path]::GetFullPath($engineDirectory) + if ([IO.Path]::GetDirectoryName($resolvedEngineDirectory) -ne $resolvedTemp -or + [IO.Path]::GetFileName($resolvedEngineDirectory) -cnotmatch '^csrun-[a-f0-9]{32}$') { throw 'Unsafe cleanup path.' } + if ($process -and $process.ExitCode -eq 0) { Remove-Item -LiteralPath $resolvedEngineDirectory -Recurse -Force } +} +if ($process.ExitCode -ne 0) { throw "csrun execution failed with exit code $($process.ExitCode). $diagnostics" } +if ($verifyTests) { Assert-CsrunTestOutput $output } +} \ No newline at end of file diff --git a/.docfx/run-actions/45fcccef5fc861315b50c55e/native.ps1 b/.docfx/run-actions/45fcccef5fc861315b50c55e/native.ps1 new file mode 100644 index 0000000..06b50f4 --- /dev/null +++ b/.docfx/run-actions/45fcccef5fc861315b50c55e/native.ps1 @@ -0,0 +1,85 @@ +& { +#requires -Version 7.0 +$ErrorActionPreference = 'Stop' +$PSNativeCommandUseErrorActionPreference = $false +$manifest = @' +{ + "dependsOn": [ + "Codebelt.Extensions.Xunit@13.0.0", + "xunit.v3@4.0.3" + ], + "framework": "net10.0", + "mode": "test", + "schemaVersion": 1, + "source": "using Codebelt.Extensions.Xunit;\nusing Xunit;\n\nnamespace Example.Tests;\n\npublic class OutputLinesTest : Test\n{\n public OutputLinesTest(ITestOutputHelper output) : base(output) { }\n\n [Fact]\n public void ShouldWriteValuesOnSeparateLines()\n {\n TestOutput.WriteLines(\"started\", 2, \"finished\");\n Assert.True(HasTestOutput);\n }\n}" +} +'@ +$OutputEncoding = [Text.UTF8Encoding]::new($false) +[Console]::OutputEncoding = $OutputEncoding +$verifyTests = $true +function Assert-CsrunTestOutput([string] $Output) { + $lines = @($Output -split '\r?\n') + $headers = @($lines | Where-Object { $_ -match '^Test run summary: Passed! - .+\)$' }) + if ($headers.Count -ne 1) { throw 'Expected exactly one completed xUnit test summary.' } + $headerIndex = [Array]::IndexOf($lines, $headers[0]) + $summaryLines = @($lines | Select-Object -Skip ($headerIndex + 1) -First 4) + $counts = @{} + foreach ($line in $summaryLines) { + if ($line -match '^\s*(total|failed|succeeded|skipped):\s*(\d+)\s*$') { $counts[$Matches[1]] = [int]$Matches[2] } + } + if ($counts.Count -ne 4) { throw 'The xUnit test summary counts are incomplete or ambiguous.' } + $failed = $counts.failed + $passed = $counts.succeeded + $skipped = $counts.skipped + $total = $counts.total + if ($total -lt 1 -or $passed -lt 1 -or $failed -ne 0 -or $skipped -ne 0 -or $passed -ne $total) { + throw 'Tests must execute at least once, all pass, and none fail or skip.' + } +} +# Downloads and executes the latest stable csrun release with your permissions. +# Source and release history: https://github.com/codebeltnet/csrun +$engineDirectory = Join-Path ([IO.Path]::GetTempPath()) ('csrun-' + [guid]::NewGuid().ToString('N')) +$null = New-Item -ItemType Directory -Path $engineDirectory +$enginePath = Join-Path $engineDirectory 'csrun.ps1' +$process = $null +try { + $release = Invoke-RestMethod 'https://api.github.com/repos/codebeltnet/csrun/releases/latest' + $assets = @($release.assets | Where-Object name -CEQ 'csrun.ps1') + if ($assets.Count -ne 1 -or $assets[0].digest -notmatch '^sha256:[0-9a-f]{64}$') { + throw "csrun release $($release.tag_name) must publish one csrun.ps1 asset with a SHA-256 digest." + } + $asset = $assets[0] + Invoke-WebRequest $asset.browser_download_url -OutFile $enginePath + $actualHash = (Get-FileHash -LiteralPath $enginePath -Algorithm SHA256).Hash + if ("sha256:$actualHash" -ne $asset.digest) { throw "csrun asset checksum mismatch: $actualHash" } +$startInfo = [Diagnostics.ProcessStartInfo]::new('pwsh') +foreach ($argument in @('-NoProfile','-NonInteractive','-File')) { $startInfo.ArgumentList.Add($argument) } +$startInfo.ArgumentList.Add($enginePath) +$startInfo.ArgumentList.Add('-ManifestJson') +$startInfo.ArgumentList.Add($manifest) +$startInfo.RedirectStandardOutput = $true +$startInfo.RedirectStandardError = $true +$startInfo.UseShellExecute = $false +$process = [Diagnostics.Process]::new() +$process.StartInfo = $startInfo +if (-not $process.Start()) { throw 'Could not start csrun.' } +$stdoutTask = $process.StandardOutput.ReadToEndAsync() +$stderrTask = $process.StandardError.ReadToEndAsync() +$process.WaitForExit() +$output = $stdoutTask.GetAwaiter().GetResult() +$diagnostics = $stderrTask.GetAwaiter().GetResult() +Write-Output $output +if ($diagnostics) { [Console]::Error.Write($diagnostics) } +} catch { + [Console]::Error.WriteLine("csrun diagnostics retained in: $engineDirectory") + throw +} finally { + $resolvedTemp = [IO.Path]::TrimEndingDirectorySeparator([IO.Path]::GetFullPath([IO.Path]::GetTempPath())) + $resolvedEngineDirectory = [IO.Path]::GetFullPath($engineDirectory) + if ([IO.Path]::GetDirectoryName($resolvedEngineDirectory) -ne $resolvedTemp -or + [IO.Path]::GetFileName($resolvedEngineDirectory) -cnotmatch '^csrun-[a-f0-9]{32}$') { throw 'Unsafe cleanup path.' } + if ($process -and $process.ExitCode -eq 0) { Remove-Item -LiteralPath $resolvedEngineDirectory -Recurse -Force } +} +if ($process.ExitCode -ne 0) { throw "csrun execution failed with exit code $($process.ExitCode). $diagnostics" } +if ($verifyTests) { Assert-CsrunTestOutput $output } +} \ No newline at end of file diff --git a/.docfx/run-actions/4c5e94adccd20cab4da52078/docker.ps1 b/.docfx/run-actions/4c5e94adccd20cab4da52078/docker.ps1 new file mode 100644 index 0000000..7a80062 --- /dev/null +++ b/.docfx/run-actions/4c5e94adccd20cab4da52078/docker.ps1 @@ -0,0 +1,58 @@ +& { +#requires -Version 7.0 + $ErrorActionPreference = 'Stop' + $PSNativeCommandUseErrorActionPreference = $false + # Executes trusted repository build tasks and NuGet packages with your permissions. + # Review the pinned source before running; a container is not a security sandbox. + $null = Get-Command docker -ErrorAction Stop + docker info *> $null + if ($LASTEXITCODE -ne 0) { throw 'Docker daemon unavailable.' } + $work = Join-Path ([IO.Path]::GetTempPath()) ('dx-' + [guid]::NewGuid().ToString('N').Substring(0, 8)) + $null = New-Item -ItemType Directory -Path $work + try { + $commit = '84b13767cb9484f8f3a36a71875662edfdb3e511' + Invoke-WebRequest "https://codeload.github.com/codebeltnet/xunit/zip/$commit" -OutFile "$work/source.zip" + Expand-Archive -LiteralPath "$work/source.zip" -DestinationPath "$work/extracted" + Move-Item -LiteralPath "$work/extracted/xunit-$commit" -Destination "$work/repo" + $project = 'test/Codebelt.Extensions.Xunit.Hosting.AspNetCore.FunctionalTests/Codebelt.Extensions.Xunit.Hosting.AspNetCore.FunctionalTests.csproj' + $test = 'Codebelt.Extensions.Xunit.Hosting.AspNetCore.WebApplicationTestTest.ShouldBootstrapApplication_WhenEntryPointUsesModernProgramPattern' + $dockerUser = @() + if ($IsLinux) { + # Keep bind-mounted build output removable by the host user. + $hostUid = id -u + if ($LASTEXITCODE -ne 0) { throw 'Cannot resolve host UID.' } + $hostGid = id -g + if ($LASTEXITCODE -ne 0) { throw 'Cannot resolve host GID.' } + $dockerUser = @('--user', "${hostUid}:${hostGid}") + } + # Let Docker's init reap orphaned build processes and keep build servers disposable. + docker run --rm --init @dockerUser --env HOME=/tmp --env DOTNET_CLI_HOME=/tmp --env MSBUILDDISABLENODEREUSE=1 --mount "type=bind,source=$work,target=/work" --workdir /work/repo mcr.microsoft.com/dotnet/sdk:11.0 dotnet run --disable-build-servers --project $project --framework net11.0 -p:SkipSignAssembly=true -- --filter-method $test --report-xunit-xml --report-xunit-xml-filename result.xml --results-directory /work/results 2>&1 | Tee-Object -FilePath "$work/run.log" + $code = $LASTEXITCODE + if ($code -ne 0) { throw "Repository test failed with exit code $code. See $work/run.log" } + # Require exactly the original test, executed and passing, with no runner errors. + [xml] $report = Get-Content -LiteralPath "$work/results/result.xml" -Raw + $tests = @($report.SelectNodes('/assemblies/assembly/collection/test')) + $assemblies = @($report.SelectNodes('/assemblies/assembly')) + if ($assemblies.Count -ne 1 -or $assemblies[0].total -ne '1' -or $assemblies[0].passed -ne '1' -or + $assemblies[0].errors -ne '0' -or $tests.Count -ne 1 -or $tests[0].name -cne $test -or $tests[0].result -cne 'Pass') { + throw "Expected exactly one passing $test; inspect $work/results/result.xml" + } + Write-Host "Verified: $test (1 executed, 1 passed)." + } + catch { + # Preserve diagnostics outside the repository even though downloaded source is cleaned. + $diagnostics = "$work-diagnostics" + $null = New-Item -ItemType Directory -Path $diagnostics -Force + foreach ($name in @('run.log', 'results')) { + if (Test-Path -LiteralPath "$work/$name") { Copy-Item -LiteralPath "$work/$name" -Destination $diagnostics -Recurse } + } + Write-Warning "Execution not verified. Diagnostics: $diagnostics" + throw + } + finally { + $resolved = [IO.Path]::GetFullPath($work) + $temp = [IO.Path]::GetFullPath([IO.Path]::GetTempPath()).TrimEnd('/','\') + [IO.Path]::DirectorySeparatorChar + if (-not $resolved.StartsWith($temp, [StringComparison]::OrdinalIgnoreCase)) { throw 'Unsafe cleanup path.' } + Remove-Item -LiteralPath $resolved -Recurse -Force + } +} \ No newline at end of file diff --git a/.docfx/run-actions/4c5e94adccd20cab4da52078/native.ps1 b/.docfx/run-actions/4c5e94adccd20cab4da52078/native.ps1 new file mode 100644 index 0000000..44884f2 --- /dev/null +++ b/.docfx/run-actions/4c5e94adccd20cab4da52078/native.ps1 @@ -0,0 +1,50 @@ +& { +#requires -Version 7.0 + $ErrorActionPreference = 'Stop' + $PSNativeCommandUseErrorActionPreference = $false + # Executes trusted repository build tasks and NuGet packages with your permissions. + # Review the pinned source before running; a container is not a security sandbox. + $null = Get-Command dotnet -ErrorAction Stop + $work = Join-Path ([IO.Path]::GetTempPath()) ('dx-' + [guid]::NewGuid().ToString('N').Substring(0, 8)) + $null = New-Item -ItemType Directory -Path $work + try { + $commit = '84b13767cb9484f8f3a36a71875662edfdb3e511' + Invoke-WebRequest "https://codeload.github.com/codebeltnet/xunit/zip/$commit" -OutFile "$work/source.zip" + Expand-Archive -LiteralPath "$work/source.zip" -DestinationPath "$work/extracted" + Move-Item -LiteralPath "$work/extracted/xunit-$commit" -Destination "$work/repo" + $project = 'test/Codebelt.Extensions.Xunit.Hosting.AspNetCore.FunctionalTests/Codebelt.Extensions.Xunit.Hosting.AspNetCore.FunctionalTests.csproj' + $test = 'Codebelt.Extensions.Xunit.Hosting.AspNetCore.WebApplicationTestTest.ShouldBootstrapApplication_WhenEntryPointUsesModernProgramPattern' + Push-Location "$work/repo" + try { + dotnet run --project $project --framework net11.0 -p:SkipSignAssembly=true -- --filter-method $test --report-xunit-xml --report-xunit-xml-filename result.xml --results-directory "$work/results" 2>&1 | Tee-Object -FilePath "$work/run.log" + } + finally { Pop-Location } + $code = $LASTEXITCODE + if ($code -ne 0) { throw "Repository test failed with exit code $code. See $work/run.log" } + # Require exactly the original test, executed and passing, with no runner errors. + [xml] $report = Get-Content -LiteralPath "$work/results/result.xml" -Raw + $tests = @($report.SelectNodes('/assemblies/assembly/collection/test')) + $assemblies = @($report.SelectNodes('/assemblies/assembly')) + if ($assemblies.Count -ne 1 -or $assemblies[0].total -ne '1' -or $assemblies[0].passed -ne '1' -or + $assemblies[0].errors -ne '0' -or $tests.Count -ne 1 -or $tests[0].name -cne $test -or $tests[0].result -cne 'Pass') { + throw "Expected exactly one passing $test; inspect $work/results/result.xml" + } + Write-Host "Verified: $test (1 executed, 1 passed)." + } + catch { + # Preserve diagnostics outside the repository even though downloaded source is cleaned. + $diagnostics = "$work-diagnostics" + $null = New-Item -ItemType Directory -Path $diagnostics -Force + foreach ($name in @('run.log', 'results')) { + if (Test-Path -LiteralPath "$work/$name") { Copy-Item -LiteralPath "$work/$name" -Destination $diagnostics -Recurse } + } + Write-Warning "Execution not verified. Diagnostics: $diagnostics" + throw + } + finally { + $resolved = [IO.Path]::GetFullPath($work) + $temp = [IO.Path]::GetFullPath([IO.Path]::GetTempPath()).TrimEnd('/','\') + [IO.Path]::DirectorySeparatorChar + if (-not $resolved.StartsWith($temp, [StringComparison]::OrdinalIgnoreCase)) { throw 'Unsafe cleanup path.' } + Remove-Item -LiteralPath $resolved -Recurse -Force + } +} \ No newline at end of file diff --git a/.docfx/run-actions/513a785b0e0abbe2284270b9/docker.ps1 b/.docfx/run-actions/513a785b0e0abbe2284270b9/docker.ps1 new file mode 100644 index 0000000..985b55c --- /dev/null +++ b/.docfx/run-actions/513a785b0e0abbe2284270b9/docker.ps1 @@ -0,0 +1,83 @@ +& { +#requires -Version 7.0 +$ErrorActionPreference = 'Stop' +$PSNativeCommandUseErrorActionPreference = $false +$manifest = @' +{ + "dependsOn": [ + "Codebelt.Extensions.Xunit.Hosting@13.0.0", + "Microsoft.Extensions.Hosting@10.0.15", + "xunit.v3@4.0.3" + ], + "framework": "net10.0", + "mode": "test", + "schemaVersion": 1, + "source": "using Codebelt.Extensions.Xunit;\nusing Codebelt.Extensions.Xunit.Hosting;\nusing Microsoft.Extensions.DependencyInjection;\nusing Microsoft.Extensions.Logging;\nusing Xunit;\n\nnamespace HostFixtureTests;\n\npublic class LogInspector\n{\n public ITestStore GetEntries(ILogger logger)\n {\n return logger.GetTestStore();\n }\n\n public ITestStore GetEntries(ILogger logger)\n {\n return logger.GetTestStore();\n }\n}\n\npublic sealed class RunExample\n{\n [Fact]\n public void ExercisesExample()\n {\n var services = new ServiceCollection();\n services.AddXunitTestLogging();\n using var provider = services.BuildServiceProvider();\n var logger = provider.GetRequiredService>();\n logger.LogWarning(\"queue ready\");\n var inspector = new LogInspector();\n Assert.Contains(inspector.GetEntries((ILogger)logger).Query(), entry => entry.Severity == LogLevel.Warning && entry.Message == \"Warning: queue ready\");\n Assert.Contains(inspector.GetEntries(logger).Query(), entry => entry.Severity == LogLevel.Warning && entry.Message == \"Warning: queue ready\");\n }\n}" +} +'@ +$OutputEncoding = [Text.UTF8Encoding]::new($false) +[Console]::OutputEncoding = $OutputEncoding +$verifyTests = $true +function Assert-CsrunTestOutput([string] $Output) { + $lines = @($Output -split '\r?\n') + $headers = @($lines | Where-Object { $_ -match '^Test run summary: Passed! - .+\)$' }) + if ($headers.Count -ne 1) { throw 'Expected exactly one completed xUnit test summary.' } + $headerIndex = [Array]::IndexOf($lines, $headers[0]) + $summaryLines = @($lines | Select-Object -Skip ($headerIndex + 1) -First 4) + $counts = @{} + foreach ($line in $summaryLines) { + if ($line -match '^\s*(total|failed|succeeded|skipped):\s*(\d+)\s*$') { $counts[$Matches[1]] = [int]$Matches[2] } + } + if ($counts.Count -ne 4) { throw 'The xUnit test summary counts are incomplete or ambiguous.' } + $failed = $counts.failed + $passed = $counts.succeeded + $skipped = $counts.skipped + $total = $counts.total + if ($total -lt 1 -or $passed -lt 1 -or $failed -ne 0 -or $skipped -ne 0 -or $passed -ne $total) { + throw 'Tests must execute at least once, all pass, and none fail or skip.' + } +} +# Downloads and executes the latest stable csrun release with your permissions. +# Source and release history: https://github.com/codebeltnet/csrun +$engineDirectory = Join-Path ([IO.Path]::GetTempPath()) ('csrun-' + [guid]::NewGuid().ToString('N')) +$null = New-Item -ItemType Directory -Path $engineDirectory +$enginePath = Join-Path $engineDirectory 'csrun.ps1' +$process = $null +try { + $release = Invoke-RestMethod 'https://api.github.com/repos/codebeltnet/csrun/releases/latest' + $assets = @($release.assets | Where-Object name -CEQ 'csrun.ps1') + if ($assets.Count -ne 1 -or $assets[0].digest -notmatch '^sha256:[0-9a-f]{64}$') { + throw "csrun release $($release.tag_name) must publish one csrun.ps1 asset with a SHA-256 digest." + } + $asset = $assets[0] + Invoke-WebRequest $asset.browser_download_url -OutFile $enginePath + $actualHash = (Get-FileHash -LiteralPath $enginePath -Algorithm SHA256).Hash + if ("sha256:$actualHash" -ne $asset.digest) { throw "csrun asset checksum mismatch: $actualHash" } +$enginePayload = [Convert]::ToBase64String([IO.File]::ReadAllBytes($enginePath)) +$containerInput = $enginePayload + "`n" + $manifest +$command = ' +$ErrorActionPreference = "Stop" +$enginePath = Join-Path ([IO.Path]::GetTempPath()) ("csrun-release-" + [guid]::NewGuid().ToString("N") + ".ps1") +$engineBytes = [Convert]::FromBase64String([Console]::In.ReadLine()) +[IO.File]::WriteAllBytes($enginePath, $engineBytes) +$manifest = [Console]::In.ReadToEnd() +& $enginePath -ManifestJson $manifest +exit $LASTEXITCODE +' +$output = (@($containerInput | & docker run --rm -i --entrypoint pwsh 'codebeltnet/csrun:10' -NoProfile -NonInteractive -Command $command) -join [Environment]::NewLine) +$process = [pscustomobject]@{ ExitCode = $LASTEXITCODE } +$diagnostics = '' +Write-Output $output +} catch { + [Console]::Error.WriteLine("csrun diagnostics retained in: $engineDirectory") + throw +} finally { + $resolvedTemp = [IO.Path]::TrimEndingDirectorySeparator([IO.Path]::GetFullPath([IO.Path]::GetTempPath())) + $resolvedEngineDirectory = [IO.Path]::GetFullPath($engineDirectory) + if ([IO.Path]::GetDirectoryName($resolvedEngineDirectory) -ne $resolvedTemp -or + [IO.Path]::GetFileName($resolvedEngineDirectory) -cnotmatch '^csrun-[a-f0-9]{32}$') { throw 'Unsafe cleanup path.' } + if ($process -and $process.ExitCode -eq 0) { Remove-Item -LiteralPath $resolvedEngineDirectory -Recurse -Force } +} +if ($process.ExitCode -ne 0) { throw "csrun execution failed with exit code $($process.ExitCode). $diagnostics" } +if ($verifyTests) { Assert-CsrunTestOutput $output } +} \ No newline at end of file diff --git a/.docfx/run-actions/513a785b0e0abbe2284270b9/native.ps1 b/.docfx/run-actions/513a785b0e0abbe2284270b9/native.ps1 new file mode 100644 index 0000000..a3942c6 --- /dev/null +++ b/.docfx/run-actions/513a785b0e0abbe2284270b9/native.ps1 @@ -0,0 +1,86 @@ +& { +#requires -Version 7.0 +$ErrorActionPreference = 'Stop' +$PSNativeCommandUseErrorActionPreference = $false +$manifest = @' +{ + "dependsOn": [ + "Codebelt.Extensions.Xunit.Hosting@13.0.0", + "Microsoft.Extensions.Hosting@10.0.15", + "xunit.v3@4.0.3" + ], + "framework": "net10.0", + "mode": "test", + "schemaVersion": 1, + "source": "using Codebelt.Extensions.Xunit;\nusing Codebelt.Extensions.Xunit.Hosting;\nusing Microsoft.Extensions.DependencyInjection;\nusing Microsoft.Extensions.Logging;\nusing Xunit;\n\nnamespace HostFixtureTests;\n\npublic class LogInspector\n{\n public ITestStore GetEntries(ILogger logger)\n {\n return logger.GetTestStore();\n }\n\n public ITestStore GetEntries(ILogger logger)\n {\n return logger.GetTestStore();\n }\n}\n\npublic sealed class RunExample\n{\n [Fact]\n public void ExercisesExample()\n {\n var services = new ServiceCollection();\n services.AddXunitTestLogging();\n using var provider = services.BuildServiceProvider();\n var logger = provider.GetRequiredService>();\n logger.LogWarning(\"queue ready\");\n var inspector = new LogInspector();\n Assert.Contains(inspector.GetEntries((ILogger)logger).Query(), entry => entry.Severity == LogLevel.Warning && entry.Message == \"Warning: queue ready\");\n Assert.Contains(inspector.GetEntries(logger).Query(), entry => entry.Severity == LogLevel.Warning && entry.Message == \"Warning: queue ready\");\n }\n}" +} +'@ +$OutputEncoding = [Text.UTF8Encoding]::new($false) +[Console]::OutputEncoding = $OutputEncoding +$verifyTests = $true +function Assert-CsrunTestOutput([string] $Output) { + $lines = @($Output -split '\r?\n') + $headers = @($lines | Where-Object { $_ -match '^Test run summary: Passed! - .+\)$' }) + if ($headers.Count -ne 1) { throw 'Expected exactly one completed xUnit test summary.' } + $headerIndex = [Array]::IndexOf($lines, $headers[0]) + $summaryLines = @($lines | Select-Object -Skip ($headerIndex + 1) -First 4) + $counts = @{} + foreach ($line in $summaryLines) { + if ($line -match '^\s*(total|failed|succeeded|skipped):\s*(\d+)\s*$') { $counts[$Matches[1]] = [int]$Matches[2] } + } + if ($counts.Count -ne 4) { throw 'The xUnit test summary counts are incomplete or ambiguous.' } + $failed = $counts.failed + $passed = $counts.succeeded + $skipped = $counts.skipped + $total = $counts.total + if ($total -lt 1 -or $passed -lt 1 -or $failed -ne 0 -or $skipped -ne 0 -or $passed -ne $total) { + throw 'Tests must execute at least once, all pass, and none fail or skip.' + } +} +# Downloads and executes the latest stable csrun release with your permissions. +# Source and release history: https://github.com/codebeltnet/csrun +$engineDirectory = Join-Path ([IO.Path]::GetTempPath()) ('csrun-' + [guid]::NewGuid().ToString('N')) +$null = New-Item -ItemType Directory -Path $engineDirectory +$enginePath = Join-Path $engineDirectory 'csrun.ps1' +$process = $null +try { + $release = Invoke-RestMethod 'https://api.github.com/repos/codebeltnet/csrun/releases/latest' + $assets = @($release.assets | Where-Object name -CEQ 'csrun.ps1') + if ($assets.Count -ne 1 -or $assets[0].digest -notmatch '^sha256:[0-9a-f]{64}$') { + throw "csrun release $($release.tag_name) must publish one csrun.ps1 asset with a SHA-256 digest." + } + $asset = $assets[0] + Invoke-WebRequest $asset.browser_download_url -OutFile $enginePath + $actualHash = (Get-FileHash -LiteralPath $enginePath -Algorithm SHA256).Hash + if ("sha256:$actualHash" -ne $asset.digest) { throw "csrun asset checksum mismatch: $actualHash" } +$startInfo = [Diagnostics.ProcessStartInfo]::new('pwsh') +foreach ($argument in @('-NoProfile','-NonInteractive','-File')) { $startInfo.ArgumentList.Add($argument) } +$startInfo.ArgumentList.Add($enginePath) +$startInfo.ArgumentList.Add('-ManifestJson') +$startInfo.ArgumentList.Add($manifest) +$startInfo.RedirectStandardOutput = $true +$startInfo.RedirectStandardError = $true +$startInfo.UseShellExecute = $false +$process = [Diagnostics.Process]::new() +$process.StartInfo = $startInfo +if (-not $process.Start()) { throw 'Could not start csrun.' } +$stdoutTask = $process.StandardOutput.ReadToEndAsync() +$stderrTask = $process.StandardError.ReadToEndAsync() +$process.WaitForExit() +$output = $stdoutTask.GetAwaiter().GetResult() +$diagnostics = $stderrTask.GetAwaiter().GetResult() +Write-Output $output +if ($diagnostics) { [Console]::Error.Write($diagnostics) } +} catch { + [Console]::Error.WriteLine("csrun diagnostics retained in: $engineDirectory") + throw +} finally { + $resolvedTemp = [IO.Path]::TrimEndingDirectorySeparator([IO.Path]::GetFullPath([IO.Path]::GetTempPath())) + $resolvedEngineDirectory = [IO.Path]::GetFullPath($engineDirectory) + if ([IO.Path]::GetDirectoryName($resolvedEngineDirectory) -ne $resolvedTemp -or + [IO.Path]::GetFileName($resolvedEngineDirectory) -cnotmatch '^csrun-[a-f0-9]{32}$') { throw 'Unsafe cleanup path.' } + if ($process -and $process.ExitCode -eq 0) { Remove-Item -LiteralPath $resolvedEngineDirectory -Recurse -Force } +} +if ($process.ExitCode -ne 0) { throw "csrun execution failed with exit code $($process.ExitCode). $diagnostics" } +if ($verifyTests) { Assert-CsrunTestOutput $output } +} \ No newline at end of file diff --git a/.docfx/run-actions/515575be5bb7683cac9903a5/docker.ps1 b/.docfx/run-actions/515575be5bb7683cac9903a5/docker.ps1 new file mode 100644 index 0000000..287cef2 --- /dev/null +++ b/.docfx/run-actions/515575be5bb7683cac9903a5/docker.ps1 @@ -0,0 +1,83 @@ +& { +#requires -Version 7.0 +$ErrorActionPreference = 'Stop' +$PSNativeCommandUseErrorActionPreference = $false +$manifest = @' +{ + "dependsOn": [ + "Codebelt.Extensions.Xunit.Hosting@13.0.0", + "Microsoft.Extensions.Hosting@10.0.15", + "xunit.v3@4.0.3" + ], + "framework": "net10.0", + "mode": "test", + "schemaVersion": 1, + "source": "using System.Threading.Tasks;\nusing Codebelt.Extensions.Xunit.Hosting;\nusing Microsoft.Extensions.DependencyInjection;\nusing Microsoft.Extensions.Hosting;\nusing Xunit;\n\nnamespace WorkerLifecycle.Tests;\n\npublic sealed class SelfManagedHostFixtureExample\n{\n public async Task StartAfterAttachingObserverAsync()\n {\n using var host = HostTestFactory.Create(\n hostFixture: new SelfManagedHostFixture());\n\n var started = false;\n var lifetime = host.Host.Services.GetRequiredService();\n using var registration = lifetime.ApplicationStarted.Register(() => started = true);\n\n Assert.False(started);\n await host.Host.StartAsync().ConfigureAwait(false);\n Assert.True(started);\n }\n}\n\npublic sealed class RunExample\n{\n [Fact]\n public async Task ExercisesExample()\n {\n await new SelfManagedHostFixtureExample().StartAfterAttachingObserverAsync();\n }\n}" +} +'@ +$OutputEncoding = [Text.UTF8Encoding]::new($false) +[Console]::OutputEncoding = $OutputEncoding +$verifyTests = $true +function Assert-CsrunTestOutput([string] $Output) { + $lines = @($Output -split '\r?\n') + $headers = @($lines | Where-Object { $_ -match '^Test run summary: Passed! - .+\)$' }) + if ($headers.Count -ne 1) { throw 'Expected exactly one completed xUnit test summary.' } + $headerIndex = [Array]::IndexOf($lines, $headers[0]) + $summaryLines = @($lines | Select-Object -Skip ($headerIndex + 1) -First 4) + $counts = @{} + foreach ($line in $summaryLines) { + if ($line -match '^\s*(total|failed|succeeded|skipped):\s*(\d+)\s*$') { $counts[$Matches[1]] = [int]$Matches[2] } + } + if ($counts.Count -ne 4) { throw 'The xUnit test summary counts are incomplete or ambiguous.' } + $failed = $counts.failed + $passed = $counts.succeeded + $skipped = $counts.skipped + $total = $counts.total + if ($total -lt 1 -or $passed -lt 1 -or $failed -ne 0 -or $skipped -ne 0 -or $passed -ne $total) { + throw 'Tests must execute at least once, all pass, and none fail or skip.' + } +} +# Downloads and executes the latest stable csrun release with your permissions. +# Source and release history: https://github.com/codebeltnet/csrun +$engineDirectory = Join-Path ([IO.Path]::GetTempPath()) ('csrun-' + [guid]::NewGuid().ToString('N')) +$null = New-Item -ItemType Directory -Path $engineDirectory +$enginePath = Join-Path $engineDirectory 'csrun.ps1' +$process = $null +try { + $release = Invoke-RestMethod 'https://api.github.com/repos/codebeltnet/csrun/releases/latest' + $assets = @($release.assets | Where-Object name -CEQ 'csrun.ps1') + if ($assets.Count -ne 1 -or $assets[0].digest -notmatch '^sha256:[0-9a-f]{64}$') { + throw "csrun release $($release.tag_name) must publish one csrun.ps1 asset with a SHA-256 digest." + } + $asset = $assets[0] + Invoke-WebRequest $asset.browser_download_url -OutFile $enginePath + $actualHash = (Get-FileHash -LiteralPath $enginePath -Algorithm SHA256).Hash + if ("sha256:$actualHash" -ne $asset.digest) { throw "csrun asset checksum mismatch: $actualHash" } +$enginePayload = [Convert]::ToBase64String([IO.File]::ReadAllBytes($enginePath)) +$containerInput = $enginePayload + "`n" + $manifest +$command = ' +$ErrorActionPreference = "Stop" +$enginePath = Join-Path ([IO.Path]::GetTempPath()) ("csrun-release-" + [guid]::NewGuid().ToString("N") + ".ps1") +$engineBytes = [Convert]::FromBase64String([Console]::In.ReadLine()) +[IO.File]::WriteAllBytes($enginePath, $engineBytes) +$manifest = [Console]::In.ReadToEnd() +& $enginePath -ManifestJson $manifest +exit $LASTEXITCODE +' +$output = (@($containerInput | & docker run --rm -i --entrypoint pwsh 'codebeltnet/csrun:10' -NoProfile -NonInteractive -Command $command) -join [Environment]::NewLine) +$process = [pscustomobject]@{ ExitCode = $LASTEXITCODE } +$diagnostics = '' +Write-Output $output +} catch { + [Console]::Error.WriteLine("csrun diagnostics retained in: $engineDirectory") + throw +} finally { + $resolvedTemp = [IO.Path]::TrimEndingDirectorySeparator([IO.Path]::GetFullPath([IO.Path]::GetTempPath())) + $resolvedEngineDirectory = [IO.Path]::GetFullPath($engineDirectory) + if ([IO.Path]::GetDirectoryName($resolvedEngineDirectory) -ne $resolvedTemp -or + [IO.Path]::GetFileName($resolvedEngineDirectory) -cnotmatch '^csrun-[a-f0-9]{32}$') { throw 'Unsafe cleanup path.' } + if ($process -and $process.ExitCode -eq 0) { Remove-Item -LiteralPath $resolvedEngineDirectory -Recurse -Force } +} +if ($process.ExitCode -ne 0) { throw "csrun execution failed with exit code $($process.ExitCode). $diagnostics" } +if ($verifyTests) { Assert-CsrunTestOutput $output } +} \ No newline at end of file diff --git a/.docfx/run-actions/515575be5bb7683cac9903a5/native.ps1 b/.docfx/run-actions/515575be5bb7683cac9903a5/native.ps1 new file mode 100644 index 0000000..38c1908 --- /dev/null +++ b/.docfx/run-actions/515575be5bb7683cac9903a5/native.ps1 @@ -0,0 +1,86 @@ +& { +#requires -Version 7.0 +$ErrorActionPreference = 'Stop' +$PSNativeCommandUseErrorActionPreference = $false +$manifest = @' +{ + "dependsOn": [ + "Codebelt.Extensions.Xunit.Hosting@13.0.0", + "Microsoft.Extensions.Hosting@10.0.15", + "xunit.v3@4.0.3" + ], + "framework": "net10.0", + "mode": "test", + "schemaVersion": 1, + "source": "using System.Threading.Tasks;\nusing Codebelt.Extensions.Xunit.Hosting;\nusing Microsoft.Extensions.DependencyInjection;\nusing Microsoft.Extensions.Hosting;\nusing Xunit;\n\nnamespace WorkerLifecycle.Tests;\n\npublic sealed class SelfManagedHostFixtureExample\n{\n public async Task StartAfterAttachingObserverAsync()\n {\n using var host = HostTestFactory.Create(\n hostFixture: new SelfManagedHostFixture());\n\n var started = false;\n var lifetime = host.Host.Services.GetRequiredService();\n using var registration = lifetime.ApplicationStarted.Register(() => started = true);\n\n Assert.False(started);\n await host.Host.StartAsync().ConfigureAwait(false);\n Assert.True(started);\n }\n}\n\npublic sealed class RunExample\n{\n [Fact]\n public async Task ExercisesExample()\n {\n await new SelfManagedHostFixtureExample().StartAfterAttachingObserverAsync();\n }\n}" +} +'@ +$OutputEncoding = [Text.UTF8Encoding]::new($false) +[Console]::OutputEncoding = $OutputEncoding +$verifyTests = $true +function Assert-CsrunTestOutput([string] $Output) { + $lines = @($Output -split '\r?\n') + $headers = @($lines | Where-Object { $_ -match '^Test run summary: Passed! - .+\)$' }) + if ($headers.Count -ne 1) { throw 'Expected exactly one completed xUnit test summary.' } + $headerIndex = [Array]::IndexOf($lines, $headers[0]) + $summaryLines = @($lines | Select-Object -Skip ($headerIndex + 1) -First 4) + $counts = @{} + foreach ($line in $summaryLines) { + if ($line -match '^\s*(total|failed|succeeded|skipped):\s*(\d+)\s*$') { $counts[$Matches[1]] = [int]$Matches[2] } + } + if ($counts.Count -ne 4) { throw 'The xUnit test summary counts are incomplete or ambiguous.' } + $failed = $counts.failed + $passed = $counts.succeeded + $skipped = $counts.skipped + $total = $counts.total + if ($total -lt 1 -or $passed -lt 1 -or $failed -ne 0 -or $skipped -ne 0 -or $passed -ne $total) { + throw 'Tests must execute at least once, all pass, and none fail or skip.' + } +} +# Downloads and executes the latest stable csrun release with your permissions. +# Source and release history: https://github.com/codebeltnet/csrun +$engineDirectory = Join-Path ([IO.Path]::GetTempPath()) ('csrun-' + [guid]::NewGuid().ToString('N')) +$null = New-Item -ItemType Directory -Path $engineDirectory +$enginePath = Join-Path $engineDirectory 'csrun.ps1' +$process = $null +try { + $release = Invoke-RestMethod 'https://api.github.com/repos/codebeltnet/csrun/releases/latest' + $assets = @($release.assets | Where-Object name -CEQ 'csrun.ps1') + if ($assets.Count -ne 1 -or $assets[0].digest -notmatch '^sha256:[0-9a-f]{64}$') { + throw "csrun release $($release.tag_name) must publish one csrun.ps1 asset with a SHA-256 digest." + } + $asset = $assets[0] + Invoke-WebRequest $asset.browser_download_url -OutFile $enginePath + $actualHash = (Get-FileHash -LiteralPath $enginePath -Algorithm SHA256).Hash + if ("sha256:$actualHash" -ne $asset.digest) { throw "csrun asset checksum mismatch: $actualHash" } +$startInfo = [Diagnostics.ProcessStartInfo]::new('pwsh') +foreach ($argument in @('-NoProfile','-NonInteractive','-File')) { $startInfo.ArgumentList.Add($argument) } +$startInfo.ArgumentList.Add($enginePath) +$startInfo.ArgumentList.Add('-ManifestJson') +$startInfo.ArgumentList.Add($manifest) +$startInfo.RedirectStandardOutput = $true +$startInfo.RedirectStandardError = $true +$startInfo.UseShellExecute = $false +$process = [Diagnostics.Process]::new() +$process.StartInfo = $startInfo +if (-not $process.Start()) { throw 'Could not start csrun.' } +$stdoutTask = $process.StandardOutput.ReadToEndAsync() +$stderrTask = $process.StandardError.ReadToEndAsync() +$process.WaitForExit() +$output = $stdoutTask.GetAwaiter().GetResult() +$diagnostics = $stderrTask.GetAwaiter().GetResult() +Write-Output $output +if ($diagnostics) { [Console]::Error.Write($diagnostics) } +} catch { + [Console]::Error.WriteLine("csrun diagnostics retained in: $engineDirectory") + throw +} finally { + $resolvedTemp = [IO.Path]::TrimEndingDirectorySeparator([IO.Path]::GetFullPath([IO.Path]::GetTempPath())) + $resolvedEngineDirectory = [IO.Path]::GetFullPath($engineDirectory) + if ([IO.Path]::GetDirectoryName($resolvedEngineDirectory) -ne $resolvedTemp -or + [IO.Path]::GetFileName($resolvedEngineDirectory) -cnotmatch '^csrun-[a-f0-9]{32}$') { throw 'Unsafe cleanup path.' } + if ($process -and $process.ExitCode -eq 0) { Remove-Item -LiteralPath $resolvedEngineDirectory -Recurse -Force } +} +if ($process.ExitCode -ne 0) { throw "csrun execution failed with exit code $($process.ExitCode). $diagnostics" } +if ($verifyTests) { Assert-CsrunTestOutput $output } +} \ No newline at end of file diff --git a/.docfx/run-actions/545543e49c6bf054a9e06186/docker.ps1 b/.docfx/run-actions/545543e49c6bf054a9e06186/docker.ps1 new file mode 100644 index 0000000..84dc9ac --- /dev/null +++ b/.docfx/run-actions/545543e49c6bf054a9e06186/docker.ps1 @@ -0,0 +1,82 @@ +& { +#requires -Version 7.0 +$ErrorActionPreference = 'Stop' +$PSNativeCommandUseErrorActionPreference = $false +$manifest = @' +{ + "dependsOn": [ + "Codebelt.Extensions.Xunit@13.0.0", + "xunit.v3@4.0.3" + ], + "framework": "net10.0", + "mode": "test", + "schemaVersion": 1, + "source": "using Codebelt.Extensions.Xunit;\nusing Xunit;\n\nnamespace Example.Tests;\n\npublic class OutputAccessorTest : Test\n{\n public OutputAccessorTest(ITestOutputHelper output) : base(output) { }\n\n [Fact]\n public void ShouldExposeCurrentOutput()\n {\n var accessor = new TestOutputHelperAccessor(TestOutput);\n Assert.Same(TestOutput, accessor.TestOutput);\n }\n}" +} +'@ +$OutputEncoding = [Text.UTF8Encoding]::new($false) +[Console]::OutputEncoding = $OutputEncoding +$verifyTests = $true +function Assert-CsrunTestOutput([string] $Output) { + $lines = @($Output -split '\r?\n') + $headers = @($lines | Where-Object { $_ -match '^Test run summary: Passed! - .+\)$' }) + if ($headers.Count -ne 1) { throw 'Expected exactly one completed xUnit test summary.' } + $headerIndex = [Array]::IndexOf($lines, $headers[0]) + $summaryLines = @($lines | Select-Object -Skip ($headerIndex + 1) -First 4) + $counts = @{} + foreach ($line in $summaryLines) { + if ($line -match '^\s*(total|failed|succeeded|skipped):\s*(\d+)\s*$') { $counts[$Matches[1]] = [int]$Matches[2] } + } + if ($counts.Count -ne 4) { throw 'The xUnit test summary counts are incomplete or ambiguous.' } + $failed = $counts.failed + $passed = $counts.succeeded + $skipped = $counts.skipped + $total = $counts.total + if ($total -lt 1 -or $passed -lt 1 -or $failed -ne 0 -or $skipped -ne 0 -or $passed -ne $total) { + throw 'Tests must execute at least once, all pass, and none fail or skip.' + } +} +# Downloads and executes the latest stable csrun release with your permissions. +# Source and release history: https://github.com/codebeltnet/csrun +$engineDirectory = Join-Path ([IO.Path]::GetTempPath()) ('csrun-' + [guid]::NewGuid().ToString('N')) +$null = New-Item -ItemType Directory -Path $engineDirectory +$enginePath = Join-Path $engineDirectory 'csrun.ps1' +$process = $null +try { + $release = Invoke-RestMethod 'https://api.github.com/repos/codebeltnet/csrun/releases/latest' + $assets = @($release.assets | Where-Object name -CEQ 'csrun.ps1') + if ($assets.Count -ne 1 -or $assets[0].digest -notmatch '^sha256:[0-9a-f]{64}$') { + throw "csrun release $($release.tag_name) must publish one csrun.ps1 asset with a SHA-256 digest." + } + $asset = $assets[0] + Invoke-WebRequest $asset.browser_download_url -OutFile $enginePath + $actualHash = (Get-FileHash -LiteralPath $enginePath -Algorithm SHA256).Hash + if ("sha256:$actualHash" -ne $asset.digest) { throw "csrun asset checksum mismatch: $actualHash" } +$enginePayload = [Convert]::ToBase64String([IO.File]::ReadAllBytes($enginePath)) +$containerInput = $enginePayload + "`n" + $manifest +$command = ' +$ErrorActionPreference = "Stop" +$enginePath = Join-Path ([IO.Path]::GetTempPath()) ("csrun-release-" + [guid]::NewGuid().ToString("N") + ".ps1") +$engineBytes = [Convert]::FromBase64String([Console]::In.ReadLine()) +[IO.File]::WriteAllBytes($enginePath, $engineBytes) +$manifest = [Console]::In.ReadToEnd() +& $enginePath -ManifestJson $manifest +exit $LASTEXITCODE +' +$output = (@($containerInput | & docker run --rm -i --entrypoint pwsh 'codebeltnet/csrun:10' -NoProfile -NonInteractive -Command $command) -join [Environment]::NewLine) +$process = [pscustomobject]@{ ExitCode = $LASTEXITCODE } +$diagnostics = '' +Write-Output $output +} catch { + [Console]::Error.WriteLine("csrun diagnostics retained in: $engineDirectory") + throw +} finally { + $resolvedTemp = [IO.Path]::TrimEndingDirectorySeparator([IO.Path]::GetFullPath([IO.Path]::GetTempPath())) + $resolvedEngineDirectory = [IO.Path]::GetFullPath($engineDirectory) + if ([IO.Path]::GetDirectoryName($resolvedEngineDirectory) -ne $resolvedTemp -or + [IO.Path]::GetFileName($resolvedEngineDirectory) -cnotmatch '^csrun-[a-f0-9]{32}$') { throw 'Unsafe cleanup path.' } + if ($process -and $process.ExitCode -eq 0) { Remove-Item -LiteralPath $resolvedEngineDirectory -Recurse -Force } +} +if ($process.ExitCode -ne 0) { throw "csrun execution failed with exit code $($process.ExitCode). $diagnostics" } +if ($verifyTests) { Assert-CsrunTestOutput $output } +} \ No newline at end of file diff --git a/.docfx/run-actions/545543e49c6bf054a9e06186/native.ps1 b/.docfx/run-actions/545543e49c6bf054a9e06186/native.ps1 new file mode 100644 index 0000000..822d1f2 --- /dev/null +++ b/.docfx/run-actions/545543e49c6bf054a9e06186/native.ps1 @@ -0,0 +1,85 @@ +& { +#requires -Version 7.0 +$ErrorActionPreference = 'Stop' +$PSNativeCommandUseErrorActionPreference = $false +$manifest = @' +{ + "dependsOn": [ + "Codebelt.Extensions.Xunit@13.0.0", + "xunit.v3@4.0.3" + ], + "framework": "net10.0", + "mode": "test", + "schemaVersion": 1, + "source": "using Codebelt.Extensions.Xunit;\nusing Xunit;\n\nnamespace Example.Tests;\n\npublic class OutputAccessorTest : Test\n{\n public OutputAccessorTest(ITestOutputHelper output) : base(output) { }\n\n [Fact]\n public void ShouldExposeCurrentOutput()\n {\n var accessor = new TestOutputHelperAccessor(TestOutput);\n Assert.Same(TestOutput, accessor.TestOutput);\n }\n}" +} +'@ +$OutputEncoding = [Text.UTF8Encoding]::new($false) +[Console]::OutputEncoding = $OutputEncoding +$verifyTests = $true +function Assert-CsrunTestOutput([string] $Output) { + $lines = @($Output -split '\r?\n') + $headers = @($lines | Where-Object { $_ -match '^Test run summary: Passed! - .+\)$' }) + if ($headers.Count -ne 1) { throw 'Expected exactly one completed xUnit test summary.' } + $headerIndex = [Array]::IndexOf($lines, $headers[0]) + $summaryLines = @($lines | Select-Object -Skip ($headerIndex + 1) -First 4) + $counts = @{} + foreach ($line in $summaryLines) { + if ($line -match '^\s*(total|failed|succeeded|skipped):\s*(\d+)\s*$') { $counts[$Matches[1]] = [int]$Matches[2] } + } + if ($counts.Count -ne 4) { throw 'The xUnit test summary counts are incomplete or ambiguous.' } + $failed = $counts.failed + $passed = $counts.succeeded + $skipped = $counts.skipped + $total = $counts.total + if ($total -lt 1 -or $passed -lt 1 -or $failed -ne 0 -or $skipped -ne 0 -or $passed -ne $total) { + throw 'Tests must execute at least once, all pass, and none fail or skip.' + } +} +# Downloads and executes the latest stable csrun release with your permissions. +# Source and release history: https://github.com/codebeltnet/csrun +$engineDirectory = Join-Path ([IO.Path]::GetTempPath()) ('csrun-' + [guid]::NewGuid().ToString('N')) +$null = New-Item -ItemType Directory -Path $engineDirectory +$enginePath = Join-Path $engineDirectory 'csrun.ps1' +$process = $null +try { + $release = Invoke-RestMethod 'https://api.github.com/repos/codebeltnet/csrun/releases/latest' + $assets = @($release.assets | Where-Object name -CEQ 'csrun.ps1') + if ($assets.Count -ne 1 -or $assets[0].digest -notmatch '^sha256:[0-9a-f]{64}$') { + throw "csrun release $($release.tag_name) must publish one csrun.ps1 asset with a SHA-256 digest." + } + $asset = $assets[0] + Invoke-WebRequest $asset.browser_download_url -OutFile $enginePath + $actualHash = (Get-FileHash -LiteralPath $enginePath -Algorithm SHA256).Hash + if ("sha256:$actualHash" -ne $asset.digest) { throw "csrun asset checksum mismatch: $actualHash" } +$startInfo = [Diagnostics.ProcessStartInfo]::new('pwsh') +foreach ($argument in @('-NoProfile','-NonInteractive','-File')) { $startInfo.ArgumentList.Add($argument) } +$startInfo.ArgumentList.Add($enginePath) +$startInfo.ArgumentList.Add('-ManifestJson') +$startInfo.ArgumentList.Add($manifest) +$startInfo.RedirectStandardOutput = $true +$startInfo.RedirectStandardError = $true +$startInfo.UseShellExecute = $false +$process = [Diagnostics.Process]::new() +$process.StartInfo = $startInfo +if (-not $process.Start()) { throw 'Could not start csrun.' } +$stdoutTask = $process.StandardOutput.ReadToEndAsync() +$stderrTask = $process.StandardError.ReadToEndAsync() +$process.WaitForExit() +$output = $stdoutTask.GetAwaiter().GetResult() +$diagnostics = $stderrTask.GetAwaiter().GetResult() +Write-Output $output +if ($diagnostics) { [Console]::Error.Write($diagnostics) } +} catch { + [Console]::Error.WriteLine("csrun diagnostics retained in: $engineDirectory") + throw +} finally { + $resolvedTemp = [IO.Path]::TrimEndingDirectorySeparator([IO.Path]::GetFullPath([IO.Path]::GetTempPath())) + $resolvedEngineDirectory = [IO.Path]::GetFullPath($engineDirectory) + if ([IO.Path]::GetDirectoryName($resolvedEngineDirectory) -ne $resolvedTemp -or + [IO.Path]::GetFileName($resolvedEngineDirectory) -cnotmatch '^csrun-[a-f0-9]{32}$') { throw 'Unsafe cleanup path.' } + if ($process -and $process.ExitCode -eq 0) { Remove-Item -LiteralPath $resolvedEngineDirectory -Recurse -Force } +} +if ($process.ExitCode -ne 0) { throw "csrun execution failed with exit code $($process.ExitCode). $diagnostics" } +if ($verifyTests) { Assert-CsrunTestOutput $output } +} \ No newline at end of file diff --git a/.docfx/run-actions/549c3e82bd0bcb99e9f05bfa/docker.ps1 b/.docfx/run-actions/549c3e82bd0bcb99e9f05bfa/docker.ps1 new file mode 100644 index 0000000..fdec138 --- /dev/null +++ b/.docfx/run-actions/549c3e82bd0bcb99e9f05bfa/docker.ps1 @@ -0,0 +1,86 @@ +& { +#requires -Version 7.0 +$ErrorActionPreference = 'Stop' +$PSNativeCommandUseErrorActionPreference = $false +$manifest = @' +{ + "dependsOn": [ + "Codebelt.Extensions.Xunit.Hosting.AspNetCore@13.0.0", + "Microsoft.Extensions.Hosting@10.0.15", + "xunit.v3@4.0.3" + ], + "framework": "net10.0", + "frameworkReferences": [ + "Microsoft.AspNetCore.App" + ], + "mode": "test", + "schemaVersion": 1, + "source": "using Codebelt.Extensions.Xunit.Hosting.AspNetCore;\nusing Xunit;\n\nnamespace WebFixtureTests;\n\npublic class WebAppStateGuard\n{\n public bool EnsureFixtureIsReady(IWebApplicationFixture fixture) where TEntryPoint : class\n {\n return fixture.HasValidState();\n }\n}\n\npublic sealed class RunExample\n{\n [Fact]\n public void ExercisesExample()\n {\n using var fixture = new ManagedWebApplicationFixture();\n Assert.False(new WebAppStateGuard().EnsureFixtureIsReady(fixture));\n }\n}" +} +'@ +$OutputEncoding = [Text.UTF8Encoding]::new($false) +[Console]::OutputEncoding = $OutputEncoding +$verifyTests = $true +function Assert-CsrunTestOutput([string] $Output) { + $lines = @($Output -split '\r?\n') + $headers = @($lines | Where-Object { $_ -match '^Test run summary: Passed! - .+\)$' }) + if ($headers.Count -ne 1) { throw 'Expected exactly one completed xUnit test summary.' } + $headerIndex = [Array]::IndexOf($lines, $headers[0]) + $summaryLines = @($lines | Select-Object -Skip ($headerIndex + 1) -First 4) + $counts = @{} + foreach ($line in $summaryLines) { + if ($line -match '^\s*(total|failed|succeeded|skipped):\s*(\d+)\s*$') { $counts[$Matches[1]] = [int]$Matches[2] } + } + if ($counts.Count -ne 4) { throw 'The xUnit test summary counts are incomplete or ambiguous.' } + $failed = $counts.failed + $passed = $counts.succeeded + $skipped = $counts.skipped + $total = $counts.total + if ($total -lt 1 -or $passed -lt 1 -or $failed -ne 0 -or $skipped -ne 0 -or $passed -ne $total) { + throw 'Tests must execute at least once, all pass, and none fail or skip.' + } +} +# Downloads and executes the latest stable csrun release with your permissions. +# Source and release history: https://github.com/codebeltnet/csrun +$engineDirectory = Join-Path ([IO.Path]::GetTempPath()) ('csrun-' + [guid]::NewGuid().ToString('N')) +$null = New-Item -ItemType Directory -Path $engineDirectory +$enginePath = Join-Path $engineDirectory 'csrun.ps1' +$process = $null +try { + $release = Invoke-RestMethod 'https://api.github.com/repos/codebeltnet/csrun/releases/latest' + $assets = @($release.assets | Where-Object name -CEQ 'csrun.ps1') + if ($assets.Count -ne 1 -or $assets[0].digest -notmatch '^sha256:[0-9a-f]{64}$') { + throw "csrun release $($release.tag_name) must publish one csrun.ps1 asset with a SHA-256 digest." + } + $asset = $assets[0] + Invoke-WebRequest $asset.browser_download_url -OutFile $enginePath + $actualHash = (Get-FileHash -LiteralPath $enginePath -Algorithm SHA256).Hash + if ("sha256:$actualHash" -ne $asset.digest) { throw "csrun asset checksum mismatch: $actualHash" } +$enginePayload = [Convert]::ToBase64String([IO.File]::ReadAllBytes($enginePath)) +$containerInput = $enginePayload + "`n" + $manifest +$command = ' +$ErrorActionPreference = "Stop" +$enginePath = Join-Path ([IO.Path]::GetTempPath()) ("csrun-release-" + [guid]::NewGuid().ToString("N") + ".ps1") +$engineBytes = [Convert]::FromBase64String([Console]::In.ReadLine()) +[IO.File]::WriteAllBytes($enginePath, $engineBytes) +$manifest = [Console]::In.ReadToEnd() +& $enginePath -ManifestJson $manifest +exit $LASTEXITCODE +' +$output = (@($containerInput | & docker run --rm -i --entrypoint pwsh 'codebeltnet/csrun:10' -NoProfile -NonInteractive -Command $command) -join [Environment]::NewLine) +$process = [pscustomobject]@{ ExitCode = $LASTEXITCODE } +$diagnostics = '' +Write-Output $output +} catch { + [Console]::Error.WriteLine("csrun diagnostics retained in: $engineDirectory") + throw +} finally { + $resolvedTemp = [IO.Path]::TrimEndingDirectorySeparator([IO.Path]::GetFullPath([IO.Path]::GetTempPath())) + $resolvedEngineDirectory = [IO.Path]::GetFullPath($engineDirectory) + if ([IO.Path]::GetDirectoryName($resolvedEngineDirectory) -ne $resolvedTemp -or + [IO.Path]::GetFileName($resolvedEngineDirectory) -cnotmatch '^csrun-[a-f0-9]{32}$') { throw 'Unsafe cleanup path.' } + if ($process -and $process.ExitCode -eq 0) { Remove-Item -LiteralPath $resolvedEngineDirectory -Recurse -Force } +} +if ($process.ExitCode -ne 0) { throw "csrun execution failed with exit code $($process.ExitCode). $diagnostics" } +if ($verifyTests) { Assert-CsrunTestOutput $output } +} \ No newline at end of file diff --git a/.docfx/run-actions/549c3e82bd0bcb99e9f05bfa/native.ps1 b/.docfx/run-actions/549c3e82bd0bcb99e9f05bfa/native.ps1 new file mode 100644 index 0000000..09ff572 --- /dev/null +++ b/.docfx/run-actions/549c3e82bd0bcb99e9f05bfa/native.ps1 @@ -0,0 +1,89 @@ +& { +#requires -Version 7.0 +$ErrorActionPreference = 'Stop' +$PSNativeCommandUseErrorActionPreference = $false +$manifest = @' +{ + "dependsOn": [ + "Codebelt.Extensions.Xunit.Hosting.AspNetCore@13.0.0", + "Microsoft.Extensions.Hosting@10.0.15", + "xunit.v3@4.0.3" + ], + "framework": "net10.0", + "frameworkReferences": [ + "Microsoft.AspNetCore.App" + ], + "mode": "test", + "schemaVersion": 1, + "source": "using Codebelt.Extensions.Xunit.Hosting.AspNetCore;\nusing Xunit;\n\nnamespace WebFixtureTests;\n\npublic class WebAppStateGuard\n{\n public bool EnsureFixtureIsReady(IWebApplicationFixture fixture) where TEntryPoint : class\n {\n return fixture.HasValidState();\n }\n}\n\npublic sealed class RunExample\n{\n [Fact]\n public void ExercisesExample()\n {\n using var fixture = new ManagedWebApplicationFixture();\n Assert.False(new WebAppStateGuard().EnsureFixtureIsReady(fixture));\n }\n}" +} +'@ +$OutputEncoding = [Text.UTF8Encoding]::new($false) +[Console]::OutputEncoding = $OutputEncoding +$verifyTests = $true +function Assert-CsrunTestOutput([string] $Output) { + $lines = @($Output -split '\r?\n') + $headers = @($lines | Where-Object { $_ -match '^Test run summary: Passed! - .+\)$' }) + if ($headers.Count -ne 1) { throw 'Expected exactly one completed xUnit test summary.' } + $headerIndex = [Array]::IndexOf($lines, $headers[0]) + $summaryLines = @($lines | Select-Object -Skip ($headerIndex + 1) -First 4) + $counts = @{} + foreach ($line in $summaryLines) { + if ($line -match '^\s*(total|failed|succeeded|skipped):\s*(\d+)\s*$') { $counts[$Matches[1]] = [int]$Matches[2] } + } + if ($counts.Count -ne 4) { throw 'The xUnit test summary counts are incomplete or ambiguous.' } + $failed = $counts.failed + $passed = $counts.succeeded + $skipped = $counts.skipped + $total = $counts.total + if ($total -lt 1 -or $passed -lt 1 -or $failed -ne 0 -or $skipped -ne 0 -or $passed -ne $total) { + throw 'Tests must execute at least once, all pass, and none fail or skip.' + } +} +# Downloads and executes the latest stable csrun release with your permissions. +# Source and release history: https://github.com/codebeltnet/csrun +$engineDirectory = Join-Path ([IO.Path]::GetTempPath()) ('csrun-' + [guid]::NewGuid().ToString('N')) +$null = New-Item -ItemType Directory -Path $engineDirectory +$enginePath = Join-Path $engineDirectory 'csrun.ps1' +$process = $null +try { + $release = Invoke-RestMethod 'https://api.github.com/repos/codebeltnet/csrun/releases/latest' + $assets = @($release.assets | Where-Object name -CEQ 'csrun.ps1') + if ($assets.Count -ne 1 -or $assets[0].digest -notmatch '^sha256:[0-9a-f]{64}$') { + throw "csrun release $($release.tag_name) must publish one csrun.ps1 asset with a SHA-256 digest." + } + $asset = $assets[0] + Invoke-WebRequest $asset.browser_download_url -OutFile $enginePath + $actualHash = (Get-FileHash -LiteralPath $enginePath -Algorithm SHA256).Hash + if ("sha256:$actualHash" -ne $asset.digest) { throw "csrun asset checksum mismatch: $actualHash" } +$startInfo = [Diagnostics.ProcessStartInfo]::new('pwsh') +foreach ($argument in @('-NoProfile','-NonInteractive','-File')) { $startInfo.ArgumentList.Add($argument) } +$startInfo.ArgumentList.Add($enginePath) +$startInfo.ArgumentList.Add('-ManifestJson') +$startInfo.ArgumentList.Add($manifest) +$startInfo.RedirectStandardOutput = $true +$startInfo.RedirectStandardError = $true +$startInfo.UseShellExecute = $false +$process = [Diagnostics.Process]::new() +$process.StartInfo = $startInfo +if (-not $process.Start()) { throw 'Could not start csrun.' } +$stdoutTask = $process.StandardOutput.ReadToEndAsync() +$stderrTask = $process.StandardError.ReadToEndAsync() +$process.WaitForExit() +$output = $stdoutTask.GetAwaiter().GetResult() +$diagnostics = $stderrTask.GetAwaiter().GetResult() +Write-Output $output +if ($diagnostics) { [Console]::Error.Write($diagnostics) } +} catch { + [Console]::Error.WriteLine("csrun diagnostics retained in: $engineDirectory") + throw +} finally { + $resolvedTemp = [IO.Path]::TrimEndingDirectorySeparator([IO.Path]::GetFullPath([IO.Path]::GetTempPath())) + $resolvedEngineDirectory = [IO.Path]::GetFullPath($engineDirectory) + if ([IO.Path]::GetDirectoryName($resolvedEngineDirectory) -ne $resolvedTemp -or + [IO.Path]::GetFileName($resolvedEngineDirectory) -cnotmatch '^csrun-[a-f0-9]{32}$') { throw 'Unsafe cleanup path.' } + if ($process -and $process.ExitCode -eq 0) { Remove-Item -LiteralPath $resolvedEngineDirectory -Recurse -Force } +} +if ($process.ExitCode -ne 0) { throw "csrun execution failed with exit code $($process.ExitCode). $diagnostics" } +if ($verifyTests) { Assert-CsrunTestOutput $output } +} \ No newline at end of file diff --git a/.docfx/run-actions/578d467fd203f66cc41b0364/docker.ps1 b/.docfx/run-actions/578d467fd203f66cc41b0364/docker.ps1 new file mode 100644 index 0000000..2ef8a3c --- /dev/null +++ b/.docfx/run-actions/578d467fd203f66cc41b0364/docker.ps1 @@ -0,0 +1,82 @@ +& { +#requires -Version 7.0 +$ErrorActionPreference = 'Stop' +$PSNativeCommandUseErrorActionPreference = $false +$manifest = @' +{ + "dependsOn": [ + "Codebelt.Extensions.Xunit@13.0.0", + "xunit.v3@4.0.3" + ], + "framework": "net10.0", + "mode": "test", + "schemaVersion": 1, + "source": "using Codebelt.Extensions.Xunit;\nusing Xunit;\n\nnamespace Example.Tests;\n\npublic class MixedOutputTest : Test\n{\n public MixedOutputTest(ITestOutputHelper output) : base(output) { }\n\n [Fact]\n public void ShouldWriteMixedValues()\n {\n TestOutput.WriteLines((object)\"cache\", 3);\n Assert.True(HasTestOutput);\n }\n}" +} +'@ +$OutputEncoding = [Text.UTF8Encoding]::new($false) +[Console]::OutputEncoding = $OutputEncoding +$verifyTests = $true +function Assert-CsrunTestOutput([string] $Output) { + $lines = @($Output -split '\r?\n') + $headers = @($lines | Where-Object { $_ -match '^Test run summary: Passed! - .+\)$' }) + if ($headers.Count -ne 1) { throw 'Expected exactly one completed xUnit test summary.' } + $headerIndex = [Array]::IndexOf($lines, $headers[0]) + $summaryLines = @($lines | Select-Object -Skip ($headerIndex + 1) -First 4) + $counts = @{} + foreach ($line in $summaryLines) { + if ($line -match '^\s*(total|failed|succeeded|skipped):\s*(\d+)\s*$') { $counts[$Matches[1]] = [int]$Matches[2] } + } + if ($counts.Count -ne 4) { throw 'The xUnit test summary counts are incomplete or ambiguous.' } + $failed = $counts.failed + $passed = $counts.succeeded + $skipped = $counts.skipped + $total = $counts.total + if ($total -lt 1 -or $passed -lt 1 -or $failed -ne 0 -or $skipped -ne 0 -or $passed -ne $total) { + throw 'Tests must execute at least once, all pass, and none fail or skip.' + } +} +# Downloads and executes the latest stable csrun release with your permissions. +# Source and release history: https://github.com/codebeltnet/csrun +$engineDirectory = Join-Path ([IO.Path]::GetTempPath()) ('csrun-' + [guid]::NewGuid().ToString('N')) +$null = New-Item -ItemType Directory -Path $engineDirectory +$enginePath = Join-Path $engineDirectory 'csrun.ps1' +$process = $null +try { + $release = Invoke-RestMethod 'https://api.github.com/repos/codebeltnet/csrun/releases/latest' + $assets = @($release.assets | Where-Object name -CEQ 'csrun.ps1') + if ($assets.Count -ne 1 -or $assets[0].digest -notmatch '^sha256:[0-9a-f]{64}$') { + throw "csrun release $($release.tag_name) must publish one csrun.ps1 asset with a SHA-256 digest." + } + $asset = $assets[0] + Invoke-WebRequest $asset.browser_download_url -OutFile $enginePath + $actualHash = (Get-FileHash -LiteralPath $enginePath -Algorithm SHA256).Hash + if ("sha256:$actualHash" -ne $asset.digest) { throw "csrun asset checksum mismatch: $actualHash" } +$enginePayload = [Convert]::ToBase64String([IO.File]::ReadAllBytes($enginePath)) +$containerInput = $enginePayload + "`n" + $manifest +$command = ' +$ErrorActionPreference = "Stop" +$enginePath = Join-Path ([IO.Path]::GetTempPath()) ("csrun-release-" + [guid]::NewGuid().ToString("N") + ".ps1") +$engineBytes = [Convert]::FromBase64String([Console]::In.ReadLine()) +[IO.File]::WriteAllBytes($enginePath, $engineBytes) +$manifest = [Console]::In.ReadToEnd() +& $enginePath -ManifestJson $manifest +exit $LASTEXITCODE +' +$output = (@($containerInput | & docker run --rm -i --entrypoint pwsh 'codebeltnet/csrun:10' -NoProfile -NonInteractive -Command $command) -join [Environment]::NewLine) +$process = [pscustomobject]@{ ExitCode = $LASTEXITCODE } +$diagnostics = '' +Write-Output $output +} catch { + [Console]::Error.WriteLine("csrun diagnostics retained in: $engineDirectory") + throw +} finally { + $resolvedTemp = [IO.Path]::TrimEndingDirectorySeparator([IO.Path]::GetFullPath([IO.Path]::GetTempPath())) + $resolvedEngineDirectory = [IO.Path]::GetFullPath($engineDirectory) + if ([IO.Path]::GetDirectoryName($resolvedEngineDirectory) -ne $resolvedTemp -or + [IO.Path]::GetFileName($resolvedEngineDirectory) -cnotmatch '^csrun-[a-f0-9]{32}$') { throw 'Unsafe cleanup path.' } + if ($process -and $process.ExitCode -eq 0) { Remove-Item -LiteralPath $resolvedEngineDirectory -Recurse -Force } +} +if ($process.ExitCode -ne 0) { throw "csrun execution failed with exit code $($process.ExitCode). $diagnostics" } +if ($verifyTests) { Assert-CsrunTestOutput $output } +} \ No newline at end of file diff --git a/.docfx/run-actions/578d467fd203f66cc41b0364/native.ps1 b/.docfx/run-actions/578d467fd203f66cc41b0364/native.ps1 new file mode 100644 index 0000000..60ddb06 --- /dev/null +++ b/.docfx/run-actions/578d467fd203f66cc41b0364/native.ps1 @@ -0,0 +1,85 @@ +& { +#requires -Version 7.0 +$ErrorActionPreference = 'Stop' +$PSNativeCommandUseErrorActionPreference = $false +$manifest = @' +{ + "dependsOn": [ + "Codebelt.Extensions.Xunit@13.0.0", + "xunit.v3@4.0.3" + ], + "framework": "net10.0", + "mode": "test", + "schemaVersion": 1, + "source": "using Codebelt.Extensions.Xunit;\nusing Xunit;\n\nnamespace Example.Tests;\n\npublic class MixedOutputTest : Test\n{\n public MixedOutputTest(ITestOutputHelper output) : base(output) { }\n\n [Fact]\n public void ShouldWriteMixedValues()\n {\n TestOutput.WriteLines((object)\"cache\", 3);\n Assert.True(HasTestOutput);\n }\n}" +} +'@ +$OutputEncoding = [Text.UTF8Encoding]::new($false) +[Console]::OutputEncoding = $OutputEncoding +$verifyTests = $true +function Assert-CsrunTestOutput([string] $Output) { + $lines = @($Output -split '\r?\n') + $headers = @($lines | Where-Object { $_ -match '^Test run summary: Passed! - .+\)$' }) + if ($headers.Count -ne 1) { throw 'Expected exactly one completed xUnit test summary.' } + $headerIndex = [Array]::IndexOf($lines, $headers[0]) + $summaryLines = @($lines | Select-Object -Skip ($headerIndex + 1) -First 4) + $counts = @{} + foreach ($line in $summaryLines) { + if ($line -match '^\s*(total|failed|succeeded|skipped):\s*(\d+)\s*$') { $counts[$Matches[1]] = [int]$Matches[2] } + } + if ($counts.Count -ne 4) { throw 'The xUnit test summary counts are incomplete or ambiguous.' } + $failed = $counts.failed + $passed = $counts.succeeded + $skipped = $counts.skipped + $total = $counts.total + if ($total -lt 1 -or $passed -lt 1 -or $failed -ne 0 -or $skipped -ne 0 -or $passed -ne $total) { + throw 'Tests must execute at least once, all pass, and none fail or skip.' + } +} +# Downloads and executes the latest stable csrun release with your permissions. +# Source and release history: https://github.com/codebeltnet/csrun +$engineDirectory = Join-Path ([IO.Path]::GetTempPath()) ('csrun-' + [guid]::NewGuid().ToString('N')) +$null = New-Item -ItemType Directory -Path $engineDirectory +$enginePath = Join-Path $engineDirectory 'csrun.ps1' +$process = $null +try { + $release = Invoke-RestMethod 'https://api.github.com/repos/codebeltnet/csrun/releases/latest' + $assets = @($release.assets | Where-Object name -CEQ 'csrun.ps1') + if ($assets.Count -ne 1 -or $assets[0].digest -notmatch '^sha256:[0-9a-f]{64}$') { + throw "csrun release $($release.tag_name) must publish one csrun.ps1 asset with a SHA-256 digest." + } + $asset = $assets[0] + Invoke-WebRequest $asset.browser_download_url -OutFile $enginePath + $actualHash = (Get-FileHash -LiteralPath $enginePath -Algorithm SHA256).Hash + if ("sha256:$actualHash" -ne $asset.digest) { throw "csrun asset checksum mismatch: $actualHash" } +$startInfo = [Diagnostics.ProcessStartInfo]::new('pwsh') +foreach ($argument in @('-NoProfile','-NonInteractive','-File')) { $startInfo.ArgumentList.Add($argument) } +$startInfo.ArgumentList.Add($enginePath) +$startInfo.ArgumentList.Add('-ManifestJson') +$startInfo.ArgumentList.Add($manifest) +$startInfo.RedirectStandardOutput = $true +$startInfo.RedirectStandardError = $true +$startInfo.UseShellExecute = $false +$process = [Diagnostics.Process]::new() +$process.StartInfo = $startInfo +if (-not $process.Start()) { throw 'Could not start csrun.' } +$stdoutTask = $process.StandardOutput.ReadToEndAsync() +$stderrTask = $process.StandardError.ReadToEndAsync() +$process.WaitForExit() +$output = $stdoutTask.GetAwaiter().GetResult() +$diagnostics = $stderrTask.GetAwaiter().GetResult() +Write-Output $output +if ($diagnostics) { [Console]::Error.Write($diagnostics) } +} catch { + [Console]::Error.WriteLine("csrun diagnostics retained in: $engineDirectory") + throw +} finally { + $resolvedTemp = [IO.Path]::TrimEndingDirectorySeparator([IO.Path]::GetFullPath([IO.Path]::GetTempPath())) + $resolvedEngineDirectory = [IO.Path]::GetFullPath($engineDirectory) + if ([IO.Path]::GetDirectoryName($resolvedEngineDirectory) -ne $resolvedTemp -or + [IO.Path]::GetFileName($resolvedEngineDirectory) -cnotmatch '^csrun-[a-f0-9]{32}$') { throw 'Unsafe cleanup path.' } + if ($process -and $process.ExitCode -eq 0) { Remove-Item -LiteralPath $resolvedEngineDirectory -Recurse -Force } +} +if ($process.ExitCode -ne 0) { throw "csrun execution failed with exit code $($process.ExitCode). $diagnostics" } +if ($verifyTests) { Assert-CsrunTestOutput $output } +} \ No newline at end of file diff --git a/.docfx/run-actions/5e35a33e56470f93afbedf19/docker.ps1 b/.docfx/run-actions/5e35a33e56470f93afbedf19/docker.ps1 new file mode 100644 index 0000000..315cacc --- /dev/null +++ b/.docfx/run-actions/5e35a33e56470f93afbedf19/docker.ps1 @@ -0,0 +1,83 @@ +& { +#requires -Version 7.0 +$ErrorActionPreference = 'Stop' +$PSNativeCommandUseErrorActionPreference = $false +$manifest = @' +{ + "dependsOn": [ + "Codebelt.Extensions.Xunit.Hosting@13.0.0", + "Microsoft.Extensions.Hosting@10.0.15", + "xunit.v3@4.0.3" + ], + "framework": "net10.0", + "mode": "test", + "schemaVersion": 1, + "source": "using System;\nusing Codebelt.Extensions.Xunit.Hosting;\nusing Microsoft.Extensions.DependencyInjection;\nusing Xunit;\n\nnamespace HostFixtureTests;\n\npublic class ServiceResolver\n{\n public T Resolve(IServiceProvider provider) where T : notnull\n {\n return provider.GetRequiredScopedService();\n }\n}\n\npublic sealed class RunExample\n{\n [Fact]\n public void ExercisesExample()\n {\n var services = new ServiceCollection();\n services.AddScoped(_ => new object());\n using var provider = services.BuildServiceProvider(new ServiceProviderOptions\n {\n ValidateScopes = true\n });\n Assert.NotSame(new ServiceResolver().Resolve(provider), new ServiceResolver().Resolve(provider));\n }\n}" +} +'@ +$OutputEncoding = [Text.UTF8Encoding]::new($false) +[Console]::OutputEncoding = $OutputEncoding +$verifyTests = $true +function Assert-CsrunTestOutput([string] $Output) { + $lines = @($Output -split '\r?\n') + $headers = @($lines | Where-Object { $_ -match '^Test run summary: Passed! - .+\)$' }) + if ($headers.Count -ne 1) { throw 'Expected exactly one completed xUnit test summary.' } + $headerIndex = [Array]::IndexOf($lines, $headers[0]) + $summaryLines = @($lines | Select-Object -Skip ($headerIndex + 1) -First 4) + $counts = @{} + foreach ($line in $summaryLines) { + if ($line -match '^\s*(total|failed|succeeded|skipped):\s*(\d+)\s*$') { $counts[$Matches[1]] = [int]$Matches[2] } + } + if ($counts.Count -ne 4) { throw 'The xUnit test summary counts are incomplete or ambiguous.' } + $failed = $counts.failed + $passed = $counts.succeeded + $skipped = $counts.skipped + $total = $counts.total + if ($total -lt 1 -or $passed -lt 1 -or $failed -ne 0 -or $skipped -ne 0 -or $passed -ne $total) { + throw 'Tests must execute at least once, all pass, and none fail or skip.' + } +} +# Downloads and executes the latest stable csrun release with your permissions. +# Source and release history: https://github.com/codebeltnet/csrun +$engineDirectory = Join-Path ([IO.Path]::GetTempPath()) ('csrun-' + [guid]::NewGuid().ToString('N')) +$null = New-Item -ItemType Directory -Path $engineDirectory +$enginePath = Join-Path $engineDirectory 'csrun.ps1' +$process = $null +try { + $release = Invoke-RestMethod 'https://api.github.com/repos/codebeltnet/csrun/releases/latest' + $assets = @($release.assets | Where-Object name -CEQ 'csrun.ps1') + if ($assets.Count -ne 1 -or $assets[0].digest -notmatch '^sha256:[0-9a-f]{64}$') { + throw "csrun release $($release.tag_name) must publish one csrun.ps1 asset with a SHA-256 digest." + } + $asset = $assets[0] + Invoke-WebRequest $asset.browser_download_url -OutFile $enginePath + $actualHash = (Get-FileHash -LiteralPath $enginePath -Algorithm SHA256).Hash + if ("sha256:$actualHash" -ne $asset.digest) { throw "csrun asset checksum mismatch: $actualHash" } +$enginePayload = [Convert]::ToBase64String([IO.File]::ReadAllBytes($enginePath)) +$containerInput = $enginePayload + "`n" + $manifest +$command = ' +$ErrorActionPreference = "Stop" +$enginePath = Join-Path ([IO.Path]::GetTempPath()) ("csrun-release-" + [guid]::NewGuid().ToString("N") + ".ps1") +$engineBytes = [Convert]::FromBase64String([Console]::In.ReadLine()) +[IO.File]::WriteAllBytes($enginePath, $engineBytes) +$manifest = [Console]::In.ReadToEnd() +& $enginePath -ManifestJson $manifest +exit $LASTEXITCODE +' +$output = (@($containerInput | & docker run --rm -i --entrypoint pwsh 'codebeltnet/csrun:10' -NoProfile -NonInteractive -Command $command) -join [Environment]::NewLine) +$process = [pscustomobject]@{ ExitCode = $LASTEXITCODE } +$diagnostics = '' +Write-Output $output +} catch { + [Console]::Error.WriteLine("csrun diagnostics retained in: $engineDirectory") + throw +} finally { + $resolvedTemp = [IO.Path]::TrimEndingDirectorySeparator([IO.Path]::GetFullPath([IO.Path]::GetTempPath())) + $resolvedEngineDirectory = [IO.Path]::GetFullPath($engineDirectory) + if ([IO.Path]::GetDirectoryName($resolvedEngineDirectory) -ne $resolvedTemp -or + [IO.Path]::GetFileName($resolvedEngineDirectory) -cnotmatch '^csrun-[a-f0-9]{32}$') { throw 'Unsafe cleanup path.' } + if ($process -and $process.ExitCode -eq 0) { Remove-Item -LiteralPath $resolvedEngineDirectory -Recurse -Force } +} +if ($process.ExitCode -ne 0) { throw "csrun execution failed with exit code $($process.ExitCode). $diagnostics" } +if ($verifyTests) { Assert-CsrunTestOutput $output } +} \ No newline at end of file diff --git a/.docfx/run-actions/5e35a33e56470f93afbedf19/native.ps1 b/.docfx/run-actions/5e35a33e56470f93afbedf19/native.ps1 new file mode 100644 index 0000000..acead69 --- /dev/null +++ b/.docfx/run-actions/5e35a33e56470f93afbedf19/native.ps1 @@ -0,0 +1,86 @@ +& { +#requires -Version 7.0 +$ErrorActionPreference = 'Stop' +$PSNativeCommandUseErrorActionPreference = $false +$manifest = @' +{ + "dependsOn": [ + "Codebelt.Extensions.Xunit.Hosting@13.0.0", + "Microsoft.Extensions.Hosting@10.0.15", + "xunit.v3@4.0.3" + ], + "framework": "net10.0", + "mode": "test", + "schemaVersion": 1, + "source": "using System;\nusing Codebelt.Extensions.Xunit.Hosting;\nusing Microsoft.Extensions.DependencyInjection;\nusing Xunit;\n\nnamespace HostFixtureTests;\n\npublic class ServiceResolver\n{\n public T Resolve(IServiceProvider provider) where T : notnull\n {\n return provider.GetRequiredScopedService();\n }\n}\n\npublic sealed class RunExample\n{\n [Fact]\n public void ExercisesExample()\n {\n var services = new ServiceCollection();\n services.AddScoped(_ => new object());\n using var provider = services.BuildServiceProvider(new ServiceProviderOptions\n {\n ValidateScopes = true\n });\n Assert.NotSame(new ServiceResolver().Resolve(provider), new ServiceResolver().Resolve(provider));\n }\n}" +} +'@ +$OutputEncoding = [Text.UTF8Encoding]::new($false) +[Console]::OutputEncoding = $OutputEncoding +$verifyTests = $true +function Assert-CsrunTestOutput([string] $Output) { + $lines = @($Output -split '\r?\n') + $headers = @($lines | Where-Object { $_ -match '^Test run summary: Passed! - .+\)$' }) + if ($headers.Count -ne 1) { throw 'Expected exactly one completed xUnit test summary.' } + $headerIndex = [Array]::IndexOf($lines, $headers[0]) + $summaryLines = @($lines | Select-Object -Skip ($headerIndex + 1) -First 4) + $counts = @{} + foreach ($line in $summaryLines) { + if ($line -match '^\s*(total|failed|succeeded|skipped):\s*(\d+)\s*$') { $counts[$Matches[1]] = [int]$Matches[2] } + } + if ($counts.Count -ne 4) { throw 'The xUnit test summary counts are incomplete or ambiguous.' } + $failed = $counts.failed + $passed = $counts.succeeded + $skipped = $counts.skipped + $total = $counts.total + if ($total -lt 1 -or $passed -lt 1 -or $failed -ne 0 -or $skipped -ne 0 -or $passed -ne $total) { + throw 'Tests must execute at least once, all pass, and none fail or skip.' + } +} +# Downloads and executes the latest stable csrun release with your permissions. +# Source and release history: https://github.com/codebeltnet/csrun +$engineDirectory = Join-Path ([IO.Path]::GetTempPath()) ('csrun-' + [guid]::NewGuid().ToString('N')) +$null = New-Item -ItemType Directory -Path $engineDirectory +$enginePath = Join-Path $engineDirectory 'csrun.ps1' +$process = $null +try { + $release = Invoke-RestMethod 'https://api.github.com/repos/codebeltnet/csrun/releases/latest' + $assets = @($release.assets | Where-Object name -CEQ 'csrun.ps1') + if ($assets.Count -ne 1 -or $assets[0].digest -notmatch '^sha256:[0-9a-f]{64}$') { + throw "csrun release $($release.tag_name) must publish one csrun.ps1 asset with a SHA-256 digest." + } + $asset = $assets[0] + Invoke-WebRequest $asset.browser_download_url -OutFile $enginePath + $actualHash = (Get-FileHash -LiteralPath $enginePath -Algorithm SHA256).Hash + if ("sha256:$actualHash" -ne $asset.digest) { throw "csrun asset checksum mismatch: $actualHash" } +$startInfo = [Diagnostics.ProcessStartInfo]::new('pwsh') +foreach ($argument in @('-NoProfile','-NonInteractive','-File')) { $startInfo.ArgumentList.Add($argument) } +$startInfo.ArgumentList.Add($enginePath) +$startInfo.ArgumentList.Add('-ManifestJson') +$startInfo.ArgumentList.Add($manifest) +$startInfo.RedirectStandardOutput = $true +$startInfo.RedirectStandardError = $true +$startInfo.UseShellExecute = $false +$process = [Diagnostics.Process]::new() +$process.StartInfo = $startInfo +if (-not $process.Start()) { throw 'Could not start csrun.' } +$stdoutTask = $process.StandardOutput.ReadToEndAsync() +$stderrTask = $process.StandardError.ReadToEndAsync() +$process.WaitForExit() +$output = $stdoutTask.GetAwaiter().GetResult() +$diagnostics = $stderrTask.GetAwaiter().GetResult() +Write-Output $output +if ($diagnostics) { [Console]::Error.Write($diagnostics) } +} catch { + [Console]::Error.WriteLine("csrun diagnostics retained in: $engineDirectory") + throw +} finally { + $resolvedTemp = [IO.Path]::TrimEndingDirectorySeparator([IO.Path]::GetFullPath([IO.Path]::GetTempPath())) + $resolvedEngineDirectory = [IO.Path]::GetFullPath($engineDirectory) + if ([IO.Path]::GetDirectoryName($resolvedEngineDirectory) -ne $resolvedTemp -or + [IO.Path]::GetFileName($resolvedEngineDirectory) -cnotmatch '^csrun-[a-f0-9]{32}$') { throw 'Unsafe cleanup path.' } + if ($process -and $process.ExitCode -eq 0) { Remove-Item -LiteralPath $resolvedEngineDirectory -Recurse -Force } +} +if ($process.ExitCode -ne 0) { throw "csrun execution failed with exit code $($process.ExitCode). $diagnostics" } +if ($verifyTests) { Assert-CsrunTestOutput $output } +} \ No newline at end of file diff --git a/.docfx/run-actions/6a59b7744a7d9994ffc04782/docker.ps1 b/.docfx/run-actions/6a59b7744a7d9994ffc04782/docker.ps1 new file mode 100644 index 0000000..b581a6b --- /dev/null +++ b/.docfx/run-actions/6a59b7744a7d9994ffc04782/docker.ps1 @@ -0,0 +1,83 @@ +& { +#requires -Version 7.0 +$ErrorActionPreference = 'Stop' +$PSNativeCommandUseErrorActionPreference = $false +$manifest = @' +{ + "dependsOn": [ + "Codebelt.Extensions.Xunit.Hosting@13.0.0", + "Microsoft.Extensions.Hosting@10.0.15", + "xunit.v3@4.0.3" + ], + "framework": "net10.0", + "mode": "test", + "schemaVersion": 1, + "source": "using Codebelt.Extensions.Xunit.Hosting;\nusing Microsoft.Extensions.DependencyInjection;\nusing Microsoft.Extensions.Hosting;\nusing Xunit;\n\nnamespace HostFixtureTests;\n\npublic class MinimalWorkerTest : MinimalHostTest\n{\n public MinimalWorkerTest(ManagedMinimalHostFixture hostFixture, ITestOutputHelper output) : base(hostFixture, output)\n {\n }\n\n protected override void ConfigureHost(IHostApplicationBuilder hb)\n {\n hb.Services.AddSingleton();\n hb.Services.AddXunitTestLogging();\n }\n\n [Fact]\n public void Host_ShouldNotBeNull()\n {\n Assert.NotNull(Host);\n }\n}\n\npublic class MetricsTracker;" +} +'@ +$OutputEncoding = [Text.UTF8Encoding]::new($false) +[Console]::OutputEncoding = $OutputEncoding +$verifyTests = $true +function Assert-CsrunTestOutput([string] $Output) { + $lines = @($Output -split '\r?\n') + $headers = @($lines | Where-Object { $_ -match '^Test run summary: Passed! - .+\)$' }) + if ($headers.Count -ne 1) { throw 'Expected exactly one completed xUnit test summary.' } + $headerIndex = [Array]::IndexOf($lines, $headers[0]) + $summaryLines = @($lines | Select-Object -Skip ($headerIndex + 1) -First 4) + $counts = @{} + foreach ($line in $summaryLines) { + if ($line -match '^\s*(total|failed|succeeded|skipped):\s*(\d+)\s*$') { $counts[$Matches[1]] = [int]$Matches[2] } + } + if ($counts.Count -ne 4) { throw 'The xUnit test summary counts are incomplete or ambiguous.' } + $failed = $counts.failed + $passed = $counts.succeeded + $skipped = $counts.skipped + $total = $counts.total + if ($total -lt 1 -or $passed -lt 1 -or $failed -ne 0 -or $skipped -ne 0 -or $passed -ne $total) { + throw 'Tests must execute at least once, all pass, and none fail or skip.' + } +} +# Downloads and executes the latest stable csrun release with your permissions. +# Source and release history: https://github.com/codebeltnet/csrun +$engineDirectory = Join-Path ([IO.Path]::GetTempPath()) ('csrun-' + [guid]::NewGuid().ToString('N')) +$null = New-Item -ItemType Directory -Path $engineDirectory +$enginePath = Join-Path $engineDirectory 'csrun.ps1' +$process = $null +try { + $release = Invoke-RestMethod 'https://api.github.com/repos/codebeltnet/csrun/releases/latest' + $assets = @($release.assets | Where-Object name -CEQ 'csrun.ps1') + if ($assets.Count -ne 1 -or $assets[0].digest -notmatch '^sha256:[0-9a-f]{64}$') { + throw "csrun release $($release.tag_name) must publish one csrun.ps1 asset with a SHA-256 digest." + } + $asset = $assets[0] + Invoke-WebRequest $asset.browser_download_url -OutFile $enginePath + $actualHash = (Get-FileHash -LiteralPath $enginePath -Algorithm SHA256).Hash + if ("sha256:$actualHash" -ne $asset.digest) { throw "csrun asset checksum mismatch: $actualHash" } +$enginePayload = [Convert]::ToBase64String([IO.File]::ReadAllBytes($enginePath)) +$containerInput = $enginePayload + "`n" + $manifest +$command = ' +$ErrorActionPreference = "Stop" +$enginePath = Join-Path ([IO.Path]::GetTempPath()) ("csrun-release-" + [guid]::NewGuid().ToString("N") + ".ps1") +$engineBytes = [Convert]::FromBase64String([Console]::In.ReadLine()) +[IO.File]::WriteAllBytes($enginePath, $engineBytes) +$manifest = [Console]::In.ReadToEnd() +& $enginePath -ManifestJson $manifest +exit $LASTEXITCODE +' +$output = (@($containerInput | & docker run --rm -i --entrypoint pwsh 'codebeltnet/csrun:10' -NoProfile -NonInteractive -Command $command) -join [Environment]::NewLine) +$process = [pscustomobject]@{ ExitCode = $LASTEXITCODE } +$diagnostics = '' +Write-Output $output +} catch { + [Console]::Error.WriteLine("csrun diagnostics retained in: $engineDirectory") + throw +} finally { + $resolvedTemp = [IO.Path]::TrimEndingDirectorySeparator([IO.Path]::GetFullPath([IO.Path]::GetTempPath())) + $resolvedEngineDirectory = [IO.Path]::GetFullPath($engineDirectory) + if ([IO.Path]::GetDirectoryName($resolvedEngineDirectory) -ne $resolvedTemp -or + [IO.Path]::GetFileName($resolvedEngineDirectory) -cnotmatch '^csrun-[a-f0-9]{32}$') { throw 'Unsafe cleanup path.' } + if ($process -and $process.ExitCode -eq 0) { Remove-Item -LiteralPath $resolvedEngineDirectory -Recurse -Force } +} +if ($process.ExitCode -ne 0) { throw "csrun execution failed with exit code $($process.ExitCode). $diagnostics" } +if ($verifyTests) { Assert-CsrunTestOutput $output } +} \ No newline at end of file diff --git a/.docfx/run-actions/6a59b7744a7d9994ffc04782/native.ps1 b/.docfx/run-actions/6a59b7744a7d9994ffc04782/native.ps1 new file mode 100644 index 0000000..de3f93d --- /dev/null +++ b/.docfx/run-actions/6a59b7744a7d9994ffc04782/native.ps1 @@ -0,0 +1,86 @@ +& { +#requires -Version 7.0 +$ErrorActionPreference = 'Stop' +$PSNativeCommandUseErrorActionPreference = $false +$manifest = @' +{ + "dependsOn": [ + "Codebelt.Extensions.Xunit.Hosting@13.0.0", + "Microsoft.Extensions.Hosting@10.0.15", + "xunit.v3@4.0.3" + ], + "framework": "net10.0", + "mode": "test", + "schemaVersion": 1, + "source": "using Codebelt.Extensions.Xunit.Hosting;\nusing Microsoft.Extensions.DependencyInjection;\nusing Microsoft.Extensions.Hosting;\nusing Xunit;\n\nnamespace HostFixtureTests;\n\npublic class MinimalWorkerTest : MinimalHostTest\n{\n public MinimalWorkerTest(ManagedMinimalHostFixture hostFixture, ITestOutputHelper output) : base(hostFixture, output)\n {\n }\n\n protected override void ConfigureHost(IHostApplicationBuilder hb)\n {\n hb.Services.AddSingleton();\n hb.Services.AddXunitTestLogging();\n }\n\n [Fact]\n public void Host_ShouldNotBeNull()\n {\n Assert.NotNull(Host);\n }\n}\n\npublic class MetricsTracker;" +} +'@ +$OutputEncoding = [Text.UTF8Encoding]::new($false) +[Console]::OutputEncoding = $OutputEncoding +$verifyTests = $true +function Assert-CsrunTestOutput([string] $Output) { + $lines = @($Output -split '\r?\n') + $headers = @($lines | Where-Object { $_ -match '^Test run summary: Passed! - .+\)$' }) + if ($headers.Count -ne 1) { throw 'Expected exactly one completed xUnit test summary.' } + $headerIndex = [Array]::IndexOf($lines, $headers[0]) + $summaryLines = @($lines | Select-Object -Skip ($headerIndex + 1) -First 4) + $counts = @{} + foreach ($line in $summaryLines) { + if ($line -match '^\s*(total|failed|succeeded|skipped):\s*(\d+)\s*$') { $counts[$Matches[1]] = [int]$Matches[2] } + } + if ($counts.Count -ne 4) { throw 'The xUnit test summary counts are incomplete or ambiguous.' } + $failed = $counts.failed + $passed = $counts.succeeded + $skipped = $counts.skipped + $total = $counts.total + if ($total -lt 1 -or $passed -lt 1 -or $failed -ne 0 -or $skipped -ne 0 -or $passed -ne $total) { + throw 'Tests must execute at least once, all pass, and none fail or skip.' + } +} +# Downloads and executes the latest stable csrun release with your permissions. +# Source and release history: https://github.com/codebeltnet/csrun +$engineDirectory = Join-Path ([IO.Path]::GetTempPath()) ('csrun-' + [guid]::NewGuid().ToString('N')) +$null = New-Item -ItemType Directory -Path $engineDirectory +$enginePath = Join-Path $engineDirectory 'csrun.ps1' +$process = $null +try { + $release = Invoke-RestMethod 'https://api.github.com/repos/codebeltnet/csrun/releases/latest' + $assets = @($release.assets | Where-Object name -CEQ 'csrun.ps1') + if ($assets.Count -ne 1 -or $assets[0].digest -notmatch '^sha256:[0-9a-f]{64}$') { + throw "csrun release $($release.tag_name) must publish one csrun.ps1 asset with a SHA-256 digest." + } + $asset = $assets[0] + Invoke-WebRequest $asset.browser_download_url -OutFile $enginePath + $actualHash = (Get-FileHash -LiteralPath $enginePath -Algorithm SHA256).Hash + if ("sha256:$actualHash" -ne $asset.digest) { throw "csrun asset checksum mismatch: $actualHash" } +$startInfo = [Diagnostics.ProcessStartInfo]::new('pwsh') +foreach ($argument in @('-NoProfile','-NonInteractive','-File')) { $startInfo.ArgumentList.Add($argument) } +$startInfo.ArgumentList.Add($enginePath) +$startInfo.ArgumentList.Add('-ManifestJson') +$startInfo.ArgumentList.Add($manifest) +$startInfo.RedirectStandardOutput = $true +$startInfo.RedirectStandardError = $true +$startInfo.UseShellExecute = $false +$process = [Diagnostics.Process]::new() +$process.StartInfo = $startInfo +if (-not $process.Start()) { throw 'Could not start csrun.' } +$stdoutTask = $process.StandardOutput.ReadToEndAsync() +$stderrTask = $process.StandardError.ReadToEndAsync() +$process.WaitForExit() +$output = $stdoutTask.GetAwaiter().GetResult() +$diagnostics = $stderrTask.GetAwaiter().GetResult() +Write-Output $output +if ($diagnostics) { [Console]::Error.Write($diagnostics) } +} catch { + [Console]::Error.WriteLine("csrun diagnostics retained in: $engineDirectory") + throw +} finally { + $resolvedTemp = [IO.Path]::TrimEndingDirectorySeparator([IO.Path]::GetFullPath([IO.Path]::GetTempPath())) + $resolvedEngineDirectory = [IO.Path]::GetFullPath($engineDirectory) + if ([IO.Path]::GetDirectoryName($resolvedEngineDirectory) -ne $resolvedTemp -or + [IO.Path]::GetFileName($resolvedEngineDirectory) -cnotmatch '^csrun-[a-f0-9]{32}$') { throw 'Unsafe cleanup path.' } + if ($process -and $process.ExitCode -eq 0) { Remove-Item -LiteralPath $resolvedEngineDirectory -Recurse -Force } +} +if ($process.ExitCode -ne 0) { throw "csrun execution failed with exit code $($process.ExitCode). $diagnostics" } +if ($verifyTests) { Assert-CsrunTestOutput $output } +} \ No newline at end of file diff --git a/.docfx/run-actions/782f24d34260070258f6d164/docker.ps1 b/.docfx/run-actions/782f24d34260070258f6d164/docker.ps1 new file mode 100644 index 0000000..6c98954 --- /dev/null +++ b/.docfx/run-actions/782f24d34260070258f6d164/docker.ps1 @@ -0,0 +1,82 @@ +& { +#requires -Version 7.0 +$ErrorActionPreference = 'Stop' +$PSNativeCommandUseErrorActionPreference = $false +$manifest = @' +{ + "dependsOn": [ + "Codebelt.Extensions.Xunit@13.0.0", + "xunit.v3@4.0.3" + ], + "framework": "net10.0", + "mode": "test", + "schemaVersion": 1, + "source": "using System;\nusing Codebelt.Extensions.Xunit;\nusing Xunit;\nusing Xunit.Sdk;\n\nnamespace Example.Tests;\n\n[TestMethodOrderer(typeof(PriorityTestMethodOrderer))]\npublic class CacheLifecycleTest : Test\n{\n private static bool _initialized;\n\n public CacheLifecycleTest(ITestOutputHelper output) : base(output) { }\n\n [Fact, Priority(-1)]\n public void ShouldInitializeCache()\n {\n var orderer = new PriorityTestMethodOrderer();\n Assert.Empty(orderer.OrderTestMethods(Array.Empty()));\n _initialized = true;\n }\n\n [Fact, Priority(0)]\n public void ShouldUseInitializedCache()\n {\n Assert.True(_initialized);\n }\n}" +} +'@ +$OutputEncoding = [Text.UTF8Encoding]::new($false) +[Console]::OutputEncoding = $OutputEncoding +$verifyTests = $true +function Assert-CsrunTestOutput([string] $Output) { + $lines = @($Output -split '\r?\n') + $headers = @($lines | Where-Object { $_ -match '^Test run summary: Passed! - .+\)$' }) + if ($headers.Count -ne 1) { throw 'Expected exactly one completed xUnit test summary.' } + $headerIndex = [Array]::IndexOf($lines, $headers[0]) + $summaryLines = @($lines | Select-Object -Skip ($headerIndex + 1) -First 4) + $counts = @{} + foreach ($line in $summaryLines) { + if ($line -match '^\s*(total|failed|succeeded|skipped):\s*(\d+)\s*$') { $counts[$Matches[1]] = [int]$Matches[2] } + } + if ($counts.Count -ne 4) { throw 'The xUnit test summary counts are incomplete or ambiguous.' } + $failed = $counts.failed + $passed = $counts.succeeded + $skipped = $counts.skipped + $total = $counts.total + if ($total -lt 1 -or $passed -lt 1 -or $failed -ne 0 -or $skipped -ne 0 -or $passed -ne $total) { + throw 'Tests must execute at least once, all pass, and none fail or skip.' + } +} +# Downloads and executes the latest stable csrun release with your permissions. +# Source and release history: https://github.com/codebeltnet/csrun +$engineDirectory = Join-Path ([IO.Path]::GetTempPath()) ('csrun-' + [guid]::NewGuid().ToString('N')) +$null = New-Item -ItemType Directory -Path $engineDirectory +$enginePath = Join-Path $engineDirectory 'csrun.ps1' +$process = $null +try { + $release = Invoke-RestMethod 'https://api.github.com/repos/codebeltnet/csrun/releases/latest' + $assets = @($release.assets | Where-Object name -CEQ 'csrun.ps1') + if ($assets.Count -ne 1 -or $assets[0].digest -notmatch '^sha256:[0-9a-f]{64}$') { + throw "csrun release $($release.tag_name) must publish one csrun.ps1 asset with a SHA-256 digest." + } + $asset = $assets[0] + Invoke-WebRequest $asset.browser_download_url -OutFile $enginePath + $actualHash = (Get-FileHash -LiteralPath $enginePath -Algorithm SHA256).Hash + if ("sha256:$actualHash" -ne $asset.digest) { throw "csrun asset checksum mismatch: $actualHash" } +$enginePayload = [Convert]::ToBase64String([IO.File]::ReadAllBytes($enginePath)) +$containerInput = $enginePayload + "`n" + $manifest +$command = ' +$ErrorActionPreference = "Stop" +$enginePath = Join-Path ([IO.Path]::GetTempPath()) ("csrun-release-" + [guid]::NewGuid().ToString("N") + ".ps1") +$engineBytes = [Convert]::FromBase64String([Console]::In.ReadLine()) +[IO.File]::WriteAllBytes($enginePath, $engineBytes) +$manifest = [Console]::In.ReadToEnd() +& $enginePath -ManifestJson $manifest +exit $LASTEXITCODE +' +$output = (@($containerInput | & docker run --rm -i --entrypoint pwsh 'codebeltnet/csrun:10' -NoProfile -NonInteractive -Command $command) -join [Environment]::NewLine) +$process = [pscustomobject]@{ ExitCode = $LASTEXITCODE } +$diagnostics = '' +Write-Output $output +} catch { + [Console]::Error.WriteLine("csrun diagnostics retained in: $engineDirectory") + throw +} finally { + $resolvedTemp = [IO.Path]::TrimEndingDirectorySeparator([IO.Path]::GetFullPath([IO.Path]::GetTempPath())) + $resolvedEngineDirectory = [IO.Path]::GetFullPath($engineDirectory) + if ([IO.Path]::GetDirectoryName($resolvedEngineDirectory) -ne $resolvedTemp -or + [IO.Path]::GetFileName($resolvedEngineDirectory) -cnotmatch '^csrun-[a-f0-9]{32}$') { throw 'Unsafe cleanup path.' } + if ($process -and $process.ExitCode -eq 0) { Remove-Item -LiteralPath $resolvedEngineDirectory -Recurse -Force } +} +if ($process.ExitCode -ne 0) { throw "csrun execution failed with exit code $($process.ExitCode). $diagnostics" } +if ($verifyTests) { Assert-CsrunTestOutput $output } +} \ No newline at end of file diff --git a/.docfx/run-actions/782f24d34260070258f6d164/native.ps1 b/.docfx/run-actions/782f24d34260070258f6d164/native.ps1 new file mode 100644 index 0000000..290f2a4 --- /dev/null +++ b/.docfx/run-actions/782f24d34260070258f6d164/native.ps1 @@ -0,0 +1,85 @@ +& { +#requires -Version 7.0 +$ErrorActionPreference = 'Stop' +$PSNativeCommandUseErrorActionPreference = $false +$manifest = @' +{ + "dependsOn": [ + "Codebelt.Extensions.Xunit@13.0.0", + "xunit.v3@4.0.3" + ], + "framework": "net10.0", + "mode": "test", + "schemaVersion": 1, + "source": "using System;\nusing Codebelt.Extensions.Xunit;\nusing Xunit;\nusing Xunit.Sdk;\n\nnamespace Example.Tests;\n\n[TestMethodOrderer(typeof(PriorityTestMethodOrderer))]\npublic class CacheLifecycleTest : Test\n{\n private static bool _initialized;\n\n public CacheLifecycleTest(ITestOutputHelper output) : base(output) { }\n\n [Fact, Priority(-1)]\n public void ShouldInitializeCache()\n {\n var orderer = new PriorityTestMethodOrderer();\n Assert.Empty(orderer.OrderTestMethods(Array.Empty()));\n _initialized = true;\n }\n\n [Fact, Priority(0)]\n public void ShouldUseInitializedCache()\n {\n Assert.True(_initialized);\n }\n}" +} +'@ +$OutputEncoding = [Text.UTF8Encoding]::new($false) +[Console]::OutputEncoding = $OutputEncoding +$verifyTests = $true +function Assert-CsrunTestOutput([string] $Output) { + $lines = @($Output -split '\r?\n') + $headers = @($lines | Where-Object { $_ -match '^Test run summary: Passed! - .+\)$' }) + if ($headers.Count -ne 1) { throw 'Expected exactly one completed xUnit test summary.' } + $headerIndex = [Array]::IndexOf($lines, $headers[0]) + $summaryLines = @($lines | Select-Object -Skip ($headerIndex + 1) -First 4) + $counts = @{} + foreach ($line in $summaryLines) { + if ($line -match '^\s*(total|failed|succeeded|skipped):\s*(\d+)\s*$') { $counts[$Matches[1]] = [int]$Matches[2] } + } + if ($counts.Count -ne 4) { throw 'The xUnit test summary counts are incomplete or ambiguous.' } + $failed = $counts.failed + $passed = $counts.succeeded + $skipped = $counts.skipped + $total = $counts.total + if ($total -lt 1 -or $passed -lt 1 -or $failed -ne 0 -or $skipped -ne 0 -or $passed -ne $total) { + throw 'Tests must execute at least once, all pass, and none fail or skip.' + } +} +# Downloads and executes the latest stable csrun release with your permissions. +# Source and release history: https://github.com/codebeltnet/csrun +$engineDirectory = Join-Path ([IO.Path]::GetTempPath()) ('csrun-' + [guid]::NewGuid().ToString('N')) +$null = New-Item -ItemType Directory -Path $engineDirectory +$enginePath = Join-Path $engineDirectory 'csrun.ps1' +$process = $null +try { + $release = Invoke-RestMethod 'https://api.github.com/repos/codebeltnet/csrun/releases/latest' + $assets = @($release.assets | Where-Object name -CEQ 'csrun.ps1') + if ($assets.Count -ne 1 -or $assets[0].digest -notmatch '^sha256:[0-9a-f]{64}$') { + throw "csrun release $($release.tag_name) must publish one csrun.ps1 asset with a SHA-256 digest." + } + $asset = $assets[0] + Invoke-WebRequest $asset.browser_download_url -OutFile $enginePath + $actualHash = (Get-FileHash -LiteralPath $enginePath -Algorithm SHA256).Hash + if ("sha256:$actualHash" -ne $asset.digest) { throw "csrun asset checksum mismatch: $actualHash" } +$startInfo = [Diagnostics.ProcessStartInfo]::new('pwsh') +foreach ($argument in @('-NoProfile','-NonInteractive','-File')) { $startInfo.ArgumentList.Add($argument) } +$startInfo.ArgumentList.Add($enginePath) +$startInfo.ArgumentList.Add('-ManifestJson') +$startInfo.ArgumentList.Add($manifest) +$startInfo.RedirectStandardOutput = $true +$startInfo.RedirectStandardError = $true +$startInfo.UseShellExecute = $false +$process = [Diagnostics.Process]::new() +$process.StartInfo = $startInfo +if (-not $process.Start()) { throw 'Could not start csrun.' } +$stdoutTask = $process.StandardOutput.ReadToEndAsync() +$stderrTask = $process.StandardError.ReadToEndAsync() +$process.WaitForExit() +$output = $stdoutTask.GetAwaiter().GetResult() +$diagnostics = $stderrTask.GetAwaiter().GetResult() +Write-Output $output +if ($diagnostics) { [Console]::Error.Write($diagnostics) } +} catch { + [Console]::Error.WriteLine("csrun diagnostics retained in: $engineDirectory") + throw +} finally { + $resolvedTemp = [IO.Path]::TrimEndingDirectorySeparator([IO.Path]::GetFullPath([IO.Path]::GetTempPath())) + $resolvedEngineDirectory = [IO.Path]::GetFullPath($engineDirectory) + if ([IO.Path]::GetDirectoryName($resolvedEngineDirectory) -ne $resolvedTemp -or + [IO.Path]::GetFileName($resolvedEngineDirectory) -cnotmatch '^csrun-[a-f0-9]{32}$') { throw 'Unsafe cleanup path.' } + if ($process -and $process.ExitCode -eq 0) { Remove-Item -LiteralPath $resolvedEngineDirectory -Recurse -Force } +} +if ($process.ExitCode -ne 0) { throw "csrun execution failed with exit code $($process.ExitCode). $diagnostics" } +if ($verifyTests) { Assert-CsrunTestOutput $output } +} \ No newline at end of file diff --git a/.docfx/run-actions/812efaa205554c7bdcd80831/docker.ps1 b/.docfx/run-actions/812efaa205554c7bdcd80831/docker.ps1 new file mode 100644 index 0000000..d1f8e6b --- /dev/null +++ b/.docfx/run-actions/812efaa205554c7bdcd80831/docker.ps1 @@ -0,0 +1,82 @@ +& { +#requires -Version 7.0 +$ErrorActionPreference = 'Stop' +$PSNativeCommandUseErrorActionPreference = $false +$manifest = @' +{ + "dependsOn": [ + "Codebelt.Extensions.Xunit@13.0.0", + "xunit.v3@4.0.3" + ], + "framework": "net10.0", + "mode": "test", + "schemaVersion": 1, + "source": "using Codebelt.Extensions.Xunit;\nusing Xunit;\n\nnamespace Example.Tests;\n\n[TestMethodOrderer(typeof(PriorityTestMethodOrderer))]\npublic class InitializationTest : Test\n{\n private static string _value;\n\n public InitializationTest(ITestOutputHelper output) : base(output) { }\n\n [Fact, Priority(0)]\n public void ShouldInitializeFirst()\n {\n var priority = new PriorityAttribute(0);\n Assert.Equal(0, priority.Priority);\n _value = \"ready\";\n }\n\n [Fact, Priority(1)]\n public void ShouldReadInitializedValue()\n {\n Assert.Equal(\"ready\", _value);\n }\n}" +} +'@ +$OutputEncoding = [Text.UTF8Encoding]::new($false) +[Console]::OutputEncoding = $OutputEncoding +$verifyTests = $true +function Assert-CsrunTestOutput([string] $Output) { + $lines = @($Output -split '\r?\n') + $headers = @($lines | Where-Object { $_ -match '^Test run summary: Passed! - .+\)$' }) + if ($headers.Count -ne 1) { throw 'Expected exactly one completed xUnit test summary.' } + $headerIndex = [Array]::IndexOf($lines, $headers[0]) + $summaryLines = @($lines | Select-Object -Skip ($headerIndex + 1) -First 4) + $counts = @{} + foreach ($line in $summaryLines) { + if ($line -match '^\s*(total|failed|succeeded|skipped):\s*(\d+)\s*$') { $counts[$Matches[1]] = [int]$Matches[2] } + } + if ($counts.Count -ne 4) { throw 'The xUnit test summary counts are incomplete or ambiguous.' } + $failed = $counts.failed + $passed = $counts.succeeded + $skipped = $counts.skipped + $total = $counts.total + if ($total -lt 1 -or $passed -lt 1 -or $failed -ne 0 -or $skipped -ne 0 -or $passed -ne $total) { + throw 'Tests must execute at least once, all pass, and none fail or skip.' + } +} +# Downloads and executes the latest stable csrun release with your permissions. +# Source and release history: https://github.com/codebeltnet/csrun +$engineDirectory = Join-Path ([IO.Path]::GetTempPath()) ('csrun-' + [guid]::NewGuid().ToString('N')) +$null = New-Item -ItemType Directory -Path $engineDirectory +$enginePath = Join-Path $engineDirectory 'csrun.ps1' +$process = $null +try { + $release = Invoke-RestMethod 'https://api.github.com/repos/codebeltnet/csrun/releases/latest' + $assets = @($release.assets | Where-Object name -CEQ 'csrun.ps1') + if ($assets.Count -ne 1 -or $assets[0].digest -notmatch '^sha256:[0-9a-f]{64}$') { + throw "csrun release $($release.tag_name) must publish one csrun.ps1 asset with a SHA-256 digest." + } + $asset = $assets[0] + Invoke-WebRequest $asset.browser_download_url -OutFile $enginePath + $actualHash = (Get-FileHash -LiteralPath $enginePath -Algorithm SHA256).Hash + if ("sha256:$actualHash" -ne $asset.digest) { throw "csrun asset checksum mismatch: $actualHash" } +$enginePayload = [Convert]::ToBase64String([IO.File]::ReadAllBytes($enginePath)) +$containerInput = $enginePayload + "`n" + $manifest +$command = ' +$ErrorActionPreference = "Stop" +$enginePath = Join-Path ([IO.Path]::GetTempPath()) ("csrun-release-" + [guid]::NewGuid().ToString("N") + ".ps1") +$engineBytes = [Convert]::FromBase64String([Console]::In.ReadLine()) +[IO.File]::WriteAllBytes($enginePath, $engineBytes) +$manifest = [Console]::In.ReadToEnd() +& $enginePath -ManifestJson $manifest +exit $LASTEXITCODE +' +$output = (@($containerInput | & docker run --rm -i --entrypoint pwsh 'codebeltnet/csrun:10' -NoProfile -NonInteractive -Command $command) -join [Environment]::NewLine) +$process = [pscustomobject]@{ ExitCode = $LASTEXITCODE } +$diagnostics = '' +Write-Output $output +} catch { + [Console]::Error.WriteLine("csrun diagnostics retained in: $engineDirectory") + throw +} finally { + $resolvedTemp = [IO.Path]::TrimEndingDirectorySeparator([IO.Path]::GetFullPath([IO.Path]::GetTempPath())) + $resolvedEngineDirectory = [IO.Path]::GetFullPath($engineDirectory) + if ([IO.Path]::GetDirectoryName($resolvedEngineDirectory) -ne $resolvedTemp -or + [IO.Path]::GetFileName($resolvedEngineDirectory) -cnotmatch '^csrun-[a-f0-9]{32}$') { throw 'Unsafe cleanup path.' } + if ($process -and $process.ExitCode -eq 0) { Remove-Item -LiteralPath $resolvedEngineDirectory -Recurse -Force } +} +if ($process.ExitCode -ne 0) { throw "csrun execution failed with exit code $($process.ExitCode). $diagnostics" } +if ($verifyTests) { Assert-CsrunTestOutput $output } +} \ No newline at end of file diff --git a/.docfx/run-actions/812efaa205554c7bdcd80831/native.ps1 b/.docfx/run-actions/812efaa205554c7bdcd80831/native.ps1 new file mode 100644 index 0000000..bb270a5 --- /dev/null +++ b/.docfx/run-actions/812efaa205554c7bdcd80831/native.ps1 @@ -0,0 +1,85 @@ +& { +#requires -Version 7.0 +$ErrorActionPreference = 'Stop' +$PSNativeCommandUseErrorActionPreference = $false +$manifest = @' +{ + "dependsOn": [ + "Codebelt.Extensions.Xunit@13.0.0", + "xunit.v3@4.0.3" + ], + "framework": "net10.0", + "mode": "test", + "schemaVersion": 1, + "source": "using Codebelt.Extensions.Xunit;\nusing Xunit;\n\nnamespace Example.Tests;\n\n[TestMethodOrderer(typeof(PriorityTestMethodOrderer))]\npublic class InitializationTest : Test\n{\n private static string _value;\n\n public InitializationTest(ITestOutputHelper output) : base(output) { }\n\n [Fact, Priority(0)]\n public void ShouldInitializeFirst()\n {\n var priority = new PriorityAttribute(0);\n Assert.Equal(0, priority.Priority);\n _value = \"ready\";\n }\n\n [Fact, Priority(1)]\n public void ShouldReadInitializedValue()\n {\n Assert.Equal(\"ready\", _value);\n }\n}" +} +'@ +$OutputEncoding = [Text.UTF8Encoding]::new($false) +[Console]::OutputEncoding = $OutputEncoding +$verifyTests = $true +function Assert-CsrunTestOutput([string] $Output) { + $lines = @($Output -split '\r?\n') + $headers = @($lines | Where-Object { $_ -match '^Test run summary: Passed! - .+\)$' }) + if ($headers.Count -ne 1) { throw 'Expected exactly one completed xUnit test summary.' } + $headerIndex = [Array]::IndexOf($lines, $headers[0]) + $summaryLines = @($lines | Select-Object -Skip ($headerIndex + 1) -First 4) + $counts = @{} + foreach ($line in $summaryLines) { + if ($line -match '^\s*(total|failed|succeeded|skipped):\s*(\d+)\s*$') { $counts[$Matches[1]] = [int]$Matches[2] } + } + if ($counts.Count -ne 4) { throw 'The xUnit test summary counts are incomplete or ambiguous.' } + $failed = $counts.failed + $passed = $counts.succeeded + $skipped = $counts.skipped + $total = $counts.total + if ($total -lt 1 -or $passed -lt 1 -or $failed -ne 0 -or $skipped -ne 0 -or $passed -ne $total) { + throw 'Tests must execute at least once, all pass, and none fail or skip.' + } +} +# Downloads and executes the latest stable csrun release with your permissions. +# Source and release history: https://github.com/codebeltnet/csrun +$engineDirectory = Join-Path ([IO.Path]::GetTempPath()) ('csrun-' + [guid]::NewGuid().ToString('N')) +$null = New-Item -ItemType Directory -Path $engineDirectory +$enginePath = Join-Path $engineDirectory 'csrun.ps1' +$process = $null +try { + $release = Invoke-RestMethod 'https://api.github.com/repos/codebeltnet/csrun/releases/latest' + $assets = @($release.assets | Where-Object name -CEQ 'csrun.ps1') + if ($assets.Count -ne 1 -or $assets[0].digest -notmatch '^sha256:[0-9a-f]{64}$') { + throw "csrun release $($release.tag_name) must publish one csrun.ps1 asset with a SHA-256 digest." + } + $asset = $assets[0] + Invoke-WebRequest $asset.browser_download_url -OutFile $enginePath + $actualHash = (Get-FileHash -LiteralPath $enginePath -Algorithm SHA256).Hash + if ("sha256:$actualHash" -ne $asset.digest) { throw "csrun asset checksum mismatch: $actualHash" } +$startInfo = [Diagnostics.ProcessStartInfo]::new('pwsh') +foreach ($argument in @('-NoProfile','-NonInteractive','-File')) { $startInfo.ArgumentList.Add($argument) } +$startInfo.ArgumentList.Add($enginePath) +$startInfo.ArgumentList.Add('-ManifestJson') +$startInfo.ArgumentList.Add($manifest) +$startInfo.RedirectStandardOutput = $true +$startInfo.RedirectStandardError = $true +$startInfo.UseShellExecute = $false +$process = [Diagnostics.Process]::new() +$process.StartInfo = $startInfo +if (-not $process.Start()) { throw 'Could not start csrun.' } +$stdoutTask = $process.StandardOutput.ReadToEndAsync() +$stderrTask = $process.StandardError.ReadToEndAsync() +$process.WaitForExit() +$output = $stdoutTask.GetAwaiter().GetResult() +$diagnostics = $stderrTask.GetAwaiter().GetResult() +Write-Output $output +if ($diagnostics) { [Console]::Error.Write($diagnostics) } +} catch { + [Console]::Error.WriteLine("csrun diagnostics retained in: $engineDirectory") + throw +} finally { + $resolvedTemp = [IO.Path]::TrimEndingDirectorySeparator([IO.Path]::GetFullPath([IO.Path]::GetTempPath())) + $resolvedEngineDirectory = [IO.Path]::GetFullPath($engineDirectory) + if ([IO.Path]::GetDirectoryName($resolvedEngineDirectory) -ne $resolvedTemp -or + [IO.Path]::GetFileName($resolvedEngineDirectory) -cnotmatch '^csrun-[a-f0-9]{32}$') { throw 'Unsafe cleanup path.' } + if ($process -and $process.ExitCode -eq 0) { Remove-Item -LiteralPath $resolvedEngineDirectory -Recurse -Force } +} +if ($process.ExitCode -ne 0) { throw "csrun execution failed with exit code $($process.ExitCode). $diagnostics" } +if ($verifyTests) { Assert-CsrunTestOutput $output } +} \ No newline at end of file diff --git a/.docfx/run-actions/90a8cd444bd08a0115613e58/docker.ps1 b/.docfx/run-actions/90a8cd444bd08a0115613e58/docker.ps1 new file mode 100644 index 0000000..b7d2512 --- /dev/null +++ b/.docfx/run-actions/90a8cd444bd08a0115613e58/docker.ps1 @@ -0,0 +1,58 @@ +& { +#requires -Version 7.0 + $ErrorActionPreference = 'Stop' + $PSNativeCommandUseErrorActionPreference = $false + # Executes trusted repository build tasks and NuGet packages with your permissions. + # Review the pinned source before running; a container is not a security sandbox. + $null = Get-Command docker -ErrorAction Stop + docker info *> $null + if ($LASTEXITCODE -ne 0) { throw 'Docker daemon unavailable.' } + $work = Join-Path ([IO.Path]::GetTempPath()) ('dx-' + [guid]::NewGuid().ToString('N').Substring(0, 8)) + $null = New-Item -ItemType Directory -Path $work + try { + $commit = '84b13767cb9484f8f3a36a71875662edfdb3e511' + Invoke-WebRequest "https://codeload.github.com/codebeltnet/xunit/zip/$commit" -OutFile "$work/source.zip" + Expand-Archive -LiteralPath "$work/source.zip" -DestinationPath "$work/extracted" + Move-Item -LiteralPath "$work/extracted/xunit-$commit" -Destination "$work/repo" + $project = 'test/Codebelt.Extensions.Xunit.Hosting.FunctionalTests/Codebelt.Extensions.Xunit.Hosting.FunctionalTests.csproj' + $test = 'Codebelt.Extensions.Xunit.Hosting.ApplicationTestFactoryTest.Create_ShouldBootstrapApplication_WhenEntryPointUsesBootstrapperMinimalWorkerProgram' + $dockerUser = @() + if ($IsLinux) { + # Keep bind-mounted build output removable by the host user. + $hostUid = id -u + if ($LASTEXITCODE -ne 0) { throw 'Cannot resolve host UID.' } + $hostGid = id -g + if ($LASTEXITCODE -ne 0) { throw 'Cannot resolve host GID.' } + $dockerUser = @('--user', "${hostUid}:${hostGid}") + } + # Let Docker's init reap orphaned build processes and keep build servers disposable. + docker run --rm --init @dockerUser --env HOME=/tmp --env DOTNET_CLI_HOME=/tmp --env MSBUILDDISABLENODEREUSE=1 --mount "type=bind,source=$work,target=/work" --workdir /work/repo mcr.microsoft.com/dotnet/sdk:11.0 dotnet run --disable-build-servers --project $project --framework net11.0 -p:SkipSignAssembly=true -- --filter-method $test --report-xunit-xml --report-xunit-xml-filename result.xml --results-directory /work/results 2>&1 | Tee-Object -FilePath "$work/run.log" + $code = $LASTEXITCODE + if ($code -ne 0) { throw "Repository test failed with exit code $code. See $work/run.log" } + # Require exactly the original test, executed and passing, with no runner errors. + [xml] $report = Get-Content -LiteralPath "$work/results/result.xml" -Raw + $tests = @($report.SelectNodes('/assemblies/assembly/collection/test')) + $assemblies = @($report.SelectNodes('/assemblies/assembly')) + if ($assemblies.Count -ne 1 -or $assemblies[0].total -ne '1' -or $assemblies[0].passed -ne '1' -or + $assemblies[0].errors -ne '0' -or $tests.Count -ne 1 -or $tests[0].name -cne $test -or $tests[0].result -cne 'Pass') { + throw "Expected exactly one passing $test; inspect $work/results/result.xml" + } + Write-Host "Verified: $test (1 executed, 1 passed)." + } + catch { + # Preserve diagnostics outside the repository even though downloaded source is cleaned. + $diagnostics = "$work-diagnostics" + $null = New-Item -ItemType Directory -Path $diagnostics -Force + foreach ($name in @('run.log', 'results')) { + if (Test-Path -LiteralPath "$work/$name") { Copy-Item -LiteralPath "$work/$name" -Destination $diagnostics -Recurse } + } + Write-Warning "Execution not verified. Diagnostics: $diagnostics" + throw + } + finally { + $resolved = [IO.Path]::GetFullPath($work) + $temp = [IO.Path]::GetFullPath([IO.Path]::GetTempPath()).TrimEnd('/','\') + [IO.Path]::DirectorySeparatorChar + if (-not $resolved.StartsWith($temp, [StringComparison]::OrdinalIgnoreCase)) { throw 'Unsafe cleanup path.' } + Remove-Item -LiteralPath $resolved -Recurse -Force + } +} \ No newline at end of file diff --git a/.docfx/run-actions/90a8cd444bd08a0115613e58/native.ps1 b/.docfx/run-actions/90a8cd444bd08a0115613e58/native.ps1 new file mode 100644 index 0000000..5e9b40c --- /dev/null +++ b/.docfx/run-actions/90a8cd444bd08a0115613e58/native.ps1 @@ -0,0 +1,50 @@ +& { +#requires -Version 7.0 + $ErrorActionPreference = 'Stop' + $PSNativeCommandUseErrorActionPreference = $false + # Executes trusted repository build tasks and NuGet packages with your permissions. + # Review the pinned source before running; a container is not a security sandbox. + $null = Get-Command dotnet -ErrorAction Stop + $work = Join-Path ([IO.Path]::GetTempPath()) ('dx-' + [guid]::NewGuid().ToString('N').Substring(0, 8)) + $null = New-Item -ItemType Directory -Path $work + try { + $commit = '84b13767cb9484f8f3a36a71875662edfdb3e511' + Invoke-WebRequest "https://codeload.github.com/codebeltnet/xunit/zip/$commit" -OutFile "$work/source.zip" + Expand-Archive -LiteralPath "$work/source.zip" -DestinationPath "$work/extracted" + Move-Item -LiteralPath "$work/extracted/xunit-$commit" -Destination "$work/repo" + $project = 'test/Codebelt.Extensions.Xunit.Hosting.FunctionalTests/Codebelt.Extensions.Xunit.Hosting.FunctionalTests.csproj' + $test = 'Codebelt.Extensions.Xunit.Hosting.ApplicationTestFactoryTest.Create_ShouldBootstrapApplication_WhenEntryPointUsesBootstrapperMinimalWorkerProgram' + Push-Location "$work/repo" + try { + dotnet run --project $project --framework net11.0 -p:SkipSignAssembly=true -- --filter-method $test --report-xunit-xml --report-xunit-xml-filename result.xml --results-directory "$work/results" 2>&1 | Tee-Object -FilePath "$work/run.log" + } + finally { Pop-Location } + $code = $LASTEXITCODE + if ($code -ne 0) { throw "Repository test failed with exit code $code. See $work/run.log" } + # Require exactly the original test, executed and passing, with no runner errors. + [xml] $report = Get-Content -LiteralPath "$work/results/result.xml" -Raw + $tests = @($report.SelectNodes('/assemblies/assembly/collection/test')) + $assemblies = @($report.SelectNodes('/assemblies/assembly')) + if ($assemblies.Count -ne 1 -or $assemblies[0].total -ne '1' -or $assemblies[0].passed -ne '1' -or + $assemblies[0].errors -ne '0' -or $tests.Count -ne 1 -or $tests[0].name -cne $test -or $tests[0].result -cne 'Pass') { + throw "Expected exactly one passing $test; inspect $work/results/result.xml" + } + Write-Host "Verified: $test (1 executed, 1 passed)." + } + catch { + # Preserve diagnostics outside the repository even though downloaded source is cleaned. + $diagnostics = "$work-diagnostics" + $null = New-Item -ItemType Directory -Path $diagnostics -Force + foreach ($name in @('run.log', 'results')) { + if (Test-Path -LiteralPath "$work/$name") { Copy-Item -LiteralPath "$work/$name" -Destination $diagnostics -Recurse } + } + Write-Warning "Execution not verified. Diagnostics: $diagnostics" + throw + } + finally { + $resolved = [IO.Path]::GetFullPath($work) + $temp = [IO.Path]::GetFullPath([IO.Path]::GetTempPath()).TrimEnd('/','\') + [IO.Path]::DirectorySeparatorChar + if (-not $resolved.StartsWith($temp, [StringComparison]::OrdinalIgnoreCase)) { throw 'Unsafe cleanup path.' } + Remove-Item -LiteralPath $resolved -Recurse -Force + } +} \ No newline at end of file diff --git a/.docfx/run-actions/927ca9f6a3bf893bc52887f4/docker.ps1 b/.docfx/run-actions/927ca9f6a3bf893bc52887f4/docker.ps1 new file mode 100644 index 0000000..be7beec --- /dev/null +++ b/.docfx/run-actions/927ca9f6a3bf893bc52887f4/docker.ps1 @@ -0,0 +1,86 @@ +& { +#requires -Version 7.0 +$ErrorActionPreference = 'Stop' +$PSNativeCommandUseErrorActionPreference = $false +$manifest = @' +{ + "dependsOn": [ + "Codebelt.Extensions.Xunit.Hosting.AspNetCore@13.0.0", + "Microsoft.Extensions.Hosting@10.0.15", + "xunit.v3@4.0.3" + ], + "framework": "net10.0", + "frameworkReferences": [ + "Microsoft.AspNetCore.App" + ], + "mode": "test", + "schemaVersion": 1, + "source": "using System.Threading.Tasks;\nusing Codebelt.Extensions.Xunit.Hosting.AspNetCore;\nusing Microsoft.AspNetCore.Builder;\nusing Microsoft.AspNetCore.Http;\nusing Microsoft.Extensions.DependencyInjection;\nusing Xunit;\n\nnamespace WebFixtureTests;\n\npublic class MiddlewareTest : WebHostTest\n{\n public MiddlewareTest(ManagedWebHostFixture hostFixture, ITestOutputHelper output) : base(hostFixture, output)\n {\n }\n\n public override void ConfigureServices(IServiceCollection services)\n {\n services.AddFakeHttpContextAccessor();\n }\n\n public override void ConfigureApplication(IApplicationBuilder app)\n {\n app.UseMiddleware();\n }\n\n [Fact]\n public async Task Middleware_ShouldAddHeader()\n {\n var pipeline = Application.Build();\n var context = new DefaultHttpContext();\n await pipeline(context);\n Assert.True(context.Response.Headers.ContainsKey(\"X-Test\"));\n }\n}\n\npublic class TestMiddleware(RequestDelegate next)\n{\n public async Task InvokeAsync(HttpContext context)\n {\n context.Response.Headers[\"X-Test\"] = \"true\";\n await next(context);\n }\n}" +} +'@ +$OutputEncoding = [Text.UTF8Encoding]::new($false) +[Console]::OutputEncoding = $OutputEncoding +$verifyTests = $true +function Assert-CsrunTestOutput([string] $Output) { + $lines = @($Output -split '\r?\n') + $headers = @($lines | Where-Object { $_ -match '^Test run summary: Passed! - .+\)$' }) + if ($headers.Count -ne 1) { throw 'Expected exactly one completed xUnit test summary.' } + $headerIndex = [Array]::IndexOf($lines, $headers[0]) + $summaryLines = @($lines | Select-Object -Skip ($headerIndex + 1) -First 4) + $counts = @{} + foreach ($line in $summaryLines) { + if ($line -match '^\s*(total|failed|succeeded|skipped):\s*(\d+)\s*$') { $counts[$Matches[1]] = [int]$Matches[2] } + } + if ($counts.Count -ne 4) { throw 'The xUnit test summary counts are incomplete or ambiguous.' } + $failed = $counts.failed + $passed = $counts.succeeded + $skipped = $counts.skipped + $total = $counts.total + if ($total -lt 1 -or $passed -lt 1 -or $failed -ne 0 -or $skipped -ne 0 -or $passed -ne $total) { + throw 'Tests must execute at least once, all pass, and none fail or skip.' + } +} +# Downloads and executes the latest stable csrun release with your permissions. +# Source and release history: https://github.com/codebeltnet/csrun +$engineDirectory = Join-Path ([IO.Path]::GetTempPath()) ('csrun-' + [guid]::NewGuid().ToString('N')) +$null = New-Item -ItemType Directory -Path $engineDirectory +$enginePath = Join-Path $engineDirectory 'csrun.ps1' +$process = $null +try { + $release = Invoke-RestMethod 'https://api.github.com/repos/codebeltnet/csrun/releases/latest' + $assets = @($release.assets | Where-Object name -CEQ 'csrun.ps1') + if ($assets.Count -ne 1 -or $assets[0].digest -notmatch '^sha256:[0-9a-f]{64}$') { + throw "csrun release $($release.tag_name) must publish one csrun.ps1 asset with a SHA-256 digest." + } + $asset = $assets[0] + Invoke-WebRequest $asset.browser_download_url -OutFile $enginePath + $actualHash = (Get-FileHash -LiteralPath $enginePath -Algorithm SHA256).Hash + if ("sha256:$actualHash" -ne $asset.digest) { throw "csrun asset checksum mismatch: $actualHash" } +$enginePayload = [Convert]::ToBase64String([IO.File]::ReadAllBytes($enginePath)) +$containerInput = $enginePayload + "`n" + $manifest +$command = ' +$ErrorActionPreference = "Stop" +$enginePath = Join-Path ([IO.Path]::GetTempPath()) ("csrun-release-" + [guid]::NewGuid().ToString("N") + ".ps1") +$engineBytes = [Convert]::FromBase64String([Console]::In.ReadLine()) +[IO.File]::WriteAllBytes($enginePath, $engineBytes) +$manifest = [Console]::In.ReadToEnd() +& $enginePath -ManifestJson $manifest +exit $LASTEXITCODE +' +$output = (@($containerInput | & docker run --rm -i --entrypoint pwsh 'codebeltnet/csrun:10' -NoProfile -NonInteractive -Command $command) -join [Environment]::NewLine) +$process = [pscustomobject]@{ ExitCode = $LASTEXITCODE } +$diagnostics = '' +Write-Output $output +} catch { + [Console]::Error.WriteLine("csrun diagnostics retained in: $engineDirectory") + throw +} finally { + $resolvedTemp = [IO.Path]::TrimEndingDirectorySeparator([IO.Path]::GetFullPath([IO.Path]::GetTempPath())) + $resolvedEngineDirectory = [IO.Path]::GetFullPath($engineDirectory) + if ([IO.Path]::GetDirectoryName($resolvedEngineDirectory) -ne $resolvedTemp -or + [IO.Path]::GetFileName($resolvedEngineDirectory) -cnotmatch '^csrun-[a-f0-9]{32}$') { throw 'Unsafe cleanup path.' } + if ($process -and $process.ExitCode -eq 0) { Remove-Item -LiteralPath $resolvedEngineDirectory -Recurse -Force } +} +if ($process.ExitCode -ne 0) { throw "csrun execution failed with exit code $($process.ExitCode). $diagnostics" } +if ($verifyTests) { Assert-CsrunTestOutput $output } +} \ No newline at end of file diff --git a/.docfx/run-actions/927ca9f6a3bf893bc52887f4/native.ps1 b/.docfx/run-actions/927ca9f6a3bf893bc52887f4/native.ps1 new file mode 100644 index 0000000..ac944b9 --- /dev/null +++ b/.docfx/run-actions/927ca9f6a3bf893bc52887f4/native.ps1 @@ -0,0 +1,89 @@ +& { +#requires -Version 7.0 +$ErrorActionPreference = 'Stop' +$PSNativeCommandUseErrorActionPreference = $false +$manifest = @' +{ + "dependsOn": [ + "Codebelt.Extensions.Xunit.Hosting.AspNetCore@13.0.0", + "Microsoft.Extensions.Hosting@10.0.15", + "xunit.v3@4.0.3" + ], + "framework": "net10.0", + "frameworkReferences": [ + "Microsoft.AspNetCore.App" + ], + "mode": "test", + "schemaVersion": 1, + "source": "using System.Threading.Tasks;\nusing Codebelt.Extensions.Xunit.Hosting.AspNetCore;\nusing Microsoft.AspNetCore.Builder;\nusing Microsoft.AspNetCore.Http;\nusing Microsoft.Extensions.DependencyInjection;\nusing Xunit;\n\nnamespace WebFixtureTests;\n\npublic class MiddlewareTest : WebHostTest\n{\n public MiddlewareTest(ManagedWebHostFixture hostFixture, ITestOutputHelper output) : base(hostFixture, output)\n {\n }\n\n public override void ConfigureServices(IServiceCollection services)\n {\n services.AddFakeHttpContextAccessor();\n }\n\n public override void ConfigureApplication(IApplicationBuilder app)\n {\n app.UseMiddleware();\n }\n\n [Fact]\n public async Task Middleware_ShouldAddHeader()\n {\n var pipeline = Application.Build();\n var context = new DefaultHttpContext();\n await pipeline(context);\n Assert.True(context.Response.Headers.ContainsKey(\"X-Test\"));\n }\n}\n\npublic class TestMiddleware(RequestDelegate next)\n{\n public async Task InvokeAsync(HttpContext context)\n {\n context.Response.Headers[\"X-Test\"] = \"true\";\n await next(context);\n }\n}" +} +'@ +$OutputEncoding = [Text.UTF8Encoding]::new($false) +[Console]::OutputEncoding = $OutputEncoding +$verifyTests = $true +function Assert-CsrunTestOutput([string] $Output) { + $lines = @($Output -split '\r?\n') + $headers = @($lines | Where-Object { $_ -match '^Test run summary: Passed! - .+\)$' }) + if ($headers.Count -ne 1) { throw 'Expected exactly one completed xUnit test summary.' } + $headerIndex = [Array]::IndexOf($lines, $headers[0]) + $summaryLines = @($lines | Select-Object -Skip ($headerIndex + 1) -First 4) + $counts = @{} + foreach ($line in $summaryLines) { + if ($line -match '^\s*(total|failed|succeeded|skipped):\s*(\d+)\s*$') { $counts[$Matches[1]] = [int]$Matches[2] } + } + if ($counts.Count -ne 4) { throw 'The xUnit test summary counts are incomplete or ambiguous.' } + $failed = $counts.failed + $passed = $counts.succeeded + $skipped = $counts.skipped + $total = $counts.total + if ($total -lt 1 -or $passed -lt 1 -or $failed -ne 0 -or $skipped -ne 0 -or $passed -ne $total) { + throw 'Tests must execute at least once, all pass, and none fail or skip.' + } +} +# Downloads and executes the latest stable csrun release with your permissions. +# Source and release history: https://github.com/codebeltnet/csrun +$engineDirectory = Join-Path ([IO.Path]::GetTempPath()) ('csrun-' + [guid]::NewGuid().ToString('N')) +$null = New-Item -ItemType Directory -Path $engineDirectory +$enginePath = Join-Path $engineDirectory 'csrun.ps1' +$process = $null +try { + $release = Invoke-RestMethod 'https://api.github.com/repos/codebeltnet/csrun/releases/latest' + $assets = @($release.assets | Where-Object name -CEQ 'csrun.ps1') + if ($assets.Count -ne 1 -or $assets[0].digest -notmatch '^sha256:[0-9a-f]{64}$') { + throw "csrun release $($release.tag_name) must publish one csrun.ps1 asset with a SHA-256 digest." + } + $asset = $assets[0] + Invoke-WebRequest $asset.browser_download_url -OutFile $enginePath + $actualHash = (Get-FileHash -LiteralPath $enginePath -Algorithm SHA256).Hash + if ("sha256:$actualHash" -ne $asset.digest) { throw "csrun asset checksum mismatch: $actualHash" } +$startInfo = [Diagnostics.ProcessStartInfo]::new('pwsh') +foreach ($argument in @('-NoProfile','-NonInteractive','-File')) { $startInfo.ArgumentList.Add($argument) } +$startInfo.ArgumentList.Add($enginePath) +$startInfo.ArgumentList.Add('-ManifestJson') +$startInfo.ArgumentList.Add($manifest) +$startInfo.RedirectStandardOutput = $true +$startInfo.RedirectStandardError = $true +$startInfo.UseShellExecute = $false +$process = [Diagnostics.Process]::new() +$process.StartInfo = $startInfo +if (-not $process.Start()) { throw 'Could not start csrun.' } +$stdoutTask = $process.StandardOutput.ReadToEndAsync() +$stderrTask = $process.StandardError.ReadToEndAsync() +$process.WaitForExit() +$output = $stdoutTask.GetAwaiter().GetResult() +$diagnostics = $stderrTask.GetAwaiter().GetResult() +Write-Output $output +if ($diagnostics) { [Console]::Error.Write($diagnostics) } +} catch { + [Console]::Error.WriteLine("csrun diagnostics retained in: $engineDirectory") + throw +} finally { + $resolvedTemp = [IO.Path]::TrimEndingDirectorySeparator([IO.Path]::GetFullPath([IO.Path]::GetTempPath())) + $resolvedEngineDirectory = [IO.Path]::GetFullPath($engineDirectory) + if ([IO.Path]::GetDirectoryName($resolvedEngineDirectory) -ne $resolvedTemp -or + [IO.Path]::GetFileName($resolvedEngineDirectory) -cnotmatch '^csrun-[a-f0-9]{32}$') { throw 'Unsafe cleanup path.' } + if ($process -and $process.ExitCode -eq 0) { Remove-Item -LiteralPath $resolvedEngineDirectory -Recurse -Force } +} +if ($process.ExitCode -ne 0) { throw "csrun execution failed with exit code $($process.ExitCode). $diagnostics" } +if ($verifyTests) { Assert-CsrunTestOutput $output } +} \ No newline at end of file diff --git a/.docfx/run-actions/947406357e3e26b26a71a538/docker.ps1 b/.docfx/run-actions/947406357e3e26b26a71a538/docker.ps1 new file mode 100644 index 0000000..ed02c38 --- /dev/null +++ b/.docfx/run-actions/947406357e3e26b26a71a538/docker.ps1 @@ -0,0 +1,87 @@ +& { +#requires -Version 7.0 +$ErrorActionPreference = 'Stop' +$PSNativeCommandUseErrorActionPreference = $false +$manifest = @' +{ + "dependsOn": [ + "Codebelt.Extensions.Xunit.Hosting.AspNetCore@13.0.0", + "Microsoft.Extensions.Hosting@10.0.15", + "Microsoft.AspNetCore.TestHost@10.0.15" + ], + "framework": "net10.0", + "frameworkReferences": [ + "Microsoft.AspNetCore.App" + ], + "mode": "console", + "schemaVersion": 1, + "sdk": "Microsoft.NET.Sdk.Web", + "source": "using System;\nusing System.Net.Http;\nusing System.Threading.Tasks;\nusing Codebelt.Extensions.Xunit.Hosting.AspNetCore;\nusing Microsoft.AspNetCore.Builder;\nusing Microsoft.AspNetCore.TestHost;\n\nnamespace WebFixtureTests;\n\npublic class HttpClientExample\n{\n public async Task DemonstrateAsync(HttpClient client)\n {\n var response = await client.ToHttpResponseMessageAsync().ConfigureAwait(false);\n Console.WriteLine(response.StatusCode);\n }\n}\n\ninternal static class RunExample\n{\n static async Task Main()\n {\n using var app = WebHostTestFactory.Create(pipelineSetup: app => app.Run(context =>\n {\n context.Response.StatusCode = 202;\n return Task.CompletedTask;\n }));\n using var client = app.Host.GetTestClient();\n await new HttpClientExample().DemonstrateAsync(client);\n }\n}" +} +'@ +$OutputEncoding = [Text.UTF8Encoding]::new($false) +[Console]::OutputEncoding = $OutputEncoding +$verifyTests = $false +function Assert-CsrunTestOutput([string] $Output) { + $lines = @($Output -split '\r?\n') + $headers = @($lines | Where-Object { $_ -match '^Test run summary: Passed! - .+\)$' }) + if ($headers.Count -ne 1) { throw 'Expected exactly one completed xUnit test summary.' } + $headerIndex = [Array]::IndexOf($lines, $headers[0]) + $summaryLines = @($lines | Select-Object -Skip ($headerIndex + 1) -First 4) + $counts = @{} + foreach ($line in $summaryLines) { + if ($line -match '^\s*(total|failed|succeeded|skipped):\s*(\d+)\s*$') { $counts[$Matches[1]] = [int]$Matches[2] } + } + if ($counts.Count -ne 4) { throw 'The xUnit test summary counts are incomplete or ambiguous.' } + $failed = $counts.failed + $passed = $counts.succeeded + $skipped = $counts.skipped + $total = $counts.total + if ($total -lt 1 -or $passed -lt 1 -or $failed -ne 0 -or $skipped -ne 0 -or $passed -ne $total) { + throw 'Tests must execute at least once, all pass, and none fail or skip.' + } +} +# Downloads and executes the latest stable csrun release with your permissions. +# Source and release history: https://github.com/codebeltnet/csrun +$engineDirectory = Join-Path ([IO.Path]::GetTempPath()) ('csrun-' + [guid]::NewGuid().ToString('N')) +$null = New-Item -ItemType Directory -Path $engineDirectory +$enginePath = Join-Path $engineDirectory 'csrun.ps1' +$process = $null +try { + $release = Invoke-RestMethod 'https://api.github.com/repos/codebeltnet/csrun/releases/latest' + $assets = @($release.assets | Where-Object name -CEQ 'csrun.ps1') + if ($assets.Count -ne 1 -or $assets[0].digest -notmatch '^sha256:[0-9a-f]{64}$') { + throw "csrun release $($release.tag_name) must publish one csrun.ps1 asset with a SHA-256 digest." + } + $asset = $assets[0] + Invoke-WebRequest $asset.browser_download_url -OutFile $enginePath + $actualHash = (Get-FileHash -LiteralPath $enginePath -Algorithm SHA256).Hash + if ("sha256:$actualHash" -ne $asset.digest) { throw "csrun asset checksum mismatch: $actualHash" } +$enginePayload = [Convert]::ToBase64String([IO.File]::ReadAllBytes($enginePath)) +$containerInput = $enginePayload + "`n" + $manifest +$command = ' +$ErrorActionPreference = "Stop" +$enginePath = Join-Path ([IO.Path]::GetTempPath()) ("csrun-release-" + [guid]::NewGuid().ToString("N") + ".ps1") +$engineBytes = [Convert]::FromBase64String([Console]::In.ReadLine()) +[IO.File]::WriteAllBytes($enginePath, $engineBytes) +$manifest = [Console]::In.ReadToEnd() +& $enginePath -ManifestJson $manifest +exit $LASTEXITCODE +' +$output = (@($containerInput | & docker run --rm -i --entrypoint pwsh 'codebeltnet/csrun:10' -NoProfile -NonInteractive -Command $command) -join [Environment]::NewLine) +$process = [pscustomobject]@{ ExitCode = $LASTEXITCODE } +$diagnostics = '' +Write-Output $output +} catch { + [Console]::Error.WriteLine("csrun diagnostics retained in: $engineDirectory") + throw +} finally { + $resolvedTemp = [IO.Path]::TrimEndingDirectorySeparator([IO.Path]::GetFullPath([IO.Path]::GetTempPath())) + $resolvedEngineDirectory = [IO.Path]::GetFullPath($engineDirectory) + if ([IO.Path]::GetDirectoryName($resolvedEngineDirectory) -ne $resolvedTemp -or + [IO.Path]::GetFileName($resolvedEngineDirectory) -cnotmatch '^csrun-[a-f0-9]{32}$') { throw 'Unsafe cleanup path.' } + if ($process -and $process.ExitCode -eq 0) { Remove-Item -LiteralPath $resolvedEngineDirectory -Recurse -Force } +} +if ($process.ExitCode -ne 0) { throw "csrun execution failed with exit code $($process.ExitCode). $diagnostics" } +if ($verifyTests) { Assert-CsrunTestOutput $output } +} \ No newline at end of file diff --git a/.docfx/run-actions/947406357e3e26b26a71a538/native.ps1 b/.docfx/run-actions/947406357e3e26b26a71a538/native.ps1 new file mode 100644 index 0000000..6774e6c --- /dev/null +++ b/.docfx/run-actions/947406357e3e26b26a71a538/native.ps1 @@ -0,0 +1,90 @@ +& { +#requires -Version 7.0 +$ErrorActionPreference = 'Stop' +$PSNativeCommandUseErrorActionPreference = $false +$manifest = @' +{ + "dependsOn": [ + "Codebelt.Extensions.Xunit.Hosting.AspNetCore@13.0.0", + "Microsoft.Extensions.Hosting@10.0.15", + "Microsoft.AspNetCore.TestHost@10.0.15" + ], + "framework": "net10.0", + "frameworkReferences": [ + "Microsoft.AspNetCore.App" + ], + "mode": "console", + "schemaVersion": 1, + "sdk": "Microsoft.NET.Sdk.Web", + "source": "using System;\nusing System.Net.Http;\nusing System.Threading.Tasks;\nusing Codebelt.Extensions.Xunit.Hosting.AspNetCore;\nusing Microsoft.AspNetCore.Builder;\nusing Microsoft.AspNetCore.TestHost;\n\nnamespace WebFixtureTests;\n\npublic class HttpClientExample\n{\n public async Task DemonstrateAsync(HttpClient client)\n {\n var response = await client.ToHttpResponseMessageAsync().ConfigureAwait(false);\n Console.WriteLine(response.StatusCode);\n }\n}\n\ninternal static class RunExample\n{\n static async Task Main()\n {\n using var app = WebHostTestFactory.Create(pipelineSetup: app => app.Run(context =>\n {\n context.Response.StatusCode = 202;\n return Task.CompletedTask;\n }));\n using var client = app.Host.GetTestClient();\n await new HttpClientExample().DemonstrateAsync(client);\n }\n}" +} +'@ +$OutputEncoding = [Text.UTF8Encoding]::new($false) +[Console]::OutputEncoding = $OutputEncoding +$verifyTests = $false +function Assert-CsrunTestOutput([string] $Output) { + $lines = @($Output -split '\r?\n') + $headers = @($lines | Where-Object { $_ -match '^Test run summary: Passed! - .+\)$' }) + if ($headers.Count -ne 1) { throw 'Expected exactly one completed xUnit test summary.' } + $headerIndex = [Array]::IndexOf($lines, $headers[0]) + $summaryLines = @($lines | Select-Object -Skip ($headerIndex + 1) -First 4) + $counts = @{} + foreach ($line in $summaryLines) { + if ($line -match '^\s*(total|failed|succeeded|skipped):\s*(\d+)\s*$') { $counts[$Matches[1]] = [int]$Matches[2] } + } + if ($counts.Count -ne 4) { throw 'The xUnit test summary counts are incomplete or ambiguous.' } + $failed = $counts.failed + $passed = $counts.succeeded + $skipped = $counts.skipped + $total = $counts.total + if ($total -lt 1 -or $passed -lt 1 -or $failed -ne 0 -or $skipped -ne 0 -or $passed -ne $total) { + throw 'Tests must execute at least once, all pass, and none fail or skip.' + } +} +# Downloads and executes the latest stable csrun release with your permissions. +# Source and release history: https://github.com/codebeltnet/csrun +$engineDirectory = Join-Path ([IO.Path]::GetTempPath()) ('csrun-' + [guid]::NewGuid().ToString('N')) +$null = New-Item -ItemType Directory -Path $engineDirectory +$enginePath = Join-Path $engineDirectory 'csrun.ps1' +$process = $null +try { + $release = Invoke-RestMethod 'https://api.github.com/repos/codebeltnet/csrun/releases/latest' + $assets = @($release.assets | Where-Object name -CEQ 'csrun.ps1') + if ($assets.Count -ne 1 -or $assets[0].digest -notmatch '^sha256:[0-9a-f]{64}$') { + throw "csrun release $($release.tag_name) must publish one csrun.ps1 asset with a SHA-256 digest." + } + $asset = $assets[0] + Invoke-WebRequest $asset.browser_download_url -OutFile $enginePath + $actualHash = (Get-FileHash -LiteralPath $enginePath -Algorithm SHA256).Hash + if ("sha256:$actualHash" -ne $asset.digest) { throw "csrun asset checksum mismatch: $actualHash" } +$startInfo = [Diagnostics.ProcessStartInfo]::new('pwsh') +foreach ($argument in @('-NoProfile','-NonInteractive','-File')) { $startInfo.ArgumentList.Add($argument) } +$startInfo.ArgumentList.Add($enginePath) +$startInfo.ArgumentList.Add('-ManifestJson') +$startInfo.ArgumentList.Add($manifest) +$startInfo.RedirectStandardOutput = $true +$startInfo.RedirectStandardError = $true +$startInfo.UseShellExecute = $false +$process = [Diagnostics.Process]::new() +$process.StartInfo = $startInfo +if (-not $process.Start()) { throw 'Could not start csrun.' } +$stdoutTask = $process.StandardOutput.ReadToEndAsync() +$stderrTask = $process.StandardError.ReadToEndAsync() +$process.WaitForExit() +$output = $stdoutTask.GetAwaiter().GetResult() +$diagnostics = $stderrTask.GetAwaiter().GetResult() +Write-Output $output +if ($diagnostics) { [Console]::Error.Write($diagnostics) } +} catch { + [Console]::Error.WriteLine("csrun diagnostics retained in: $engineDirectory") + throw +} finally { + $resolvedTemp = [IO.Path]::TrimEndingDirectorySeparator([IO.Path]::GetFullPath([IO.Path]::GetTempPath())) + $resolvedEngineDirectory = [IO.Path]::GetFullPath($engineDirectory) + if ([IO.Path]::GetDirectoryName($resolvedEngineDirectory) -ne $resolvedTemp -or + [IO.Path]::GetFileName($resolvedEngineDirectory) -cnotmatch '^csrun-[a-f0-9]{32}$') { throw 'Unsafe cleanup path.' } + if ($process -and $process.ExitCode -eq 0) { Remove-Item -LiteralPath $resolvedEngineDirectory -Recurse -Force } +} +if ($process.ExitCode -ne 0) { throw "csrun execution failed with exit code $($process.ExitCode). $diagnostics" } +if ($verifyTests) { Assert-CsrunTestOutput $output } +} \ No newline at end of file diff --git a/.docfx/run-actions/9a558a9a581c6b11ccb28057/docker.ps1 b/.docfx/run-actions/9a558a9a581c6b11ccb28057/docker.ps1 new file mode 100644 index 0000000..13e5465 --- /dev/null +++ b/.docfx/run-actions/9a558a9a581c6b11ccb28057/docker.ps1 @@ -0,0 +1,83 @@ +& { +#requires -Version 7.0 +$ErrorActionPreference = 'Stop' +$PSNativeCommandUseErrorActionPreference = $false +$manifest = @' +{ + "dependsOn": [ + "Codebelt.Extensions.Xunit.Hosting@13.0.0", + "Microsoft.Extensions.Hosting@10.0.15", + "xunit.v3@4.0.3" + ], + "framework": "net10.0", + "mode": "test", + "schemaVersion": 1, + "source": "using Codebelt.Extensions.Xunit.Hosting;\nusing Microsoft.Extensions.Logging;\nusing Xunit;\n\nnamespace HostFixtureTests;\n\npublic class LogEntryExample\n{\n public string FormatEntry()\n {\n var entry = new XunitTestLoggerEntry(LogLevel.Warning, new EventId(1001, \"MyEvent\"), \"Something unexpected happened.\");\n return entry.ToString();\n }\n}\n\npublic sealed class RunExample\n{\n [Fact]\n public void ExercisesExample()\n {\n Assert.Equal(\"Something unexpected happened.\", new LogEntryExample().FormatEntry());\n }\n}" +} +'@ +$OutputEncoding = [Text.UTF8Encoding]::new($false) +[Console]::OutputEncoding = $OutputEncoding +$verifyTests = $true +function Assert-CsrunTestOutput([string] $Output) { + $lines = @($Output -split '\r?\n') + $headers = @($lines | Where-Object { $_ -match '^Test run summary: Passed! - .+\)$' }) + if ($headers.Count -ne 1) { throw 'Expected exactly one completed xUnit test summary.' } + $headerIndex = [Array]::IndexOf($lines, $headers[0]) + $summaryLines = @($lines | Select-Object -Skip ($headerIndex + 1) -First 4) + $counts = @{} + foreach ($line in $summaryLines) { + if ($line -match '^\s*(total|failed|succeeded|skipped):\s*(\d+)\s*$') { $counts[$Matches[1]] = [int]$Matches[2] } + } + if ($counts.Count -ne 4) { throw 'The xUnit test summary counts are incomplete or ambiguous.' } + $failed = $counts.failed + $passed = $counts.succeeded + $skipped = $counts.skipped + $total = $counts.total + if ($total -lt 1 -or $passed -lt 1 -or $failed -ne 0 -or $skipped -ne 0 -or $passed -ne $total) { + throw 'Tests must execute at least once, all pass, and none fail or skip.' + } +} +# Downloads and executes the latest stable csrun release with your permissions. +# Source and release history: https://github.com/codebeltnet/csrun +$engineDirectory = Join-Path ([IO.Path]::GetTempPath()) ('csrun-' + [guid]::NewGuid().ToString('N')) +$null = New-Item -ItemType Directory -Path $engineDirectory +$enginePath = Join-Path $engineDirectory 'csrun.ps1' +$process = $null +try { + $release = Invoke-RestMethod 'https://api.github.com/repos/codebeltnet/csrun/releases/latest' + $assets = @($release.assets | Where-Object name -CEQ 'csrun.ps1') + if ($assets.Count -ne 1 -or $assets[0].digest -notmatch '^sha256:[0-9a-f]{64}$') { + throw "csrun release $($release.tag_name) must publish one csrun.ps1 asset with a SHA-256 digest." + } + $asset = $assets[0] + Invoke-WebRequest $asset.browser_download_url -OutFile $enginePath + $actualHash = (Get-FileHash -LiteralPath $enginePath -Algorithm SHA256).Hash + if ("sha256:$actualHash" -ne $asset.digest) { throw "csrun asset checksum mismatch: $actualHash" } +$enginePayload = [Convert]::ToBase64String([IO.File]::ReadAllBytes($enginePath)) +$containerInput = $enginePayload + "`n" + $manifest +$command = ' +$ErrorActionPreference = "Stop" +$enginePath = Join-Path ([IO.Path]::GetTempPath()) ("csrun-release-" + [guid]::NewGuid().ToString("N") + ".ps1") +$engineBytes = [Convert]::FromBase64String([Console]::In.ReadLine()) +[IO.File]::WriteAllBytes($enginePath, $engineBytes) +$manifest = [Console]::In.ReadToEnd() +& $enginePath -ManifestJson $manifest +exit $LASTEXITCODE +' +$output = (@($containerInput | & docker run --rm -i --entrypoint pwsh 'codebeltnet/csrun:10' -NoProfile -NonInteractive -Command $command) -join [Environment]::NewLine) +$process = [pscustomobject]@{ ExitCode = $LASTEXITCODE } +$diagnostics = '' +Write-Output $output +} catch { + [Console]::Error.WriteLine("csrun diagnostics retained in: $engineDirectory") + throw +} finally { + $resolvedTemp = [IO.Path]::TrimEndingDirectorySeparator([IO.Path]::GetFullPath([IO.Path]::GetTempPath())) + $resolvedEngineDirectory = [IO.Path]::GetFullPath($engineDirectory) + if ([IO.Path]::GetDirectoryName($resolvedEngineDirectory) -ne $resolvedTemp -or + [IO.Path]::GetFileName($resolvedEngineDirectory) -cnotmatch '^csrun-[a-f0-9]{32}$') { throw 'Unsafe cleanup path.' } + if ($process -and $process.ExitCode -eq 0) { Remove-Item -LiteralPath $resolvedEngineDirectory -Recurse -Force } +} +if ($process.ExitCode -ne 0) { throw "csrun execution failed with exit code $($process.ExitCode). $diagnostics" } +if ($verifyTests) { Assert-CsrunTestOutput $output } +} \ No newline at end of file diff --git a/.docfx/run-actions/9a558a9a581c6b11ccb28057/native.ps1 b/.docfx/run-actions/9a558a9a581c6b11ccb28057/native.ps1 new file mode 100644 index 0000000..0e2d591 --- /dev/null +++ b/.docfx/run-actions/9a558a9a581c6b11ccb28057/native.ps1 @@ -0,0 +1,86 @@ +& { +#requires -Version 7.0 +$ErrorActionPreference = 'Stop' +$PSNativeCommandUseErrorActionPreference = $false +$manifest = @' +{ + "dependsOn": [ + "Codebelt.Extensions.Xunit.Hosting@13.0.0", + "Microsoft.Extensions.Hosting@10.0.15", + "xunit.v3@4.0.3" + ], + "framework": "net10.0", + "mode": "test", + "schemaVersion": 1, + "source": "using Codebelt.Extensions.Xunit.Hosting;\nusing Microsoft.Extensions.Logging;\nusing Xunit;\n\nnamespace HostFixtureTests;\n\npublic class LogEntryExample\n{\n public string FormatEntry()\n {\n var entry = new XunitTestLoggerEntry(LogLevel.Warning, new EventId(1001, \"MyEvent\"), \"Something unexpected happened.\");\n return entry.ToString();\n }\n}\n\npublic sealed class RunExample\n{\n [Fact]\n public void ExercisesExample()\n {\n Assert.Equal(\"Something unexpected happened.\", new LogEntryExample().FormatEntry());\n }\n}" +} +'@ +$OutputEncoding = [Text.UTF8Encoding]::new($false) +[Console]::OutputEncoding = $OutputEncoding +$verifyTests = $true +function Assert-CsrunTestOutput([string] $Output) { + $lines = @($Output -split '\r?\n') + $headers = @($lines | Where-Object { $_ -match '^Test run summary: Passed! - .+\)$' }) + if ($headers.Count -ne 1) { throw 'Expected exactly one completed xUnit test summary.' } + $headerIndex = [Array]::IndexOf($lines, $headers[0]) + $summaryLines = @($lines | Select-Object -Skip ($headerIndex + 1) -First 4) + $counts = @{} + foreach ($line in $summaryLines) { + if ($line -match '^\s*(total|failed|succeeded|skipped):\s*(\d+)\s*$') { $counts[$Matches[1]] = [int]$Matches[2] } + } + if ($counts.Count -ne 4) { throw 'The xUnit test summary counts are incomplete or ambiguous.' } + $failed = $counts.failed + $passed = $counts.succeeded + $skipped = $counts.skipped + $total = $counts.total + if ($total -lt 1 -or $passed -lt 1 -or $failed -ne 0 -or $skipped -ne 0 -or $passed -ne $total) { + throw 'Tests must execute at least once, all pass, and none fail or skip.' + } +} +# Downloads and executes the latest stable csrun release with your permissions. +# Source and release history: https://github.com/codebeltnet/csrun +$engineDirectory = Join-Path ([IO.Path]::GetTempPath()) ('csrun-' + [guid]::NewGuid().ToString('N')) +$null = New-Item -ItemType Directory -Path $engineDirectory +$enginePath = Join-Path $engineDirectory 'csrun.ps1' +$process = $null +try { + $release = Invoke-RestMethod 'https://api.github.com/repos/codebeltnet/csrun/releases/latest' + $assets = @($release.assets | Where-Object name -CEQ 'csrun.ps1') + if ($assets.Count -ne 1 -or $assets[0].digest -notmatch '^sha256:[0-9a-f]{64}$') { + throw "csrun release $($release.tag_name) must publish one csrun.ps1 asset with a SHA-256 digest." + } + $asset = $assets[0] + Invoke-WebRequest $asset.browser_download_url -OutFile $enginePath + $actualHash = (Get-FileHash -LiteralPath $enginePath -Algorithm SHA256).Hash + if ("sha256:$actualHash" -ne $asset.digest) { throw "csrun asset checksum mismatch: $actualHash" } +$startInfo = [Diagnostics.ProcessStartInfo]::new('pwsh') +foreach ($argument in @('-NoProfile','-NonInteractive','-File')) { $startInfo.ArgumentList.Add($argument) } +$startInfo.ArgumentList.Add($enginePath) +$startInfo.ArgumentList.Add('-ManifestJson') +$startInfo.ArgumentList.Add($manifest) +$startInfo.RedirectStandardOutput = $true +$startInfo.RedirectStandardError = $true +$startInfo.UseShellExecute = $false +$process = [Diagnostics.Process]::new() +$process.StartInfo = $startInfo +if (-not $process.Start()) { throw 'Could not start csrun.' } +$stdoutTask = $process.StandardOutput.ReadToEndAsync() +$stderrTask = $process.StandardError.ReadToEndAsync() +$process.WaitForExit() +$output = $stdoutTask.GetAwaiter().GetResult() +$diagnostics = $stderrTask.GetAwaiter().GetResult() +Write-Output $output +if ($diagnostics) { [Console]::Error.Write($diagnostics) } +} catch { + [Console]::Error.WriteLine("csrun diagnostics retained in: $engineDirectory") + throw +} finally { + $resolvedTemp = [IO.Path]::TrimEndingDirectorySeparator([IO.Path]::GetFullPath([IO.Path]::GetTempPath())) + $resolvedEngineDirectory = [IO.Path]::GetFullPath($engineDirectory) + if ([IO.Path]::GetDirectoryName($resolvedEngineDirectory) -ne $resolvedTemp -or + [IO.Path]::GetFileName($resolvedEngineDirectory) -cnotmatch '^csrun-[a-f0-9]{32}$') { throw 'Unsafe cleanup path.' } + if ($process -and $process.ExitCode -eq 0) { Remove-Item -LiteralPath $resolvedEngineDirectory -Recurse -Force } +} +if ($process.ExitCode -ne 0) { throw "csrun execution failed with exit code $($process.ExitCode). $diagnostics" } +if ($verifyTests) { Assert-CsrunTestOutput $output } +} \ No newline at end of file diff --git a/.docfx/run-actions/9cdeb08f8ba8f3b361a98c58/docker.ps1 b/.docfx/run-actions/9cdeb08f8ba8f3b361a98c58/docker.ps1 new file mode 100644 index 0000000..453d21f --- /dev/null +++ b/.docfx/run-actions/9cdeb08f8ba8f3b361a98c58/docker.ps1 @@ -0,0 +1,83 @@ +& { +#requires -Version 7.0 +$ErrorActionPreference = 'Stop' +$PSNativeCommandUseErrorActionPreference = $false +$manifest = @' +{ + "dependsOn": [ + "Codebelt.Extensions.Xunit.Hosting@13.0.0", + "Microsoft.Extensions.Hosting@10.0.15", + "xunit.v3@4.0.3" + ], + "framework": "net10.0", + "mode": "test", + "schemaVersion": 1, + "source": "using Codebelt.Extensions.Xunit.Hosting;\nusing Microsoft.Extensions.DependencyInjection;\nusing Xunit;\n\nnamespace WorkerServices.Tests;\n\npublic sealed class HostTestFactoryExample\n{\n public string ResolveWorkerStatus()\n {\n using var host = HostTestFactory.Create(\n services => services.AddSingleton(new WorkerStatus(\"ready\")));\n\n var status = host.Host.Services.GetRequiredService();\n return status.Value;\n }\n}\n\npublic sealed record WorkerStatus(string Value);\n\npublic sealed class RunExample\n{\n [Fact]\n public void ExercisesExample()\n {\n Assert.Equal(\"ready\", new HostTestFactoryExample().ResolveWorkerStatus());\n }\n}" +} +'@ +$OutputEncoding = [Text.UTF8Encoding]::new($false) +[Console]::OutputEncoding = $OutputEncoding +$verifyTests = $true +function Assert-CsrunTestOutput([string] $Output) { + $lines = @($Output -split '\r?\n') + $headers = @($lines | Where-Object { $_ -match '^Test run summary: Passed! - .+\)$' }) + if ($headers.Count -ne 1) { throw 'Expected exactly one completed xUnit test summary.' } + $headerIndex = [Array]::IndexOf($lines, $headers[0]) + $summaryLines = @($lines | Select-Object -Skip ($headerIndex + 1) -First 4) + $counts = @{} + foreach ($line in $summaryLines) { + if ($line -match '^\s*(total|failed|succeeded|skipped):\s*(\d+)\s*$') { $counts[$Matches[1]] = [int]$Matches[2] } + } + if ($counts.Count -ne 4) { throw 'The xUnit test summary counts are incomplete or ambiguous.' } + $failed = $counts.failed + $passed = $counts.succeeded + $skipped = $counts.skipped + $total = $counts.total + if ($total -lt 1 -or $passed -lt 1 -or $failed -ne 0 -or $skipped -ne 0 -or $passed -ne $total) { + throw 'Tests must execute at least once, all pass, and none fail or skip.' + } +} +# Downloads and executes the latest stable csrun release with your permissions. +# Source and release history: https://github.com/codebeltnet/csrun +$engineDirectory = Join-Path ([IO.Path]::GetTempPath()) ('csrun-' + [guid]::NewGuid().ToString('N')) +$null = New-Item -ItemType Directory -Path $engineDirectory +$enginePath = Join-Path $engineDirectory 'csrun.ps1' +$process = $null +try { + $release = Invoke-RestMethod 'https://api.github.com/repos/codebeltnet/csrun/releases/latest' + $assets = @($release.assets | Where-Object name -CEQ 'csrun.ps1') + if ($assets.Count -ne 1 -or $assets[0].digest -notmatch '^sha256:[0-9a-f]{64}$') { + throw "csrun release $($release.tag_name) must publish one csrun.ps1 asset with a SHA-256 digest." + } + $asset = $assets[0] + Invoke-WebRequest $asset.browser_download_url -OutFile $enginePath + $actualHash = (Get-FileHash -LiteralPath $enginePath -Algorithm SHA256).Hash + if ("sha256:$actualHash" -ne $asset.digest) { throw "csrun asset checksum mismatch: $actualHash" } +$enginePayload = [Convert]::ToBase64String([IO.File]::ReadAllBytes($enginePath)) +$containerInput = $enginePayload + "`n" + $manifest +$command = ' +$ErrorActionPreference = "Stop" +$enginePath = Join-Path ([IO.Path]::GetTempPath()) ("csrun-release-" + [guid]::NewGuid().ToString("N") + ".ps1") +$engineBytes = [Convert]::FromBase64String([Console]::In.ReadLine()) +[IO.File]::WriteAllBytes($enginePath, $engineBytes) +$manifest = [Console]::In.ReadToEnd() +& $enginePath -ManifestJson $manifest +exit $LASTEXITCODE +' +$output = (@($containerInput | & docker run --rm -i --entrypoint pwsh 'codebeltnet/csrun:10' -NoProfile -NonInteractive -Command $command) -join [Environment]::NewLine) +$process = [pscustomobject]@{ ExitCode = $LASTEXITCODE } +$diagnostics = '' +Write-Output $output +} catch { + [Console]::Error.WriteLine("csrun diagnostics retained in: $engineDirectory") + throw +} finally { + $resolvedTemp = [IO.Path]::TrimEndingDirectorySeparator([IO.Path]::GetFullPath([IO.Path]::GetTempPath())) + $resolvedEngineDirectory = [IO.Path]::GetFullPath($engineDirectory) + if ([IO.Path]::GetDirectoryName($resolvedEngineDirectory) -ne $resolvedTemp -or + [IO.Path]::GetFileName($resolvedEngineDirectory) -cnotmatch '^csrun-[a-f0-9]{32}$') { throw 'Unsafe cleanup path.' } + if ($process -and $process.ExitCode -eq 0) { Remove-Item -LiteralPath $resolvedEngineDirectory -Recurse -Force } +} +if ($process.ExitCode -ne 0) { throw "csrun execution failed with exit code $($process.ExitCode). $diagnostics" } +if ($verifyTests) { Assert-CsrunTestOutput $output } +} \ No newline at end of file diff --git a/.docfx/run-actions/9cdeb08f8ba8f3b361a98c58/native.ps1 b/.docfx/run-actions/9cdeb08f8ba8f3b361a98c58/native.ps1 new file mode 100644 index 0000000..eeb9345 --- /dev/null +++ b/.docfx/run-actions/9cdeb08f8ba8f3b361a98c58/native.ps1 @@ -0,0 +1,86 @@ +& { +#requires -Version 7.0 +$ErrorActionPreference = 'Stop' +$PSNativeCommandUseErrorActionPreference = $false +$manifest = @' +{ + "dependsOn": [ + "Codebelt.Extensions.Xunit.Hosting@13.0.0", + "Microsoft.Extensions.Hosting@10.0.15", + "xunit.v3@4.0.3" + ], + "framework": "net10.0", + "mode": "test", + "schemaVersion": 1, + "source": "using Codebelt.Extensions.Xunit.Hosting;\nusing Microsoft.Extensions.DependencyInjection;\nusing Xunit;\n\nnamespace WorkerServices.Tests;\n\npublic sealed class HostTestFactoryExample\n{\n public string ResolveWorkerStatus()\n {\n using var host = HostTestFactory.Create(\n services => services.AddSingleton(new WorkerStatus(\"ready\")));\n\n var status = host.Host.Services.GetRequiredService();\n return status.Value;\n }\n}\n\npublic sealed record WorkerStatus(string Value);\n\npublic sealed class RunExample\n{\n [Fact]\n public void ExercisesExample()\n {\n Assert.Equal(\"ready\", new HostTestFactoryExample().ResolveWorkerStatus());\n }\n}" +} +'@ +$OutputEncoding = [Text.UTF8Encoding]::new($false) +[Console]::OutputEncoding = $OutputEncoding +$verifyTests = $true +function Assert-CsrunTestOutput([string] $Output) { + $lines = @($Output -split '\r?\n') + $headers = @($lines | Where-Object { $_ -match '^Test run summary: Passed! - .+\)$' }) + if ($headers.Count -ne 1) { throw 'Expected exactly one completed xUnit test summary.' } + $headerIndex = [Array]::IndexOf($lines, $headers[0]) + $summaryLines = @($lines | Select-Object -Skip ($headerIndex + 1) -First 4) + $counts = @{} + foreach ($line in $summaryLines) { + if ($line -match '^\s*(total|failed|succeeded|skipped):\s*(\d+)\s*$') { $counts[$Matches[1]] = [int]$Matches[2] } + } + if ($counts.Count -ne 4) { throw 'The xUnit test summary counts are incomplete or ambiguous.' } + $failed = $counts.failed + $passed = $counts.succeeded + $skipped = $counts.skipped + $total = $counts.total + if ($total -lt 1 -or $passed -lt 1 -or $failed -ne 0 -or $skipped -ne 0 -or $passed -ne $total) { + throw 'Tests must execute at least once, all pass, and none fail or skip.' + } +} +# Downloads and executes the latest stable csrun release with your permissions. +# Source and release history: https://github.com/codebeltnet/csrun +$engineDirectory = Join-Path ([IO.Path]::GetTempPath()) ('csrun-' + [guid]::NewGuid().ToString('N')) +$null = New-Item -ItemType Directory -Path $engineDirectory +$enginePath = Join-Path $engineDirectory 'csrun.ps1' +$process = $null +try { + $release = Invoke-RestMethod 'https://api.github.com/repos/codebeltnet/csrun/releases/latest' + $assets = @($release.assets | Where-Object name -CEQ 'csrun.ps1') + if ($assets.Count -ne 1 -or $assets[0].digest -notmatch '^sha256:[0-9a-f]{64}$') { + throw "csrun release $($release.tag_name) must publish one csrun.ps1 asset with a SHA-256 digest." + } + $asset = $assets[0] + Invoke-WebRequest $asset.browser_download_url -OutFile $enginePath + $actualHash = (Get-FileHash -LiteralPath $enginePath -Algorithm SHA256).Hash + if ("sha256:$actualHash" -ne $asset.digest) { throw "csrun asset checksum mismatch: $actualHash" } +$startInfo = [Diagnostics.ProcessStartInfo]::new('pwsh') +foreach ($argument in @('-NoProfile','-NonInteractive','-File')) { $startInfo.ArgumentList.Add($argument) } +$startInfo.ArgumentList.Add($enginePath) +$startInfo.ArgumentList.Add('-ManifestJson') +$startInfo.ArgumentList.Add($manifest) +$startInfo.RedirectStandardOutput = $true +$startInfo.RedirectStandardError = $true +$startInfo.UseShellExecute = $false +$process = [Diagnostics.Process]::new() +$process.StartInfo = $startInfo +if (-not $process.Start()) { throw 'Could not start csrun.' } +$stdoutTask = $process.StandardOutput.ReadToEndAsync() +$stderrTask = $process.StandardError.ReadToEndAsync() +$process.WaitForExit() +$output = $stdoutTask.GetAwaiter().GetResult() +$diagnostics = $stderrTask.GetAwaiter().GetResult() +Write-Output $output +if ($diagnostics) { [Console]::Error.Write($diagnostics) } +} catch { + [Console]::Error.WriteLine("csrun diagnostics retained in: $engineDirectory") + throw +} finally { + $resolvedTemp = [IO.Path]::TrimEndingDirectorySeparator([IO.Path]::GetFullPath([IO.Path]::GetTempPath())) + $resolvedEngineDirectory = [IO.Path]::GetFullPath($engineDirectory) + if ([IO.Path]::GetDirectoryName($resolvedEngineDirectory) -ne $resolvedTemp -or + [IO.Path]::GetFileName($resolvedEngineDirectory) -cnotmatch '^csrun-[a-f0-9]{32}$') { throw 'Unsafe cleanup path.' } + if ($process -and $process.ExitCode -eq 0) { Remove-Item -LiteralPath $resolvedEngineDirectory -Recurse -Force } +} +if ($process.ExitCode -ne 0) { throw "csrun execution failed with exit code $($process.ExitCode). $diagnostics" } +if ($verifyTests) { Assert-CsrunTestOutput $output } +} \ No newline at end of file diff --git a/.docfx/run-actions/a31971b360a8c557b87f6684/docker.ps1 b/.docfx/run-actions/a31971b360a8c557b87f6684/docker.ps1 new file mode 100644 index 0000000..c8e485a --- /dev/null +++ b/.docfx/run-actions/a31971b360a8c557b87f6684/docker.ps1 @@ -0,0 +1,82 @@ +& { +#requires -Version 7.0 +$ErrorActionPreference = 'Stop' +$PSNativeCommandUseErrorActionPreference = $false +$manifest = @' +{ + "dependsOn": [ + "Codebelt.Extensions.Xunit@13.0.0", + "xunit.v3@4.0.3" + ], + "framework": "net10.0", + "mode": "test", + "schemaVersion": 1, + "source": "using System.Linq;\nusing Codebelt.Extensions.Xunit;\nusing Xunit;\n\nnamespace Example.Tests;\n\npublic class StoreExample\n{\n public bool HasMatchingItem()\n {\n var store = new InMemoryTestStore();\n store.Add(\"cached\");\n store.Add(\"other\");\n return store.Count == 2 && store.Query(value => value == \"cached\").Single() == \"cached\";\n }\n}\n\npublic sealed class RunExample\n{\n [Fact]\n public void ExercisesExample()\n {\n Assert.True(new StoreExample().HasMatchingItem());\n }\n}" +} +'@ +$OutputEncoding = [Text.UTF8Encoding]::new($false) +[Console]::OutputEncoding = $OutputEncoding +$verifyTests = $true +function Assert-CsrunTestOutput([string] $Output) { + $lines = @($Output -split '\r?\n') + $headers = @($lines | Where-Object { $_ -match '^Test run summary: Passed! - .+\)$' }) + if ($headers.Count -ne 1) { throw 'Expected exactly one completed xUnit test summary.' } + $headerIndex = [Array]::IndexOf($lines, $headers[0]) + $summaryLines = @($lines | Select-Object -Skip ($headerIndex + 1) -First 4) + $counts = @{} + foreach ($line in $summaryLines) { + if ($line -match '^\s*(total|failed|succeeded|skipped):\s*(\d+)\s*$') { $counts[$Matches[1]] = [int]$Matches[2] } + } + if ($counts.Count -ne 4) { throw 'The xUnit test summary counts are incomplete or ambiguous.' } + $failed = $counts.failed + $passed = $counts.succeeded + $skipped = $counts.skipped + $total = $counts.total + if ($total -lt 1 -or $passed -lt 1 -or $failed -ne 0 -or $skipped -ne 0 -or $passed -ne $total) { + throw 'Tests must execute at least once, all pass, and none fail or skip.' + } +} +# Downloads and executes the latest stable csrun release with your permissions. +# Source and release history: https://github.com/codebeltnet/csrun +$engineDirectory = Join-Path ([IO.Path]::GetTempPath()) ('csrun-' + [guid]::NewGuid().ToString('N')) +$null = New-Item -ItemType Directory -Path $engineDirectory +$enginePath = Join-Path $engineDirectory 'csrun.ps1' +$process = $null +try { + $release = Invoke-RestMethod 'https://api.github.com/repos/codebeltnet/csrun/releases/latest' + $assets = @($release.assets | Where-Object name -CEQ 'csrun.ps1') + if ($assets.Count -ne 1 -or $assets[0].digest -notmatch '^sha256:[0-9a-f]{64}$') { + throw "csrun release $($release.tag_name) must publish one csrun.ps1 asset with a SHA-256 digest." + } + $asset = $assets[0] + Invoke-WebRequest $asset.browser_download_url -OutFile $enginePath + $actualHash = (Get-FileHash -LiteralPath $enginePath -Algorithm SHA256).Hash + if ("sha256:$actualHash" -ne $asset.digest) { throw "csrun asset checksum mismatch: $actualHash" } +$enginePayload = [Convert]::ToBase64String([IO.File]::ReadAllBytes($enginePath)) +$containerInput = $enginePayload + "`n" + $manifest +$command = ' +$ErrorActionPreference = "Stop" +$enginePath = Join-Path ([IO.Path]::GetTempPath()) ("csrun-release-" + [guid]::NewGuid().ToString("N") + ".ps1") +$engineBytes = [Convert]::FromBase64String([Console]::In.ReadLine()) +[IO.File]::WriteAllBytes($enginePath, $engineBytes) +$manifest = [Console]::In.ReadToEnd() +& $enginePath -ManifestJson $manifest +exit $LASTEXITCODE +' +$output = (@($containerInput | & docker run --rm -i --entrypoint pwsh 'codebeltnet/csrun:10' -NoProfile -NonInteractive -Command $command) -join [Environment]::NewLine) +$process = [pscustomobject]@{ ExitCode = $LASTEXITCODE } +$diagnostics = '' +Write-Output $output +} catch { + [Console]::Error.WriteLine("csrun diagnostics retained in: $engineDirectory") + throw +} finally { + $resolvedTemp = [IO.Path]::TrimEndingDirectorySeparator([IO.Path]::GetFullPath([IO.Path]::GetTempPath())) + $resolvedEngineDirectory = [IO.Path]::GetFullPath($engineDirectory) + if ([IO.Path]::GetDirectoryName($resolvedEngineDirectory) -ne $resolvedTemp -or + [IO.Path]::GetFileName($resolvedEngineDirectory) -cnotmatch '^csrun-[a-f0-9]{32}$') { throw 'Unsafe cleanup path.' } + if ($process -and $process.ExitCode -eq 0) { Remove-Item -LiteralPath $resolvedEngineDirectory -Recurse -Force } +} +if ($process.ExitCode -ne 0) { throw "csrun execution failed with exit code $($process.ExitCode). $diagnostics" } +if ($verifyTests) { Assert-CsrunTestOutput $output } +} \ No newline at end of file diff --git a/.docfx/run-actions/a31971b360a8c557b87f6684/native.ps1 b/.docfx/run-actions/a31971b360a8c557b87f6684/native.ps1 new file mode 100644 index 0000000..702bba8 --- /dev/null +++ b/.docfx/run-actions/a31971b360a8c557b87f6684/native.ps1 @@ -0,0 +1,85 @@ +& { +#requires -Version 7.0 +$ErrorActionPreference = 'Stop' +$PSNativeCommandUseErrorActionPreference = $false +$manifest = @' +{ + "dependsOn": [ + "Codebelt.Extensions.Xunit@13.0.0", + "xunit.v3@4.0.3" + ], + "framework": "net10.0", + "mode": "test", + "schemaVersion": 1, + "source": "using System.Linq;\nusing Codebelt.Extensions.Xunit;\nusing Xunit;\n\nnamespace Example.Tests;\n\npublic class StoreExample\n{\n public bool HasMatchingItem()\n {\n var store = new InMemoryTestStore();\n store.Add(\"cached\");\n store.Add(\"other\");\n return store.Count == 2 && store.Query(value => value == \"cached\").Single() == \"cached\";\n }\n}\n\npublic sealed class RunExample\n{\n [Fact]\n public void ExercisesExample()\n {\n Assert.True(new StoreExample().HasMatchingItem());\n }\n}" +} +'@ +$OutputEncoding = [Text.UTF8Encoding]::new($false) +[Console]::OutputEncoding = $OutputEncoding +$verifyTests = $true +function Assert-CsrunTestOutput([string] $Output) { + $lines = @($Output -split '\r?\n') + $headers = @($lines | Where-Object { $_ -match '^Test run summary: Passed! - .+\)$' }) + if ($headers.Count -ne 1) { throw 'Expected exactly one completed xUnit test summary.' } + $headerIndex = [Array]::IndexOf($lines, $headers[0]) + $summaryLines = @($lines | Select-Object -Skip ($headerIndex + 1) -First 4) + $counts = @{} + foreach ($line in $summaryLines) { + if ($line -match '^\s*(total|failed|succeeded|skipped):\s*(\d+)\s*$') { $counts[$Matches[1]] = [int]$Matches[2] } + } + if ($counts.Count -ne 4) { throw 'The xUnit test summary counts are incomplete or ambiguous.' } + $failed = $counts.failed + $passed = $counts.succeeded + $skipped = $counts.skipped + $total = $counts.total + if ($total -lt 1 -or $passed -lt 1 -or $failed -ne 0 -or $skipped -ne 0 -or $passed -ne $total) { + throw 'Tests must execute at least once, all pass, and none fail or skip.' + } +} +# Downloads and executes the latest stable csrun release with your permissions. +# Source and release history: https://github.com/codebeltnet/csrun +$engineDirectory = Join-Path ([IO.Path]::GetTempPath()) ('csrun-' + [guid]::NewGuid().ToString('N')) +$null = New-Item -ItemType Directory -Path $engineDirectory +$enginePath = Join-Path $engineDirectory 'csrun.ps1' +$process = $null +try { + $release = Invoke-RestMethod 'https://api.github.com/repos/codebeltnet/csrun/releases/latest' + $assets = @($release.assets | Where-Object name -CEQ 'csrun.ps1') + if ($assets.Count -ne 1 -or $assets[0].digest -notmatch '^sha256:[0-9a-f]{64}$') { + throw "csrun release $($release.tag_name) must publish one csrun.ps1 asset with a SHA-256 digest." + } + $asset = $assets[0] + Invoke-WebRequest $asset.browser_download_url -OutFile $enginePath + $actualHash = (Get-FileHash -LiteralPath $enginePath -Algorithm SHA256).Hash + if ("sha256:$actualHash" -ne $asset.digest) { throw "csrun asset checksum mismatch: $actualHash" } +$startInfo = [Diagnostics.ProcessStartInfo]::new('pwsh') +foreach ($argument in @('-NoProfile','-NonInteractive','-File')) { $startInfo.ArgumentList.Add($argument) } +$startInfo.ArgumentList.Add($enginePath) +$startInfo.ArgumentList.Add('-ManifestJson') +$startInfo.ArgumentList.Add($manifest) +$startInfo.RedirectStandardOutput = $true +$startInfo.RedirectStandardError = $true +$startInfo.UseShellExecute = $false +$process = [Diagnostics.Process]::new() +$process.StartInfo = $startInfo +if (-not $process.Start()) { throw 'Could not start csrun.' } +$stdoutTask = $process.StandardOutput.ReadToEndAsync() +$stderrTask = $process.StandardError.ReadToEndAsync() +$process.WaitForExit() +$output = $stdoutTask.GetAwaiter().GetResult() +$diagnostics = $stderrTask.GetAwaiter().GetResult() +Write-Output $output +if ($diagnostics) { [Console]::Error.Write($diagnostics) } +} catch { + [Console]::Error.WriteLine("csrun diagnostics retained in: $engineDirectory") + throw +} finally { + $resolvedTemp = [IO.Path]::TrimEndingDirectorySeparator([IO.Path]::GetFullPath([IO.Path]::GetTempPath())) + $resolvedEngineDirectory = [IO.Path]::GetFullPath($engineDirectory) + if ([IO.Path]::GetDirectoryName($resolvedEngineDirectory) -ne $resolvedTemp -or + [IO.Path]::GetFileName($resolvedEngineDirectory) -cnotmatch '^csrun-[a-f0-9]{32}$') { throw 'Unsafe cleanup path.' } + if ($process -and $process.ExitCode -eq 0) { Remove-Item -LiteralPath $resolvedEngineDirectory -Recurse -Force } +} +if ($process.ExitCode -ne 0) { throw "csrun execution failed with exit code $($process.ExitCode). $diagnostics" } +if ($verifyTests) { Assert-CsrunTestOutput $output } +} \ No newline at end of file diff --git a/.docfx/run-actions/aa478d74f298d8c98e6cd1bf/docker.ps1 b/.docfx/run-actions/aa478d74f298d8c98e6cd1bf/docker.ps1 new file mode 100644 index 0000000..e23a36b --- /dev/null +++ b/.docfx/run-actions/aa478d74f298d8c98e6cd1bf/docker.ps1 @@ -0,0 +1,83 @@ +& { +#requires -Version 7.0 +$ErrorActionPreference = 'Stop' +$PSNativeCommandUseErrorActionPreference = $false +$manifest = @' +{ + "dependsOn": [ + "Codebelt.Extensions.Xunit.Hosting@13.0.0", + "Microsoft.Extensions.Hosting@10.0.15", + "xunit.v3@4.0.3" + ], + "framework": "net10.0", + "mode": "test", + "schemaVersion": 1, + "source": "using System.Threading;\nusing System.Threading.Tasks;\nusing Codebelt.Extensions.Xunit.Hosting;\nusing Microsoft.Extensions.DependencyInjection;\nusing Microsoft.Extensions.Hosting;\nusing Xunit;\n\nnamespace HostFixtureTests;\n\npublic class BackgroundServiceTest : HostTest\n{\n public BackgroundServiceTest(ManagedHostFixture hostFixture, ITestOutputHelper output) : base(hostFixture, output)\n {\n }\n\n public override void ConfigureServices(IServiceCollection services)\n {\n services.AddHostedService();\n services.AddXunitTestLogging();\n }\n\n [Fact]\n public void Host_ShouldBeRunning()\n {\n Assert.NotNull(Host);\n }\n}\n\npublic class TestWorker : BackgroundService\n{\n protected override async Task ExecuteAsync(CancellationToken stoppingToken)\n {\n while (!stoppingToken.IsCancellationRequested)\n {\n await Task.Delay(100, stoppingToken);\n }\n }\n}" +} +'@ +$OutputEncoding = [Text.UTF8Encoding]::new($false) +[Console]::OutputEncoding = $OutputEncoding +$verifyTests = $true +function Assert-CsrunTestOutput([string] $Output) { + $lines = @($Output -split '\r?\n') + $headers = @($lines | Where-Object { $_ -match '^Test run summary: Passed! - .+\)$' }) + if ($headers.Count -ne 1) { throw 'Expected exactly one completed xUnit test summary.' } + $headerIndex = [Array]::IndexOf($lines, $headers[0]) + $summaryLines = @($lines | Select-Object -Skip ($headerIndex + 1) -First 4) + $counts = @{} + foreach ($line in $summaryLines) { + if ($line -match '^\s*(total|failed|succeeded|skipped):\s*(\d+)\s*$') { $counts[$Matches[1]] = [int]$Matches[2] } + } + if ($counts.Count -ne 4) { throw 'The xUnit test summary counts are incomplete or ambiguous.' } + $failed = $counts.failed + $passed = $counts.succeeded + $skipped = $counts.skipped + $total = $counts.total + if ($total -lt 1 -or $passed -lt 1 -or $failed -ne 0 -or $skipped -ne 0 -or $passed -ne $total) { + throw 'Tests must execute at least once, all pass, and none fail or skip.' + } +} +# Downloads and executes the latest stable csrun release with your permissions. +# Source and release history: https://github.com/codebeltnet/csrun +$engineDirectory = Join-Path ([IO.Path]::GetTempPath()) ('csrun-' + [guid]::NewGuid().ToString('N')) +$null = New-Item -ItemType Directory -Path $engineDirectory +$enginePath = Join-Path $engineDirectory 'csrun.ps1' +$process = $null +try { + $release = Invoke-RestMethod 'https://api.github.com/repos/codebeltnet/csrun/releases/latest' + $assets = @($release.assets | Where-Object name -CEQ 'csrun.ps1') + if ($assets.Count -ne 1 -or $assets[0].digest -notmatch '^sha256:[0-9a-f]{64}$') { + throw "csrun release $($release.tag_name) must publish one csrun.ps1 asset with a SHA-256 digest." + } + $asset = $assets[0] + Invoke-WebRequest $asset.browser_download_url -OutFile $enginePath + $actualHash = (Get-FileHash -LiteralPath $enginePath -Algorithm SHA256).Hash + if ("sha256:$actualHash" -ne $asset.digest) { throw "csrun asset checksum mismatch: $actualHash" } +$enginePayload = [Convert]::ToBase64String([IO.File]::ReadAllBytes($enginePath)) +$containerInput = $enginePayload + "`n" + $manifest +$command = ' +$ErrorActionPreference = "Stop" +$enginePath = Join-Path ([IO.Path]::GetTempPath()) ("csrun-release-" + [guid]::NewGuid().ToString("N") + ".ps1") +$engineBytes = [Convert]::FromBase64String([Console]::In.ReadLine()) +[IO.File]::WriteAllBytes($enginePath, $engineBytes) +$manifest = [Console]::In.ReadToEnd() +& $enginePath -ManifestJson $manifest +exit $LASTEXITCODE +' +$output = (@($containerInput | & docker run --rm -i --entrypoint pwsh 'codebeltnet/csrun:10' -NoProfile -NonInteractive -Command $command) -join [Environment]::NewLine) +$process = [pscustomobject]@{ ExitCode = $LASTEXITCODE } +$diagnostics = '' +Write-Output $output +} catch { + [Console]::Error.WriteLine("csrun diagnostics retained in: $engineDirectory") + throw +} finally { + $resolvedTemp = [IO.Path]::TrimEndingDirectorySeparator([IO.Path]::GetFullPath([IO.Path]::GetTempPath())) + $resolvedEngineDirectory = [IO.Path]::GetFullPath($engineDirectory) + if ([IO.Path]::GetDirectoryName($resolvedEngineDirectory) -ne $resolvedTemp -or + [IO.Path]::GetFileName($resolvedEngineDirectory) -cnotmatch '^csrun-[a-f0-9]{32}$') { throw 'Unsafe cleanup path.' } + if ($process -and $process.ExitCode -eq 0) { Remove-Item -LiteralPath $resolvedEngineDirectory -Recurse -Force } +} +if ($process.ExitCode -ne 0) { throw "csrun execution failed with exit code $($process.ExitCode). $diagnostics" } +if ($verifyTests) { Assert-CsrunTestOutput $output } +} \ No newline at end of file diff --git a/.docfx/run-actions/aa478d74f298d8c98e6cd1bf/native.ps1 b/.docfx/run-actions/aa478d74f298d8c98e6cd1bf/native.ps1 new file mode 100644 index 0000000..cc2a267 --- /dev/null +++ b/.docfx/run-actions/aa478d74f298d8c98e6cd1bf/native.ps1 @@ -0,0 +1,86 @@ +& { +#requires -Version 7.0 +$ErrorActionPreference = 'Stop' +$PSNativeCommandUseErrorActionPreference = $false +$manifest = @' +{ + "dependsOn": [ + "Codebelt.Extensions.Xunit.Hosting@13.0.0", + "Microsoft.Extensions.Hosting@10.0.15", + "xunit.v3@4.0.3" + ], + "framework": "net10.0", + "mode": "test", + "schemaVersion": 1, + "source": "using System.Threading;\nusing System.Threading.Tasks;\nusing Codebelt.Extensions.Xunit.Hosting;\nusing Microsoft.Extensions.DependencyInjection;\nusing Microsoft.Extensions.Hosting;\nusing Xunit;\n\nnamespace HostFixtureTests;\n\npublic class BackgroundServiceTest : HostTest\n{\n public BackgroundServiceTest(ManagedHostFixture hostFixture, ITestOutputHelper output) : base(hostFixture, output)\n {\n }\n\n public override void ConfigureServices(IServiceCollection services)\n {\n services.AddHostedService();\n services.AddXunitTestLogging();\n }\n\n [Fact]\n public void Host_ShouldBeRunning()\n {\n Assert.NotNull(Host);\n }\n}\n\npublic class TestWorker : BackgroundService\n{\n protected override async Task ExecuteAsync(CancellationToken stoppingToken)\n {\n while (!stoppingToken.IsCancellationRequested)\n {\n await Task.Delay(100, stoppingToken);\n }\n }\n}" +} +'@ +$OutputEncoding = [Text.UTF8Encoding]::new($false) +[Console]::OutputEncoding = $OutputEncoding +$verifyTests = $true +function Assert-CsrunTestOutput([string] $Output) { + $lines = @($Output -split '\r?\n') + $headers = @($lines | Where-Object { $_ -match '^Test run summary: Passed! - .+\)$' }) + if ($headers.Count -ne 1) { throw 'Expected exactly one completed xUnit test summary.' } + $headerIndex = [Array]::IndexOf($lines, $headers[0]) + $summaryLines = @($lines | Select-Object -Skip ($headerIndex + 1) -First 4) + $counts = @{} + foreach ($line in $summaryLines) { + if ($line -match '^\s*(total|failed|succeeded|skipped):\s*(\d+)\s*$') { $counts[$Matches[1]] = [int]$Matches[2] } + } + if ($counts.Count -ne 4) { throw 'The xUnit test summary counts are incomplete or ambiguous.' } + $failed = $counts.failed + $passed = $counts.succeeded + $skipped = $counts.skipped + $total = $counts.total + if ($total -lt 1 -or $passed -lt 1 -or $failed -ne 0 -or $skipped -ne 0 -or $passed -ne $total) { + throw 'Tests must execute at least once, all pass, and none fail or skip.' + } +} +# Downloads and executes the latest stable csrun release with your permissions. +# Source and release history: https://github.com/codebeltnet/csrun +$engineDirectory = Join-Path ([IO.Path]::GetTempPath()) ('csrun-' + [guid]::NewGuid().ToString('N')) +$null = New-Item -ItemType Directory -Path $engineDirectory +$enginePath = Join-Path $engineDirectory 'csrun.ps1' +$process = $null +try { + $release = Invoke-RestMethod 'https://api.github.com/repos/codebeltnet/csrun/releases/latest' + $assets = @($release.assets | Where-Object name -CEQ 'csrun.ps1') + if ($assets.Count -ne 1 -or $assets[0].digest -notmatch '^sha256:[0-9a-f]{64}$') { + throw "csrun release $($release.tag_name) must publish one csrun.ps1 asset with a SHA-256 digest." + } + $asset = $assets[0] + Invoke-WebRequest $asset.browser_download_url -OutFile $enginePath + $actualHash = (Get-FileHash -LiteralPath $enginePath -Algorithm SHA256).Hash + if ("sha256:$actualHash" -ne $asset.digest) { throw "csrun asset checksum mismatch: $actualHash" } +$startInfo = [Diagnostics.ProcessStartInfo]::new('pwsh') +foreach ($argument in @('-NoProfile','-NonInteractive','-File')) { $startInfo.ArgumentList.Add($argument) } +$startInfo.ArgumentList.Add($enginePath) +$startInfo.ArgumentList.Add('-ManifestJson') +$startInfo.ArgumentList.Add($manifest) +$startInfo.RedirectStandardOutput = $true +$startInfo.RedirectStandardError = $true +$startInfo.UseShellExecute = $false +$process = [Diagnostics.Process]::new() +$process.StartInfo = $startInfo +if (-not $process.Start()) { throw 'Could not start csrun.' } +$stdoutTask = $process.StandardOutput.ReadToEndAsync() +$stderrTask = $process.StandardError.ReadToEndAsync() +$process.WaitForExit() +$output = $stdoutTask.GetAwaiter().GetResult() +$diagnostics = $stderrTask.GetAwaiter().GetResult() +Write-Output $output +if ($diagnostics) { [Console]::Error.Write($diagnostics) } +} catch { + [Console]::Error.WriteLine("csrun diagnostics retained in: $engineDirectory") + throw +} finally { + $resolvedTemp = [IO.Path]::TrimEndingDirectorySeparator([IO.Path]::GetFullPath([IO.Path]::GetTempPath())) + $resolvedEngineDirectory = [IO.Path]::GetFullPath($engineDirectory) + if ([IO.Path]::GetDirectoryName($resolvedEngineDirectory) -ne $resolvedTemp -or + [IO.Path]::GetFileName($resolvedEngineDirectory) -cnotmatch '^csrun-[a-f0-9]{32}$') { throw 'Unsafe cleanup path.' } + if ($process -and $process.ExitCode -eq 0) { Remove-Item -LiteralPath $resolvedEngineDirectory -Recurse -Force } +} +if ($process.ExitCode -ne 0) { throw "csrun execution failed with exit code $($process.ExitCode). $diagnostics" } +if ($verifyTests) { Assert-CsrunTestOutput $output } +} \ No newline at end of file diff --git a/.docfx/run-actions/b4149382f121a5ffc3c057df/docker.ps1 b/.docfx/run-actions/b4149382f121a5ffc3c057df/docker.ps1 new file mode 100644 index 0000000..efb5ce6 --- /dev/null +++ b/.docfx/run-actions/b4149382f121a5ffc3c057df/docker.ps1 @@ -0,0 +1,83 @@ +& { +#requires -Version 7.0 +$ErrorActionPreference = 'Stop' +$PSNativeCommandUseErrorActionPreference = $false +$manifest = @' +{ + "dependsOn": [ + "Codebelt.Extensions.Xunit.Hosting@13.0.0", + "Microsoft.Extensions.Hosting@10.0.15", + "xunit.v3@4.0.3" + ], + "framework": "net10.0", + "mode": "test", + "schemaVersion": 1, + "source": "using System.Threading.Tasks;\nusing Codebelt.Extensions.Xunit.Hosting;\nusing Microsoft.Extensions.DependencyInjection;\nusing Xunit;\n\nnamespace MinimalWorkerLifecycle.Tests;\n\npublic sealed class SelfManagedMinimalHostFixtureExample\n{\n public async Task ConfigureBeforeStartingAsync()\n {\n using var host = MinimalHostTestFactory.Create(\n services => services.AddSingleton(new StartupState(\"configured\")),\n hostFixture: new SelfManagedMinimalHostFixture());\n\n var beforeStart = host.Host.Services.GetRequiredService();\n Assert.Equal(\"configured\", beforeStart.Value);\n\n await host.Host.StartAsync().ConfigureAwait(false);\n\n var afterStart = host.Host.Services.GetRequiredService();\n Assert.Same(beforeStart, afterStart);\n }\n}\n\npublic sealed record StartupState(string Value);\n\npublic sealed class RunExample\n{\n [Fact]\n public async Task ExercisesExample()\n {\n await new SelfManagedMinimalHostFixtureExample().ConfigureBeforeStartingAsync();\n }\n}" +} +'@ +$OutputEncoding = [Text.UTF8Encoding]::new($false) +[Console]::OutputEncoding = $OutputEncoding +$verifyTests = $true +function Assert-CsrunTestOutput([string] $Output) { + $lines = @($Output -split '\r?\n') + $headers = @($lines | Where-Object { $_ -match '^Test run summary: Passed! - .+\)$' }) + if ($headers.Count -ne 1) { throw 'Expected exactly one completed xUnit test summary.' } + $headerIndex = [Array]::IndexOf($lines, $headers[0]) + $summaryLines = @($lines | Select-Object -Skip ($headerIndex + 1) -First 4) + $counts = @{} + foreach ($line in $summaryLines) { + if ($line -match '^\s*(total|failed|succeeded|skipped):\s*(\d+)\s*$') { $counts[$Matches[1]] = [int]$Matches[2] } + } + if ($counts.Count -ne 4) { throw 'The xUnit test summary counts are incomplete or ambiguous.' } + $failed = $counts.failed + $passed = $counts.succeeded + $skipped = $counts.skipped + $total = $counts.total + if ($total -lt 1 -or $passed -lt 1 -or $failed -ne 0 -or $skipped -ne 0 -or $passed -ne $total) { + throw 'Tests must execute at least once, all pass, and none fail or skip.' + } +} +# Downloads and executes the latest stable csrun release with your permissions. +# Source and release history: https://github.com/codebeltnet/csrun +$engineDirectory = Join-Path ([IO.Path]::GetTempPath()) ('csrun-' + [guid]::NewGuid().ToString('N')) +$null = New-Item -ItemType Directory -Path $engineDirectory +$enginePath = Join-Path $engineDirectory 'csrun.ps1' +$process = $null +try { + $release = Invoke-RestMethod 'https://api.github.com/repos/codebeltnet/csrun/releases/latest' + $assets = @($release.assets | Where-Object name -CEQ 'csrun.ps1') + if ($assets.Count -ne 1 -or $assets[0].digest -notmatch '^sha256:[0-9a-f]{64}$') { + throw "csrun release $($release.tag_name) must publish one csrun.ps1 asset with a SHA-256 digest." + } + $asset = $assets[0] + Invoke-WebRequest $asset.browser_download_url -OutFile $enginePath + $actualHash = (Get-FileHash -LiteralPath $enginePath -Algorithm SHA256).Hash + if ("sha256:$actualHash" -ne $asset.digest) { throw "csrun asset checksum mismatch: $actualHash" } +$enginePayload = [Convert]::ToBase64String([IO.File]::ReadAllBytes($enginePath)) +$containerInput = $enginePayload + "`n" + $manifest +$command = ' +$ErrorActionPreference = "Stop" +$enginePath = Join-Path ([IO.Path]::GetTempPath()) ("csrun-release-" + [guid]::NewGuid().ToString("N") + ".ps1") +$engineBytes = [Convert]::FromBase64String([Console]::In.ReadLine()) +[IO.File]::WriteAllBytes($enginePath, $engineBytes) +$manifest = [Console]::In.ReadToEnd() +& $enginePath -ManifestJson $manifest +exit $LASTEXITCODE +' +$output = (@($containerInput | & docker run --rm -i --entrypoint pwsh 'codebeltnet/csrun:10' -NoProfile -NonInteractive -Command $command) -join [Environment]::NewLine) +$process = [pscustomobject]@{ ExitCode = $LASTEXITCODE } +$diagnostics = '' +Write-Output $output +} catch { + [Console]::Error.WriteLine("csrun diagnostics retained in: $engineDirectory") + throw +} finally { + $resolvedTemp = [IO.Path]::TrimEndingDirectorySeparator([IO.Path]::GetFullPath([IO.Path]::GetTempPath())) + $resolvedEngineDirectory = [IO.Path]::GetFullPath($engineDirectory) + if ([IO.Path]::GetDirectoryName($resolvedEngineDirectory) -ne $resolvedTemp -or + [IO.Path]::GetFileName($resolvedEngineDirectory) -cnotmatch '^csrun-[a-f0-9]{32}$') { throw 'Unsafe cleanup path.' } + if ($process -and $process.ExitCode -eq 0) { Remove-Item -LiteralPath $resolvedEngineDirectory -Recurse -Force } +} +if ($process.ExitCode -ne 0) { throw "csrun execution failed with exit code $($process.ExitCode). $diagnostics" } +if ($verifyTests) { Assert-CsrunTestOutput $output } +} \ No newline at end of file diff --git a/.docfx/run-actions/b4149382f121a5ffc3c057df/native.ps1 b/.docfx/run-actions/b4149382f121a5ffc3c057df/native.ps1 new file mode 100644 index 0000000..d9a6a46 --- /dev/null +++ b/.docfx/run-actions/b4149382f121a5ffc3c057df/native.ps1 @@ -0,0 +1,86 @@ +& { +#requires -Version 7.0 +$ErrorActionPreference = 'Stop' +$PSNativeCommandUseErrorActionPreference = $false +$manifest = @' +{ + "dependsOn": [ + "Codebelt.Extensions.Xunit.Hosting@13.0.0", + "Microsoft.Extensions.Hosting@10.0.15", + "xunit.v3@4.0.3" + ], + "framework": "net10.0", + "mode": "test", + "schemaVersion": 1, + "source": "using System.Threading.Tasks;\nusing Codebelt.Extensions.Xunit.Hosting;\nusing Microsoft.Extensions.DependencyInjection;\nusing Xunit;\n\nnamespace MinimalWorkerLifecycle.Tests;\n\npublic sealed class SelfManagedMinimalHostFixtureExample\n{\n public async Task ConfigureBeforeStartingAsync()\n {\n using var host = MinimalHostTestFactory.Create(\n services => services.AddSingleton(new StartupState(\"configured\")),\n hostFixture: new SelfManagedMinimalHostFixture());\n\n var beforeStart = host.Host.Services.GetRequiredService();\n Assert.Equal(\"configured\", beforeStart.Value);\n\n await host.Host.StartAsync().ConfigureAwait(false);\n\n var afterStart = host.Host.Services.GetRequiredService();\n Assert.Same(beforeStart, afterStart);\n }\n}\n\npublic sealed record StartupState(string Value);\n\npublic sealed class RunExample\n{\n [Fact]\n public async Task ExercisesExample()\n {\n await new SelfManagedMinimalHostFixtureExample().ConfigureBeforeStartingAsync();\n }\n}" +} +'@ +$OutputEncoding = [Text.UTF8Encoding]::new($false) +[Console]::OutputEncoding = $OutputEncoding +$verifyTests = $true +function Assert-CsrunTestOutput([string] $Output) { + $lines = @($Output -split '\r?\n') + $headers = @($lines | Where-Object { $_ -match '^Test run summary: Passed! - .+\)$' }) + if ($headers.Count -ne 1) { throw 'Expected exactly one completed xUnit test summary.' } + $headerIndex = [Array]::IndexOf($lines, $headers[0]) + $summaryLines = @($lines | Select-Object -Skip ($headerIndex + 1) -First 4) + $counts = @{} + foreach ($line in $summaryLines) { + if ($line -match '^\s*(total|failed|succeeded|skipped):\s*(\d+)\s*$') { $counts[$Matches[1]] = [int]$Matches[2] } + } + if ($counts.Count -ne 4) { throw 'The xUnit test summary counts are incomplete or ambiguous.' } + $failed = $counts.failed + $passed = $counts.succeeded + $skipped = $counts.skipped + $total = $counts.total + if ($total -lt 1 -or $passed -lt 1 -or $failed -ne 0 -or $skipped -ne 0 -or $passed -ne $total) { + throw 'Tests must execute at least once, all pass, and none fail or skip.' + } +} +# Downloads and executes the latest stable csrun release with your permissions. +# Source and release history: https://github.com/codebeltnet/csrun +$engineDirectory = Join-Path ([IO.Path]::GetTempPath()) ('csrun-' + [guid]::NewGuid().ToString('N')) +$null = New-Item -ItemType Directory -Path $engineDirectory +$enginePath = Join-Path $engineDirectory 'csrun.ps1' +$process = $null +try { + $release = Invoke-RestMethod 'https://api.github.com/repos/codebeltnet/csrun/releases/latest' + $assets = @($release.assets | Where-Object name -CEQ 'csrun.ps1') + if ($assets.Count -ne 1 -or $assets[0].digest -notmatch '^sha256:[0-9a-f]{64}$') { + throw "csrun release $($release.tag_name) must publish one csrun.ps1 asset with a SHA-256 digest." + } + $asset = $assets[0] + Invoke-WebRequest $asset.browser_download_url -OutFile $enginePath + $actualHash = (Get-FileHash -LiteralPath $enginePath -Algorithm SHA256).Hash + if ("sha256:$actualHash" -ne $asset.digest) { throw "csrun asset checksum mismatch: $actualHash" } +$startInfo = [Diagnostics.ProcessStartInfo]::new('pwsh') +foreach ($argument in @('-NoProfile','-NonInteractive','-File')) { $startInfo.ArgumentList.Add($argument) } +$startInfo.ArgumentList.Add($enginePath) +$startInfo.ArgumentList.Add('-ManifestJson') +$startInfo.ArgumentList.Add($manifest) +$startInfo.RedirectStandardOutput = $true +$startInfo.RedirectStandardError = $true +$startInfo.UseShellExecute = $false +$process = [Diagnostics.Process]::new() +$process.StartInfo = $startInfo +if (-not $process.Start()) { throw 'Could not start csrun.' } +$stdoutTask = $process.StandardOutput.ReadToEndAsync() +$stderrTask = $process.StandardError.ReadToEndAsync() +$process.WaitForExit() +$output = $stdoutTask.GetAwaiter().GetResult() +$diagnostics = $stderrTask.GetAwaiter().GetResult() +Write-Output $output +if ($diagnostics) { [Console]::Error.Write($diagnostics) } +} catch { + [Console]::Error.WriteLine("csrun diagnostics retained in: $engineDirectory") + throw +} finally { + $resolvedTemp = [IO.Path]::TrimEndingDirectorySeparator([IO.Path]::GetFullPath([IO.Path]::GetTempPath())) + $resolvedEngineDirectory = [IO.Path]::GetFullPath($engineDirectory) + if ([IO.Path]::GetDirectoryName($resolvedEngineDirectory) -ne $resolvedTemp -or + [IO.Path]::GetFileName($resolvedEngineDirectory) -cnotmatch '^csrun-[a-f0-9]{32}$') { throw 'Unsafe cleanup path.' } + if ($process -and $process.ExitCode -eq 0) { Remove-Item -LiteralPath $resolvedEngineDirectory -Recurse -Force } +} +if ($process.ExitCode -ne 0) { throw "csrun execution failed with exit code $($process.ExitCode). $diagnostics" } +if ($verifyTests) { Assert-CsrunTestOutput $output } +} \ No newline at end of file diff --git a/.docfx/run-actions/becb2fe7446fc1571dc86953/docker.ps1 b/.docfx/run-actions/becb2fe7446fc1571dc86953/docker.ps1 new file mode 100644 index 0000000..3ab7938 --- /dev/null +++ b/.docfx/run-actions/becb2fe7446fc1571dc86953/docker.ps1 @@ -0,0 +1,83 @@ +& { +#requires -Version 7.0 +$ErrorActionPreference = 'Stop' +$PSNativeCommandUseErrorActionPreference = $false +$manifest = @' +{ + "dependsOn": [ + "Codebelt.Extensions.Xunit.Hosting@13.0.0", + "Microsoft.Extensions.Hosting@10.0.15", + "xunit.v3@4.0.3" + ], + "framework": "net10.0", + "mode": "test", + "schemaVersion": 1, + "source": "using Codebelt.Extensions.Xunit.Hosting;\nusing Xunit;\n\nnamespace HostFixtureTests;\n\npublic class HostStateGuard\n{\n public bool EnsureFixtureIsReady(IMinimalHostFixture fixture)\n {\n return fixture.HasValidState();\n }\n}\n\npublic sealed class RunExample\n{\n [Fact]\n public void ExercisesExample()\n {\n using var fixture = new ManagedMinimalHostFixture();\n Assert.False(new HostStateGuard().EnsureFixtureIsReady(fixture));\n using var app = MinimalHostTestFactory.Create(hostFixture: fixture);\n Assert.True(new HostStateGuard().EnsureFixtureIsReady(fixture));\n }\n}" +} +'@ +$OutputEncoding = [Text.UTF8Encoding]::new($false) +[Console]::OutputEncoding = $OutputEncoding +$verifyTests = $true +function Assert-CsrunTestOutput([string] $Output) { + $lines = @($Output -split '\r?\n') + $headers = @($lines | Where-Object { $_ -match '^Test run summary: Passed! - .+\)$' }) + if ($headers.Count -ne 1) { throw 'Expected exactly one completed xUnit test summary.' } + $headerIndex = [Array]::IndexOf($lines, $headers[0]) + $summaryLines = @($lines | Select-Object -Skip ($headerIndex + 1) -First 4) + $counts = @{} + foreach ($line in $summaryLines) { + if ($line -match '^\s*(total|failed|succeeded|skipped):\s*(\d+)\s*$') { $counts[$Matches[1]] = [int]$Matches[2] } + } + if ($counts.Count -ne 4) { throw 'The xUnit test summary counts are incomplete or ambiguous.' } + $failed = $counts.failed + $passed = $counts.succeeded + $skipped = $counts.skipped + $total = $counts.total + if ($total -lt 1 -or $passed -lt 1 -or $failed -ne 0 -or $skipped -ne 0 -or $passed -ne $total) { + throw 'Tests must execute at least once, all pass, and none fail or skip.' + } +} +# Downloads and executes the latest stable csrun release with your permissions. +# Source and release history: https://github.com/codebeltnet/csrun +$engineDirectory = Join-Path ([IO.Path]::GetTempPath()) ('csrun-' + [guid]::NewGuid().ToString('N')) +$null = New-Item -ItemType Directory -Path $engineDirectory +$enginePath = Join-Path $engineDirectory 'csrun.ps1' +$process = $null +try { + $release = Invoke-RestMethod 'https://api.github.com/repos/codebeltnet/csrun/releases/latest' + $assets = @($release.assets | Where-Object name -CEQ 'csrun.ps1') + if ($assets.Count -ne 1 -or $assets[0].digest -notmatch '^sha256:[0-9a-f]{64}$') { + throw "csrun release $($release.tag_name) must publish one csrun.ps1 asset with a SHA-256 digest." + } + $asset = $assets[0] + Invoke-WebRequest $asset.browser_download_url -OutFile $enginePath + $actualHash = (Get-FileHash -LiteralPath $enginePath -Algorithm SHA256).Hash + if ("sha256:$actualHash" -ne $asset.digest) { throw "csrun asset checksum mismatch: $actualHash" } +$enginePayload = [Convert]::ToBase64String([IO.File]::ReadAllBytes($enginePath)) +$containerInput = $enginePayload + "`n" + $manifest +$command = ' +$ErrorActionPreference = "Stop" +$enginePath = Join-Path ([IO.Path]::GetTempPath()) ("csrun-release-" + [guid]::NewGuid().ToString("N") + ".ps1") +$engineBytes = [Convert]::FromBase64String([Console]::In.ReadLine()) +[IO.File]::WriteAllBytes($enginePath, $engineBytes) +$manifest = [Console]::In.ReadToEnd() +& $enginePath -ManifestJson $manifest +exit $LASTEXITCODE +' +$output = (@($containerInput | & docker run --rm -i --entrypoint pwsh 'codebeltnet/csrun:10' -NoProfile -NonInteractive -Command $command) -join [Environment]::NewLine) +$process = [pscustomobject]@{ ExitCode = $LASTEXITCODE } +$diagnostics = '' +Write-Output $output +} catch { + [Console]::Error.WriteLine("csrun diagnostics retained in: $engineDirectory") + throw +} finally { + $resolvedTemp = [IO.Path]::TrimEndingDirectorySeparator([IO.Path]::GetFullPath([IO.Path]::GetTempPath())) + $resolvedEngineDirectory = [IO.Path]::GetFullPath($engineDirectory) + if ([IO.Path]::GetDirectoryName($resolvedEngineDirectory) -ne $resolvedTemp -or + [IO.Path]::GetFileName($resolvedEngineDirectory) -cnotmatch '^csrun-[a-f0-9]{32}$') { throw 'Unsafe cleanup path.' } + if ($process -and $process.ExitCode -eq 0) { Remove-Item -LiteralPath $resolvedEngineDirectory -Recurse -Force } +} +if ($process.ExitCode -ne 0) { throw "csrun execution failed with exit code $($process.ExitCode). $diagnostics" } +if ($verifyTests) { Assert-CsrunTestOutput $output } +} \ No newline at end of file diff --git a/.docfx/run-actions/becb2fe7446fc1571dc86953/native.ps1 b/.docfx/run-actions/becb2fe7446fc1571dc86953/native.ps1 new file mode 100644 index 0000000..7244533 --- /dev/null +++ b/.docfx/run-actions/becb2fe7446fc1571dc86953/native.ps1 @@ -0,0 +1,86 @@ +& { +#requires -Version 7.0 +$ErrorActionPreference = 'Stop' +$PSNativeCommandUseErrorActionPreference = $false +$manifest = @' +{ + "dependsOn": [ + "Codebelt.Extensions.Xunit.Hosting@13.0.0", + "Microsoft.Extensions.Hosting@10.0.15", + "xunit.v3@4.0.3" + ], + "framework": "net10.0", + "mode": "test", + "schemaVersion": 1, + "source": "using Codebelt.Extensions.Xunit.Hosting;\nusing Xunit;\n\nnamespace HostFixtureTests;\n\npublic class HostStateGuard\n{\n public bool EnsureFixtureIsReady(IMinimalHostFixture fixture)\n {\n return fixture.HasValidState();\n }\n}\n\npublic sealed class RunExample\n{\n [Fact]\n public void ExercisesExample()\n {\n using var fixture = new ManagedMinimalHostFixture();\n Assert.False(new HostStateGuard().EnsureFixtureIsReady(fixture));\n using var app = MinimalHostTestFactory.Create(hostFixture: fixture);\n Assert.True(new HostStateGuard().EnsureFixtureIsReady(fixture));\n }\n}" +} +'@ +$OutputEncoding = [Text.UTF8Encoding]::new($false) +[Console]::OutputEncoding = $OutputEncoding +$verifyTests = $true +function Assert-CsrunTestOutput([string] $Output) { + $lines = @($Output -split '\r?\n') + $headers = @($lines | Where-Object { $_ -match '^Test run summary: Passed! - .+\)$' }) + if ($headers.Count -ne 1) { throw 'Expected exactly one completed xUnit test summary.' } + $headerIndex = [Array]::IndexOf($lines, $headers[0]) + $summaryLines = @($lines | Select-Object -Skip ($headerIndex + 1) -First 4) + $counts = @{} + foreach ($line in $summaryLines) { + if ($line -match '^\s*(total|failed|succeeded|skipped):\s*(\d+)\s*$') { $counts[$Matches[1]] = [int]$Matches[2] } + } + if ($counts.Count -ne 4) { throw 'The xUnit test summary counts are incomplete or ambiguous.' } + $failed = $counts.failed + $passed = $counts.succeeded + $skipped = $counts.skipped + $total = $counts.total + if ($total -lt 1 -or $passed -lt 1 -or $failed -ne 0 -or $skipped -ne 0 -or $passed -ne $total) { + throw 'Tests must execute at least once, all pass, and none fail or skip.' + } +} +# Downloads and executes the latest stable csrun release with your permissions. +# Source and release history: https://github.com/codebeltnet/csrun +$engineDirectory = Join-Path ([IO.Path]::GetTempPath()) ('csrun-' + [guid]::NewGuid().ToString('N')) +$null = New-Item -ItemType Directory -Path $engineDirectory +$enginePath = Join-Path $engineDirectory 'csrun.ps1' +$process = $null +try { + $release = Invoke-RestMethod 'https://api.github.com/repos/codebeltnet/csrun/releases/latest' + $assets = @($release.assets | Where-Object name -CEQ 'csrun.ps1') + if ($assets.Count -ne 1 -or $assets[0].digest -notmatch '^sha256:[0-9a-f]{64}$') { + throw "csrun release $($release.tag_name) must publish one csrun.ps1 asset with a SHA-256 digest." + } + $asset = $assets[0] + Invoke-WebRequest $asset.browser_download_url -OutFile $enginePath + $actualHash = (Get-FileHash -LiteralPath $enginePath -Algorithm SHA256).Hash + if ("sha256:$actualHash" -ne $asset.digest) { throw "csrun asset checksum mismatch: $actualHash" } +$startInfo = [Diagnostics.ProcessStartInfo]::new('pwsh') +foreach ($argument in @('-NoProfile','-NonInteractive','-File')) { $startInfo.ArgumentList.Add($argument) } +$startInfo.ArgumentList.Add($enginePath) +$startInfo.ArgumentList.Add('-ManifestJson') +$startInfo.ArgumentList.Add($manifest) +$startInfo.RedirectStandardOutput = $true +$startInfo.RedirectStandardError = $true +$startInfo.UseShellExecute = $false +$process = [Diagnostics.Process]::new() +$process.StartInfo = $startInfo +if (-not $process.Start()) { throw 'Could not start csrun.' } +$stdoutTask = $process.StandardOutput.ReadToEndAsync() +$stderrTask = $process.StandardError.ReadToEndAsync() +$process.WaitForExit() +$output = $stdoutTask.GetAwaiter().GetResult() +$diagnostics = $stderrTask.GetAwaiter().GetResult() +Write-Output $output +if ($diagnostics) { [Console]::Error.Write($diagnostics) } +} catch { + [Console]::Error.WriteLine("csrun diagnostics retained in: $engineDirectory") + throw +} finally { + $resolvedTemp = [IO.Path]::TrimEndingDirectorySeparator([IO.Path]::GetFullPath([IO.Path]::GetTempPath())) + $resolvedEngineDirectory = [IO.Path]::GetFullPath($engineDirectory) + if ([IO.Path]::GetDirectoryName($resolvedEngineDirectory) -ne $resolvedTemp -or + [IO.Path]::GetFileName($resolvedEngineDirectory) -cnotmatch '^csrun-[a-f0-9]{32}$') { throw 'Unsafe cleanup path.' } + if ($process -and $process.ExitCode -eq 0) { Remove-Item -LiteralPath $resolvedEngineDirectory -Recurse -Force } +} +if ($process.ExitCode -ne 0) { throw "csrun execution failed with exit code $($process.ExitCode). $diagnostics" } +if ($verifyTests) { Assert-CsrunTestOutput $output } +} \ No newline at end of file diff --git a/.docfx/run-actions/d565f9c40d015b247963fdee/docker.ps1 b/.docfx/run-actions/d565f9c40d015b247963fdee/docker.ps1 new file mode 100644 index 0000000..1b168e4 --- /dev/null +++ b/.docfx/run-actions/d565f9c40d015b247963fdee/docker.ps1 @@ -0,0 +1,86 @@ +& { +#requires -Version 7.0 +$ErrorActionPreference = 'Stop' +$PSNativeCommandUseErrorActionPreference = $false +$manifest = @' +{ + "dependsOn": [ + "Codebelt.Extensions.Xunit.Hosting.AspNetCore@13.0.0", + "Microsoft.Extensions.Hosting@10.0.15", + "xunit.v3@4.0.3" + ], + "framework": "net10.0", + "frameworkReferences": [ + "Microsoft.AspNetCore.App" + ], + "mode": "test", + "schemaVersion": 1, + "source": "using Codebelt.Extensions.Xunit.Hosting.AspNetCore;\nusing Microsoft.AspNetCore.Builder;\nusing Microsoft.Extensions.Hosting;\nusing Xunit;\n\nnamespace WebFixtureTests;\n\npublic class BuilderConverter\n{\n public IHostBuilder Convert(IHostApplicationBuilder builder)\n {\n return builder.ToHostBuilder();\n }\n}\n\npublic sealed class RunExample\n{\n [Fact]\n public void ReturnsTheWebHostBuilder()\n {\n var builder = WebApplication.CreateBuilder();\n Assert.Same(builder.Host, new BuilderConverter().Convert(builder));\n }\n}" +} +'@ +$OutputEncoding = [Text.UTF8Encoding]::new($false) +[Console]::OutputEncoding = $OutputEncoding +$verifyTests = $true +function Assert-CsrunTestOutput([string] $Output) { + $lines = @($Output -split '\r?\n') + $headers = @($lines | Where-Object { $_ -match '^Test run summary: Passed! - .+\)$' }) + if ($headers.Count -ne 1) { throw 'Expected exactly one completed xUnit test summary.' } + $headerIndex = [Array]::IndexOf($lines, $headers[0]) + $summaryLines = @($lines | Select-Object -Skip ($headerIndex + 1) -First 4) + $counts = @{} + foreach ($line in $summaryLines) { + if ($line -match '^\s*(total|failed|succeeded|skipped):\s*(\d+)\s*$') { $counts[$Matches[1]] = [int]$Matches[2] } + } + if ($counts.Count -ne 4) { throw 'The xUnit test summary counts are incomplete or ambiguous.' } + $failed = $counts.failed + $passed = $counts.succeeded + $skipped = $counts.skipped + $total = $counts.total + if ($total -lt 1 -or $passed -lt 1 -or $failed -ne 0 -or $skipped -ne 0 -or $passed -ne $total) { + throw 'Tests must execute at least once, all pass, and none fail or skip.' + } +} +# Downloads and executes the latest stable csrun release with your permissions. +# Source and release history: https://github.com/codebeltnet/csrun +$engineDirectory = Join-Path ([IO.Path]::GetTempPath()) ('csrun-' + [guid]::NewGuid().ToString('N')) +$null = New-Item -ItemType Directory -Path $engineDirectory +$enginePath = Join-Path $engineDirectory 'csrun.ps1' +$process = $null +try { + $release = Invoke-RestMethod 'https://api.github.com/repos/codebeltnet/csrun/releases/latest' + $assets = @($release.assets | Where-Object name -CEQ 'csrun.ps1') + if ($assets.Count -ne 1 -or $assets[0].digest -notmatch '^sha256:[0-9a-f]{64}$') { + throw "csrun release $($release.tag_name) must publish one csrun.ps1 asset with a SHA-256 digest." + } + $asset = $assets[0] + Invoke-WebRequest $asset.browser_download_url -OutFile $enginePath + $actualHash = (Get-FileHash -LiteralPath $enginePath -Algorithm SHA256).Hash + if ("sha256:$actualHash" -ne $asset.digest) { throw "csrun asset checksum mismatch: $actualHash" } +$enginePayload = [Convert]::ToBase64String([IO.File]::ReadAllBytes($enginePath)) +$containerInput = $enginePayload + "`n" + $manifest +$command = ' +$ErrorActionPreference = "Stop" +$enginePath = Join-Path ([IO.Path]::GetTempPath()) ("csrun-release-" + [guid]::NewGuid().ToString("N") + ".ps1") +$engineBytes = [Convert]::FromBase64String([Console]::In.ReadLine()) +[IO.File]::WriteAllBytes($enginePath, $engineBytes) +$manifest = [Console]::In.ReadToEnd() +& $enginePath -ManifestJson $manifest +exit $LASTEXITCODE +' +$output = (@($containerInput | & docker run --rm -i --entrypoint pwsh 'codebeltnet/csrun:10' -NoProfile -NonInteractive -Command $command) -join [Environment]::NewLine) +$process = [pscustomobject]@{ ExitCode = $LASTEXITCODE } +$diagnostics = '' +Write-Output $output +} catch { + [Console]::Error.WriteLine("csrun diagnostics retained in: $engineDirectory") + throw +} finally { + $resolvedTemp = [IO.Path]::TrimEndingDirectorySeparator([IO.Path]::GetFullPath([IO.Path]::GetTempPath())) + $resolvedEngineDirectory = [IO.Path]::GetFullPath($engineDirectory) + if ([IO.Path]::GetDirectoryName($resolvedEngineDirectory) -ne $resolvedTemp -or + [IO.Path]::GetFileName($resolvedEngineDirectory) -cnotmatch '^csrun-[a-f0-9]{32}$') { throw 'Unsafe cleanup path.' } + if ($process -and $process.ExitCode -eq 0) { Remove-Item -LiteralPath $resolvedEngineDirectory -Recurse -Force } +} +if ($process.ExitCode -ne 0) { throw "csrun execution failed with exit code $($process.ExitCode). $diagnostics" } +if ($verifyTests) { Assert-CsrunTestOutput $output } +} \ No newline at end of file diff --git a/.docfx/run-actions/d565f9c40d015b247963fdee/native.ps1 b/.docfx/run-actions/d565f9c40d015b247963fdee/native.ps1 new file mode 100644 index 0000000..4df77d6 --- /dev/null +++ b/.docfx/run-actions/d565f9c40d015b247963fdee/native.ps1 @@ -0,0 +1,89 @@ +& { +#requires -Version 7.0 +$ErrorActionPreference = 'Stop' +$PSNativeCommandUseErrorActionPreference = $false +$manifest = @' +{ + "dependsOn": [ + "Codebelt.Extensions.Xunit.Hosting.AspNetCore@13.0.0", + "Microsoft.Extensions.Hosting@10.0.15", + "xunit.v3@4.0.3" + ], + "framework": "net10.0", + "frameworkReferences": [ + "Microsoft.AspNetCore.App" + ], + "mode": "test", + "schemaVersion": 1, + "source": "using Codebelt.Extensions.Xunit.Hosting.AspNetCore;\nusing Microsoft.AspNetCore.Builder;\nusing Microsoft.Extensions.Hosting;\nusing Xunit;\n\nnamespace WebFixtureTests;\n\npublic class BuilderConverter\n{\n public IHostBuilder Convert(IHostApplicationBuilder builder)\n {\n return builder.ToHostBuilder();\n }\n}\n\npublic sealed class RunExample\n{\n [Fact]\n public void ReturnsTheWebHostBuilder()\n {\n var builder = WebApplication.CreateBuilder();\n Assert.Same(builder.Host, new BuilderConverter().Convert(builder));\n }\n}" +} +'@ +$OutputEncoding = [Text.UTF8Encoding]::new($false) +[Console]::OutputEncoding = $OutputEncoding +$verifyTests = $true +function Assert-CsrunTestOutput([string] $Output) { + $lines = @($Output -split '\r?\n') + $headers = @($lines | Where-Object { $_ -match '^Test run summary: Passed! - .+\)$' }) + if ($headers.Count -ne 1) { throw 'Expected exactly one completed xUnit test summary.' } + $headerIndex = [Array]::IndexOf($lines, $headers[0]) + $summaryLines = @($lines | Select-Object -Skip ($headerIndex + 1) -First 4) + $counts = @{} + foreach ($line in $summaryLines) { + if ($line -match '^\s*(total|failed|succeeded|skipped):\s*(\d+)\s*$') { $counts[$Matches[1]] = [int]$Matches[2] } + } + if ($counts.Count -ne 4) { throw 'The xUnit test summary counts are incomplete or ambiguous.' } + $failed = $counts.failed + $passed = $counts.succeeded + $skipped = $counts.skipped + $total = $counts.total + if ($total -lt 1 -or $passed -lt 1 -or $failed -ne 0 -or $skipped -ne 0 -or $passed -ne $total) { + throw 'Tests must execute at least once, all pass, and none fail or skip.' + } +} +# Downloads and executes the latest stable csrun release with your permissions. +# Source and release history: https://github.com/codebeltnet/csrun +$engineDirectory = Join-Path ([IO.Path]::GetTempPath()) ('csrun-' + [guid]::NewGuid().ToString('N')) +$null = New-Item -ItemType Directory -Path $engineDirectory +$enginePath = Join-Path $engineDirectory 'csrun.ps1' +$process = $null +try { + $release = Invoke-RestMethod 'https://api.github.com/repos/codebeltnet/csrun/releases/latest' + $assets = @($release.assets | Where-Object name -CEQ 'csrun.ps1') + if ($assets.Count -ne 1 -or $assets[0].digest -notmatch '^sha256:[0-9a-f]{64}$') { + throw "csrun release $($release.tag_name) must publish one csrun.ps1 asset with a SHA-256 digest." + } + $asset = $assets[0] + Invoke-WebRequest $asset.browser_download_url -OutFile $enginePath + $actualHash = (Get-FileHash -LiteralPath $enginePath -Algorithm SHA256).Hash + if ("sha256:$actualHash" -ne $asset.digest) { throw "csrun asset checksum mismatch: $actualHash" } +$startInfo = [Diagnostics.ProcessStartInfo]::new('pwsh') +foreach ($argument in @('-NoProfile','-NonInteractive','-File')) { $startInfo.ArgumentList.Add($argument) } +$startInfo.ArgumentList.Add($enginePath) +$startInfo.ArgumentList.Add('-ManifestJson') +$startInfo.ArgumentList.Add($manifest) +$startInfo.RedirectStandardOutput = $true +$startInfo.RedirectStandardError = $true +$startInfo.UseShellExecute = $false +$process = [Diagnostics.Process]::new() +$process.StartInfo = $startInfo +if (-not $process.Start()) { throw 'Could not start csrun.' } +$stdoutTask = $process.StandardOutput.ReadToEndAsync() +$stderrTask = $process.StandardError.ReadToEndAsync() +$process.WaitForExit() +$output = $stdoutTask.GetAwaiter().GetResult() +$diagnostics = $stderrTask.GetAwaiter().GetResult() +Write-Output $output +if ($diagnostics) { [Console]::Error.Write($diagnostics) } +} catch { + [Console]::Error.WriteLine("csrun diagnostics retained in: $engineDirectory") + throw +} finally { + $resolvedTemp = [IO.Path]::TrimEndingDirectorySeparator([IO.Path]::GetFullPath([IO.Path]::GetTempPath())) + $resolvedEngineDirectory = [IO.Path]::GetFullPath($engineDirectory) + if ([IO.Path]::GetDirectoryName($resolvedEngineDirectory) -ne $resolvedTemp -or + [IO.Path]::GetFileName($resolvedEngineDirectory) -cnotmatch '^csrun-[a-f0-9]{32}$') { throw 'Unsafe cleanup path.' } + if ($process -and $process.ExitCode -eq 0) { Remove-Item -LiteralPath $resolvedEngineDirectory -Recurse -Force } +} +if ($process.ExitCode -ne 0) { throw "csrun execution failed with exit code $($process.ExitCode). $diagnostics" } +if ($verifyTests) { Assert-CsrunTestOutput $output } +} \ No newline at end of file diff --git a/.docfx/run-actions/d71e8ed85f1221cb41308b31/docker.ps1 b/.docfx/run-actions/d71e8ed85f1221cb41308b31/docker.ps1 new file mode 100644 index 0000000..7912d45 --- /dev/null +++ b/.docfx/run-actions/d71e8ed85f1221cb41308b31/docker.ps1 @@ -0,0 +1,86 @@ +& { +#requires -Version 7.0 +$ErrorActionPreference = 'Stop' +$PSNativeCommandUseErrorActionPreference = $false +$manifest = @' +{ + "dependsOn": [ + "Codebelt.Extensions.Xunit.Hosting.AspNetCore@13.0.0", + "Microsoft.Extensions.Hosting@10.0.15", + "xunit.v3@4.0.3" + ], + "framework": "net10.0", + "frameworkReferences": [ + "Microsoft.AspNetCore.App" + ], + "mode": "test", + "schemaVersion": 1, + "source": "using System.Threading.Tasks;\nusing Codebelt.Extensions.Xunit.Hosting.AspNetCore;\nusing Microsoft.AspNetCore.Builder;\nusing Microsoft.AspNetCore.Http;\nusing Microsoft.Extensions.DependencyInjection;\nusing Xunit;\n\nnamespace RequestPipeline.Tests;\n\npublic sealed class WebHostTestFactoryExample\n{\n public async Task InvokeStatusMiddlewareAsync()\n {\n using var response = await WebHostTestFactory.RunAsync(\n services => services.AddSingleton(new PipelineStatus(\"ready\")),\n app => app.Run(context =>\n {\n var status = context.RequestServices.GetRequiredService();\n return context.Response.WriteAsync(status.Value);\n })).ConfigureAwait(false);\n\n return await response.Content.ReadAsStringAsync().ConfigureAwait(false);\n }\n}\n\npublic sealed record PipelineStatus(string Value);\n\npublic sealed class RunExample\n{\n [Fact]\n public async Task ExercisesExample()\n {\n Assert.Equal(\"ready\", await new WebHostTestFactoryExample().InvokeStatusMiddlewareAsync());\n }\n}" +} +'@ +$OutputEncoding = [Text.UTF8Encoding]::new($false) +[Console]::OutputEncoding = $OutputEncoding +$verifyTests = $true +function Assert-CsrunTestOutput([string] $Output) { + $lines = @($Output -split '\r?\n') + $headers = @($lines | Where-Object { $_ -match '^Test run summary: Passed! - .+\)$' }) + if ($headers.Count -ne 1) { throw 'Expected exactly one completed xUnit test summary.' } + $headerIndex = [Array]::IndexOf($lines, $headers[0]) + $summaryLines = @($lines | Select-Object -Skip ($headerIndex + 1) -First 4) + $counts = @{} + foreach ($line in $summaryLines) { + if ($line -match '^\s*(total|failed|succeeded|skipped):\s*(\d+)\s*$') { $counts[$Matches[1]] = [int]$Matches[2] } + } + if ($counts.Count -ne 4) { throw 'The xUnit test summary counts are incomplete or ambiguous.' } + $failed = $counts.failed + $passed = $counts.succeeded + $skipped = $counts.skipped + $total = $counts.total + if ($total -lt 1 -or $passed -lt 1 -or $failed -ne 0 -or $skipped -ne 0 -or $passed -ne $total) { + throw 'Tests must execute at least once, all pass, and none fail or skip.' + } +} +# Downloads and executes the latest stable csrun release with your permissions. +# Source and release history: https://github.com/codebeltnet/csrun +$engineDirectory = Join-Path ([IO.Path]::GetTempPath()) ('csrun-' + [guid]::NewGuid().ToString('N')) +$null = New-Item -ItemType Directory -Path $engineDirectory +$enginePath = Join-Path $engineDirectory 'csrun.ps1' +$process = $null +try { + $release = Invoke-RestMethod 'https://api.github.com/repos/codebeltnet/csrun/releases/latest' + $assets = @($release.assets | Where-Object name -CEQ 'csrun.ps1') + if ($assets.Count -ne 1 -or $assets[0].digest -notmatch '^sha256:[0-9a-f]{64}$') { + throw "csrun release $($release.tag_name) must publish one csrun.ps1 asset with a SHA-256 digest." + } + $asset = $assets[0] + Invoke-WebRequest $asset.browser_download_url -OutFile $enginePath + $actualHash = (Get-FileHash -LiteralPath $enginePath -Algorithm SHA256).Hash + if ("sha256:$actualHash" -ne $asset.digest) { throw "csrun asset checksum mismatch: $actualHash" } +$enginePayload = [Convert]::ToBase64String([IO.File]::ReadAllBytes($enginePath)) +$containerInput = $enginePayload + "`n" + $manifest +$command = ' +$ErrorActionPreference = "Stop" +$enginePath = Join-Path ([IO.Path]::GetTempPath()) ("csrun-release-" + [guid]::NewGuid().ToString("N") + ".ps1") +$engineBytes = [Convert]::FromBase64String([Console]::In.ReadLine()) +[IO.File]::WriteAllBytes($enginePath, $engineBytes) +$manifest = [Console]::In.ReadToEnd() +& $enginePath -ManifestJson $manifest +exit $LASTEXITCODE +' +$output = (@($containerInput | & docker run --rm -i --entrypoint pwsh 'codebeltnet/csrun:10' -NoProfile -NonInteractive -Command $command) -join [Environment]::NewLine) +$process = [pscustomobject]@{ ExitCode = $LASTEXITCODE } +$diagnostics = '' +Write-Output $output +} catch { + [Console]::Error.WriteLine("csrun diagnostics retained in: $engineDirectory") + throw +} finally { + $resolvedTemp = [IO.Path]::TrimEndingDirectorySeparator([IO.Path]::GetFullPath([IO.Path]::GetTempPath())) + $resolvedEngineDirectory = [IO.Path]::GetFullPath($engineDirectory) + if ([IO.Path]::GetDirectoryName($resolvedEngineDirectory) -ne $resolvedTemp -or + [IO.Path]::GetFileName($resolvedEngineDirectory) -cnotmatch '^csrun-[a-f0-9]{32}$') { throw 'Unsafe cleanup path.' } + if ($process -and $process.ExitCode -eq 0) { Remove-Item -LiteralPath $resolvedEngineDirectory -Recurse -Force } +} +if ($process.ExitCode -ne 0) { throw "csrun execution failed with exit code $($process.ExitCode). $diagnostics" } +if ($verifyTests) { Assert-CsrunTestOutput $output } +} \ No newline at end of file diff --git a/.docfx/run-actions/d71e8ed85f1221cb41308b31/native.ps1 b/.docfx/run-actions/d71e8ed85f1221cb41308b31/native.ps1 new file mode 100644 index 0000000..1137601 --- /dev/null +++ b/.docfx/run-actions/d71e8ed85f1221cb41308b31/native.ps1 @@ -0,0 +1,89 @@ +& { +#requires -Version 7.0 +$ErrorActionPreference = 'Stop' +$PSNativeCommandUseErrorActionPreference = $false +$manifest = @' +{ + "dependsOn": [ + "Codebelt.Extensions.Xunit.Hosting.AspNetCore@13.0.0", + "Microsoft.Extensions.Hosting@10.0.15", + "xunit.v3@4.0.3" + ], + "framework": "net10.0", + "frameworkReferences": [ + "Microsoft.AspNetCore.App" + ], + "mode": "test", + "schemaVersion": 1, + "source": "using System.Threading.Tasks;\nusing Codebelt.Extensions.Xunit.Hosting.AspNetCore;\nusing Microsoft.AspNetCore.Builder;\nusing Microsoft.AspNetCore.Http;\nusing Microsoft.Extensions.DependencyInjection;\nusing Xunit;\n\nnamespace RequestPipeline.Tests;\n\npublic sealed class WebHostTestFactoryExample\n{\n public async Task InvokeStatusMiddlewareAsync()\n {\n using var response = await WebHostTestFactory.RunAsync(\n services => services.AddSingleton(new PipelineStatus(\"ready\")),\n app => app.Run(context =>\n {\n var status = context.RequestServices.GetRequiredService();\n return context.Response.WriteAsync(status.Value);\n })).ConfigureAwait(false);\n\n return await response.Content.ReadAsStringAsync().ConfigureAwait(false);\n }\n}\n\npublic sealed record PipelineStatus(string Value);\n\npublic sealed class RunExample\n{\n [Fact]\n public async Task ExercisesExample()\n {\n Assert.Equal(\"ready\", await new WebHostTestFactoryExample().InvokeStatusMiddlewareAsync());\n }\n}" +} +'@ +$OutputEncoding = [Text.UTF8Encoding]::new($false) +[Console]::OutputEncoding = $OutputEncoding +$verifyTests = $true +function Assert-CsrunTestOutput([string] $Output) { + $lines = @($Output -split '\r?\n') + $headers = @($lines | Where-Object { $_ -match '^Test run summary: Passed! - .+\)$' }) + if ($headers.Count -ne 1) { throw 'Expected exactly one completed xUnit test summary.' } + $headerIndex = [Array]::IndexOf($lines, $headers[0]) + $summaryLines = @($lines | Select-Object -Skip ($headerIndex + 1) -First 4) + $counts = @{} + foreach ($line in $summaryLines) { + if ($line -match '^\s*(total|failed|succeeded|skipped):\s*(\d+)\s*$') { $counts[$Matches[1]] = [int]$Matches[2] } + } + if ($counts.Count -ne 4) { throw 'The xUnit test summary counts are incomplete or ambiguous.' } + $failed = $counts.failed + $passed = $counts.succeeded + $skipped = $counts.skipped + $total = $counts.total + if ($total -lt 1 -or $passed -lt 1 -or $failed -ne 0 -or $skipped -ne 0 -or $passed -ne $total) { + throw 'Tests must execute at least once, all pass, and none fail or skip.' + } +} +# Downloads and executes the latest stable csrun release with your permissions. +# Source and release history: https://github.com/codebeltnet/csrun +$engineDirectory = Join-Path ([IO.Path]::GetTempPath()) ('csrun-' + [guid]::NewGuid().ToString('N')) +$null = New-Item -ItemType Directory -Path $engineDirectory +$enginePath = Join-Path $engineDirectory 'csrun.ps1' +$process = $null +try { + $release = Invoke-RestMethod 'https://api.github.com/repos/codebeltnet/csrun/releases/latest' + $assets = @($release.assets | Where-Object name -CEQ 'csrun.ps1') + if ($assets.Count -ne 1 -or $assets[0].digest -notmatch '^sha256:[0-9a-f]{64}$') { + throw "csrun release $($release.tag_name) must publish one csrun.ps1 asset with a SHA-256 digest." + } + $asset = $assets[0] + Invoke-WebRequest $asset.browser_download_url -OutFile $enginePath + $actualHash = (Get-FileHash -LiteralPath $enginePath -Algorithm SHA256).Hash + if ("sha256:$actualHash" -ne $asset.digest) { throw "csrun asset checksum mismatch: $actualHash" } +$startInfo = [Diagnostics.ProcessStartInfo]::new('pwsh') +foreach ($argument in @('-NoProfile','-NonInteractive','-File')) { $startInfo.ArgumentList.Add($argument) } +$startInfo.ArgumentList.Add($enginePath) +$startInfo.ArgumentList.Add('-ManifestJson') +$startInfo.ArgumentList.Add($manifest) +$startInfo.RedirectStandardOutput = $true +$startInfo.RedirectStandardError = $true +$startInfo.UseShellExecute = $false +$process = [Diagnostics.Process]::new() +$process.StartInfo = $startInfo +if (-not $process.Start()) { throw 'Could not start csrun.' } +$stdoutTask = $process.StandardOutput.ReadToEndAsync() +$stderrTask = $process.StandardError.ReadToEndAsync() +$process.WaitForExit() +$output = $stdoutTask.GetAwaiter().GetResult() +$diagnostics = $stderrTask.GetAwaiter().GetResult() +Write-Output $output +if ($diagnostics) { [Console]::Error.Write($diagnostics) } +} catch { + [Console]::Error.WriteLine("csrun diagnostics retained in: $engineDirectory") + throw +} finally { + $resolvedTemp = [IO.Path]::TrimEndingDirectorySeparator([IO.Path]::GetFullPath([IO.Path]::GetTempPath())) + $resolvedEngineDirectory = [IO.Path]::GetFullPath($engineDirectory) + if ([IO.Path]::GetDirectoryName($resolvedEngineDirectory) -ne $resolvedTemp -or + [IO.Path]::GetFileName($resolvedEngineDirectory) -cnotmatch '^csrun-[a-f0-9]{32}$') { throw 'Unsafe cleanup path.' } + if ($process -and $process.ExitCode -eq 0) { Remove-Item -LiteralPath $resolvedEngineDirectory -Recurse -Force } +} +if ($process.ExitCode -ne 0) { throw "csrun execution failed with exit code $($process.ExitCode). $diagnostics" } +if ($verifyTests) { Assert-CsrunTestOutput $output } +} \ No newline at end of file diff --git a/.docfx/run-actions/dd2fa1a038dbc1220b366a53/docker.ps1 b/.docfx/run-actions/dd2fa1a038dbc1220b366a53/docker.ps1 new file mode 100644 index 0000000..5ff802c --- /dev/null +++ b/.docfx/run-actions/dd2fa1a038dbc1220b366a53/docker.ps1 @@ -0,0 +1,86 @@ +& { +#requires -Version 7.0 +$ErrorActionPreference = 'Stop' +$PSNativeCommandUseErrorActionPreference = $false +$manifest = @' +{ + "dependsOn": [ + "Codebelt.Extensions.Xunit.Hosting.AspNetCore@13.0.0", + "Microsoft.Extensions.Hosting@10.0.15", + "xunit.v3@4.0.3" + ], + "framework": "net10.0", + "frameworkReferences": [ + "Microsoft.AspNetCore.App" + ], + "mode": "test", + "schemaVersion": 1, + "source": "using Codebelt.Extensions.Xunit.Hosting.AspNetCore;\nusing Xunit;\n\nnamespace WebFixtureTests;\n\npublic class WebMinimalHostStateGuard\n{\n public bool EnsureFixtureIsReady(IWebMinimalHostFixture fixture)\n {\n return fixture.HasValidState();\n }\n}\n\npublic sealed class RunExample\n{\n [Fact]\n public void ExercisesExample()\n {\n using var fixture = new ManagedWebMinimalHostFixture();\n Assert.False(new WebMinimalHostStateGuard().EnsureFixtureIsReady(fixture));\n using var app = MinimalWebHostTestFactory.Create(hostFixture: fixture);\n Assert.True(new WebMinimalHostStateGuard().EnsureFixtureIsReady(fixture));\n }\n}" +} +'@ +$OutputEncoding = [Text.UTF8Encoding]::new($false) +[Console]::OutputEncoding = $OutputEncoding +$verifyTests = $true +function Assert-CsrunTestOutput([string] $Output) { + $lines = @($Output -split '\r?\n') + $headers = @($lines | Where-Object { $_ -match '^Test run summary: Passed! - .+\)$' }) + if ($headers.Count -ne 1) { throw 'Expected exactly one completed xUnit test summary.' } + $headerIndex = [Array]::IndexOf($lines, $headers[0]) + $summaryLines = @($lines | Select-Object -Skip ($headerIndex + 1) -First 4) + $counts = @{} + foreach ($line in $summaryLines) { + if ($line -match '^\s*(total|failed|succeeded|skipped):\s*(\d+)\s*$') { $counts[$Matches[1]] = [int]$Matches[2] } + } + if ($counts.Count -ne 4) { throw 'The xUnit test summary counts are incomplete or ambiguous.' } + $failed = $counts.failed + $passed = $counts.succeeded + $skipped = $counts.skipped + $total = $counts.total + if ($total -lt 1 -or $passed -lt 1 -or $failed -ne 0 -or $skipped -ne 0 -or $passed -ne $total) { + throw 'Tests must execute at least once, all pass, and none fail or skip.' + } +} +# Downloads and executes the latest stable csrun release with your permissions. +# Source and release history: https://github.com/codebeltnet/csrun +$engineDirectory = Join-Path ([IO.Path]::GetTempPath()) ('csrun-' + [guid]::NewGuid().ToString('N')) +$null = New-Item -ItemType Directory -Path $engineDirectory +$enginePath = Join-Path $engineDirectory 'csrun.ps1' +$process = $null +try { + $release = Invoke-RestMethod 'https://api.github.com/repos/codebeltnet/csrun/releases/latest' + $assets = @($release.assets | Where-Object name -CEQ 'csrun.ps1') + if ($assets.Count -ne 1 -or $assets[0].digest -notmatch '^sha256:[0-9a-f]{64}$') { + throw "csrun release $($release.tag_name) must publish one csrun.ps1 asset with a SHA-256 digest." + } + $asset = $assets[0] + Invoke-WebRequest $asset.browser_download_url -OutFile $enginePath + $actualHash = (Get-FileHash -LiteralPath $enginePath -Algorithm SHA256).Hash + if ("sha256:$actualHash" -ne $asset.digest) { throw "csrun asset checksum mismatch: $actualHash" } +$enginePayload = [Convert]::ToBase64String([IO.File]::ReadAllBytes($enginePath)) +$containerInput = $enginePayload + "`n" + $manifest +$command = ' +$ErrorActionPreference = "Stop" +$enginePath = Join-Path ([IO.Path]::GetTempPath()) ("csrun-release-" + [guid]::NewGuid().ToString("N") + ".ps1") +$engineBytes = [Convert]::FromBase64String([Console]::In.ReadLine()) +[IO.File]::WriteAllBytes($enginePath, $engineBytes) +$manifest = [Console]::In.ReadToEnd() +& $enginePath -ManifestJson $manifest +exit $LASTEXITCODE +' +$output = (@($containerInput | & docker run --rm -i --entrypoint pwsh 'codebeltnet/csrun:10' -NoProfile -NonInteractive -Command $command) -join [Environment]::NewLine) +$process = [pscustomobject]@{ ExitCode = $LASTEXITCODE } +$diagnostics = '' +Write-Output $output +} catch { + [Console]::Error.WriteLine("csrun diagnostics retained in: $engineDirectory") + throw +} finally { + $resolvedTemp = [IO.Path]::TrimEndingDirectorySeparator([IO.Path]::GetFullPath([IO.Path]::GetTempPath())) + $resolvedEngineDirectory = [IO.Path]::GetFullPath($engineDirectory) + if ([IO.Path]::GetDirectoryName($resolvedEngineDirectory) -ne $resolvedTemp -or + [IO.Path]::GetFileName($resolvedEngineDirectory) -cnotmatch '^csrun-[a-f0-9]{32}$') { throw 'Unsafe cleanup path.' } + if ($process -and $process.ExitCode -eq 0) { Remove-Item -LiteralPath $resolvedEngineDirectory -Recurse -Force } +} +if ($process.ExitCode -ne 0) { throw "csrun execution failed with exit code $($process.ExitCode). $diagnostics" } +if ($verifyTests) { Assert-CsrunTestOutput $output } +} \ No newline at end of file diff --git a/.docfx/run-actions/dd2fa1a038dbc1220b366a53/native.ps1 b/.docfx/run-actions/dd2fa1a038dbc1220b366a53/native.ps1 new file mode 100644 index 0000000..219cd22 --- /dev/null +++ b/.docfx/run-actions/dd2fa1a038dbc1220b366a53/native.ps1 @@ -0,0 +1,89 @@ +& { +#requires -Version 7.0 +$ErrorActionPreference = 'Stop' +$PSNativeCommandUseErrorActionPreference = $false +$manifest = @' +{ + "dependsOn": [ + "Codebelt.Extensions.Xunit.Hosting.AspNetCore@13.0.0", + "Microsoft.Extensions.Hosting@10.0.15", + "xunit.v3@4.0.3" + ], + "framework": "net10.0", + "frameworkReferences": [ + "Microsoft.AspNetCore.App" + ], + "mode": "test", + "schemaVersion": 1, + "source": "using Codebelt.Extensions.Xunit.Hosting.AspNetCore;\nusing Xunit;\n\nnamespace WebFixtureTests;\n\npublic class WebMinimalHostStateGuard\n{\n public bool EnsureFixtureIsReady(IWebMinimalHostFixture fixture)\n {\n return fixture.HasValidState();\n }\n}\n\npublic sealed class RunExample\n{\n [Fact]\n public void ExercisesExample()\n {\n using var fixture = new ManagedWebMinimalHostFixture();\n Assert.False(new WebMinimalHostStateGuard().EnsureFixtureIsReady(fixture));\n using var app = MinimalWebHostTestFactory.Create(hostFixture: fixture);\n Assert.True(new WebMinimalHostStateGuard().EnsureFixtureIsReady(fixture));\n }\n}" +} +'@ +$OutputEncoding = [Text.UTF8Encoding]::new($false) +[Console]::OutputEncoding = $OutputEncoding +$verifyTests = $true +function Assert-CsrunTestOutput([string] $Output) { + $lines = @($Output -split '\r?\n') + $headers = @($lines | Where-Object { $_ -match '^Test run summary: Passed! - .+\)$' }) + if ($headers.Count -ne 1) { throw 'Expected exactly one completed xUnit test summary.' } + $headerIndex = [Array]::IndexOf($lines, $headers[0]) + $summaryLines = @($lines | Select-Object -Skip ($headerIndex + 1) -First 4) + $counts = @{} + foreach ($line in $summaryLines) { + if ($line -match '^\s*(total|failed|succeeded|skipped):\s*(\d+)\s*$') { $counts[$Matches[1]] = [int]$Matches[2] } + } + if ($counts.Count -ne 4) { throw 'The xUnit test summary counts are incomplete or ambiguous.' } + $failed = $counts.failed + $passed = $counts.succeeded + $skipped = $counts.skipped + $total = $counts.total + if ($total -lt 1 -or $passed -lt 1 -or $failed -ne 0 -or $skipped -ne 0 -or $passed -ne $total) { + throw 'Tests must execute at least once, all pass, and none fail or skip.' + } +} +# Downloads and executes the latest stable csrun release with your permissions. +# Source and release history: https://github.com/codebeltnet/csrun +$engineDirectory = Join-Path ([IO.Path]::GetTempPath()) ('csrun-' + [guid]::NewGuid().ToString('N')) +$null = New-Item -ItemType Directory -Path $engineDirectory +$enginePath = Join-Path $engineDirectory 'csrun.ps1' +$process = $null +try { + $release = Invoke-RestMethod 'https://api.github.com/repos/codebeltnet/csrun/releases/latest' + $assets = @($release.assets | Where-Object name -CEQ 'csrun.ps1') + if ($assets.Count -ne 1 -or $assets[0].digest -notmatch '^sha256:[0-9a-f]{64}$') { + throw "csrun release $($release.tag_name) must publish one csrun.ps1 asset with a SHA-256 digest." + } + $asset = $assets[0] + Invoke-WebRequest $asset.browser_download_url -OutFile $enginePath + $actualHash = (Get-FileHash -LiteralPath $enginePath -Algorithm SHA256).Hash + if ("sha256:$actualHash" -ne $asset.digest) { throw "csrun asset checksum mismatch: $actualHash" } +$startInfo = [Diagnostics.ProcessStartInfo]::new('pwsh') +foreach ($argument in @('-NoProfile','-NonInteractive','-File')) { $startInfo.ArgumentList.Add($argument) } +$startInfo.ArgumentList.Add($enginePath) +$startInfo.ArgumentList.Add('-ManifestJson') +$startInfo.ArgumentList.Add($manifest) +$startInfo.RedirectStandardOutput = $true +$startInfo.RedirectStandardError = $true +$startInfo.UseShellExecute = $false +$process = [Diagnostics.Process]::new() +$process.StartInfo = $startInfo +if (-not $process.Start()) { throw 'Could not start csrun.' } +$stdoutTask = $process.StandardOutput.ReadToEndAsync() +$stderrTask = $process.StandardError.ReadToEndAsync() +$process.WaitForExit() +$output = $stdoutTask.GetAwaiter().GetResult() +$diagnostics = $stderrTask.GetAwaiter().GetResult() +Write-Output $output +if ($diagnostics) { [Console]::Error.Write($diagnostics) } +} catch { + [Console]::Error.WriteLine("csrun diagnostics retained in: $engineDirectory") + throw +} finally { + $resolvedTemp = [IO.Path]::TrimEndingDirectorySeparator([IO.Path]::GetFullPath([IO.Path]::GetTempPath())) + $resolvedEngineDirectory = [IO.Path]::GetFullPath($engineDirectory) + if ([IO.Path]::GetDirectoryName($resolvedEngineDirectory) -ne $resolvedTemp -or + [IO.Path]::GetFileName($resolvedEngineDirectory) -cnotmatch '^csrun-[a-f0-9]{32}$') { throw 'Unsafe cleanup path.' } + if ($process -and $process.ExitCode -eq 0) { Remove-Item -LiteralPath $resolvedEngineDirectory -Recurse -Force } +} +if ($process.ExitCode -ne 0) { throw "csrun execution failed with exit code $($process.ExitCode). $diagnostics" } +if ($verifyTests) { Assert-CsrunTestOutput $output } +} \ No newline at end of file diff --git a/.docfx/run-actions/dfdd064179bf4643e1a0b2bf/docker.ps1 b/.docfx/run-actions/dfdd064179bf4643e1a0b2bf/docker.ps1 new file mode 100644 index 0000000..2447606 --- /dev/null +++ b/.docfx/run-actions/dfdd064179bf4643e1a0b2bf/docker.ps1 @@ -0,0 +1,86 @@ +& { +#requires -Version 7.0 +$ErrorActionPreference = 'Stop' +$PSNativeCommandUseErrorActionPreference = $false +$manifest = @' +{ + "dependsOn": [ + "Codebelt.Extensions.Xunit.Hosting.AspNetCore@13.0.0", + "Microsoft.Extensions.Hosting@10.0.15", + "xunit.v3@4.0.3" + ], + "framework": "net10.0", + "frameworkReferences": [ + "Microsoft.AspNetCore.App" + ], + "mode": "test", + "schemaVersion": 1, + "source": "using Codebelt.Extensions.Xunit.Hosting.AspNetCore;\nusing Xunit;\n\nnamespace WebFixtureTests;\n\npublic class WebHostStateGuard\n{\n public bool EnsureFixtureIsReady(IWebHostFixture fixture)\n {\n return fixture.HasValidState();\n }\n}\n\npublic sealed class RunExample\n{\n [Fact]\n public void ExercisesExample()\n {\n using var fixture = new ManagedWebHostFixture();\n Assert.False(new WebHostStateGuard().EnsureFixtureIsReady(fixture));\n using var app = WebHostTestFactory.Create(hostFixture: fixture);\n Assert.True(new WebHostStateGuard().EnsureFixtureIsReady(fixture));\n }\n}" +} +'@ +$OutputEncoding = [Text.UTF8Encoding]::new($false) +[Console]::OutputEncoding = $OutputEncoding +$verifyTests = $true +function Assert-CsrunTestOutput([string] $Output) { + $lines = @($Output -split '\r?\n') + $headers = @($lines | Where-Object { $_ -match '^Test run summary: Passed! - .+\)$' }) + if ($headers.Count -ne 1) { throw 'Expected exactly one completed xUnit test summary.' } + $headerIndex = [Array]::IndexOf($lines, $headers[0]) + $summaryLines = @($lines | Select-Object -Skip ($headerIndex + 1) -First 4) + $counts = @{} + foreach ($line in $summaryLines) { + if ($line -match '^\s*(total|failed|succeeded|skipped):\s*(\d+)\s*$') { $counts[$Matches[1]] = [int]$Matches[2] } + } + if ($counts.Count -ne 4) { throw 'The xUnit test summary counts are incomplete or ambiguous.' } + $failed = $counts.failed + $passed = $counts.succeeded + $skipped = $counts.skipped + $total = $counts.total + if ($total -lt 1 -or $passed -lt 1 -or $failed -ne 0 -or $skipped -ne 0 -or $passed -ne $total) { + throw 'Tests must execute at least once, all pass, and none fail or skip.' + } +} +# Downloads and executes the latest stable csrun release with your permissions. +# Source and release history: https://github.com/codebeltnet/csrun +$engineDirectory = Join-Path ([IO.Path]::GetTempPath()) ('csrun-' + [guid]::NewGuid().ToString('N')) +$null = New-Item -ItemType Directory -Path $engineDirectory +$enginePath = Join-Path $engineDirectory 'csrun.ps1' +$process = $null +try { + $release = Invoke-RestMethod 'https://api.github.com/repos/codebeltnet/csrun/releases/latest' + $assets = @($release.assets | Where-Object name -CEQ 'csrun.ps1') + if ($assets.Count -ne 1 -or $assets[0].digest -notmatch '^sha256:[0-9a-f]{64}$') { + throw "csrun release $($release.tag_name) must publish one csrun.ps1 asset with a SHA-256 digest." + } + $asset = $assets[0] + Invoke-WebRequest $asset.browser_download_url -OutFile $enginePath + $actualHash = (Get-FileHash -LiteralPath $enginePath -Algorithm SHA256).Hash + if ("sha256:$actualHash" -ne $asset.digest) { throw "csrun asset checksum mismatch: $actualHash" } +$enginePayload = [Convert]::ToBase64String([IO.File]::ReadAllBytes($enginePath)) +$containerInput = $enginePayload + "`n" + $manifest +$command = ' +$ErrorActionPreference = "Stop" +$enginePath = Join-Path ([IO.Path]::GetTempPath()) ("csrun-release-" + [guid]::NewGuid().ToString("N") + ".ps1") +$engineBytes = [Convert]::FromBase64String([Console]::In.ReadLine()) +[IO.File]::WriteAllBytes($enginePath, $engineBytes) +$manifest = [Console]::In.ReadToEnd() +& $enginePath -ManifestJson $manifest +exit $LASTEXITCODE +' +$output = (@($containerInput | & docker run --rm -i --entrypoint pwsh 'codebeltnet/csrun:10' -NoProfile -NonInteractive -Command $command) -join [Environment]::NewLine) +$process = [pscustomobject]@{ ExitCode = $LASTEXITCODE } +$diagnostics = '' +Write-Output $output +} catch { + [Console]::Error.WriteLine("csrun diagnostics retained in: $engineDirectory") + throw +} finally { + $resolvedTemp = [IO.Path]::TrimEndingDirectorySeparator([IO.Path]::GetFullPath([IO.Path]::GetTempPath())) + $resolvedEngineDirectory = [IO.Path]::GetFullPath($engineDirectory) + if ([IO.Path]::GetDirectoryName($resolvedEngineDirectory) -ne $resolvedTemp -or + [IO.Path]::GetFileName($resolvedEngineDirectory) -cnotmatch '^csrun-[a-f0-9]{32}$') { throw 'Unsafe cleanup path.' } + if ($process -and $process.ExitCode -eq 0) { Remove-Item -LiteralPath $resolvedEngineDirectory -Recurse -Force } +} +if ($process.ExitCode -ne 0) { throw "csrun execution failed with exit code $($process.ExitCode). $diagnostics" } +if ($verifyTests) { Assert-CsrunTestOutput $output } +} \ No newline at end of file diff --git a/.docfx/run-actions/dfdd064179bf4643e1a0b2bf/native.ps1 b/.docfx/run-actions/dfdd064179bf4643e1a0b2bf/native.ps1 new file mode 100644 index 0000000..62c8531 --- /dev/null +++ b/.docfx/run-actions/dfdd064179bf4643e1a0b2bf/native.ps1 @@ -0,0 +1,89 @@ +& { +#requires -Version 7.0 +$ErrorActionPreference = 'Stop' +$PSNativeCommandUseErrorActionPreference = $false +$manifest = @' +{ + "dependsOn": [ + "Codebelt.Extensions.Xunit.Hosting.AspNetCore@13.0.0", + "Microsoft.Extensions.Hosting@10.0.15", + "xunit.v3@4.0.3" + ], + "framework": "net10.0", + "frameworkReferences": [ + "Microsoft.AspNetCore.App" + ], + "mode": "test", + "schemaVersion": 1, + "source": "using Codebelt.Extensions.Xunit.Hosting.AspNetCore;\nusing Xunit;\n\nnamespace WebFixtureTests;\n\npublic class WebHostStateGuard\n{\n public bool EnsureFixtureIsReady(IWebHostFixture fixture)\n {\n return fixture.HasValidState();\n }\n}\n\npublic sealed class RunExample\n{\n [Fact]\n public void ExercisesExample()\n {\n using var fixture = new ManagedWebHostFixture();\n Assert.False(new WebHostStateGuard().EnsureFixtureIsReady(fixture));\n using var app = WebHostTestFactory.Create(hostFixture: fixture);\n Assert.True(new WebHostStateGuard().EnsureFixtureIsReady(fixture));\n }\n}" +} +'@ +$OutputEncoding = [Text.UTF8Encoding]::new($false) +[Console]::OutputEncoding = $OutputEncoding +$verifyTests = $true +function Assert-CsrunTestOutput([string] $Output) { + $lines = @($Output -split '\r?\n') + $headers = @($lines | Where-Object { $_ -match '^Test run summary: Passed! - .+\)$' }) + if ($headers.Count -ne 1) { throw 'Expected exactly one completed xUnit test summary.' } + $headerIndex = [Array]::IndexOf($lines, $headers[0]) + $summaryLines = @($lines | Select-Object -Skip ($headerIndex + 1) -First 4) + $counts = @{} + foreach ($line in $summaryLines) { + if ($line -match '^\s*(total|failed|succeeded|skipped):\s*(\d+)\s*$') { $counts[$Matches[1]] = [int]$Matches[2] } + } + if ($counts.Count -ne 4) { throw 'The xUnit test summary counts are incomplete or ambiguous.' } + $failed = $counts.failed + $passed = $counts.succeeded + $skipped = $counts.skipped + $total = $counts.total + if ($total -lt 1 -or $passed -lt 1 -or $failed -ne 0 -or $skipped -ne 0 -or $passed -ne $total) { + throw 'Tests must execute at least once, all pass, and none fail or skip.' + } +} +# Downloads and executes the latest stable csrun release with your permissions. +# Source and release history: https://github.com/codebeltnet/csrun +$engineDirectory = Join-Path ([IO.Path]::GetTempPath()) ('csrun-' + [guid]::NewGuid().ToString('N')) +$null = New-Item -ItemType Directory -Path $engineDirectory +$enginePath = Join-Path $engineDirectory 'csrun.ps1' +$process = $null +try { + $release = Invoke-RestMethod 'https://api.github.com/repos/codebeltnet/csrun/releases/latest' + $assets = @($release.assets | Where-Object name -CEQ 'csrun.ps1') + if ($assets.Count -ne 1 -or $assets[0].digest -notmatch '^sha256:[0-9a-f]{64}$') { + throw "csrun release $($release.tag_name) must publish one csrun.ps1 asset with a SHA-256 digest." + } + $asset = $assets[0] + Invoke-WebRequest $asset.browser_download_url -OutFile $enginePath + $actualHash = (Get-FileHash -LiteralPath $enginePath -Algorithm SHA256).Hash + if ("sha256:$actualHash" -ne $asset.digest) { throw "csrun asset checksum mismatch: $actualHash" } +$startInfo = [Diagnostics.ProcessStartInfo]::new('pwsh') +foreach ($argument in @('-NoProfile','-NonInteractive','-File')) { $startInfo.ArgumentList.Add($argument) } +$startInfo.ArgumentList.Add($enginePath) +$startInfo.ArgumentList.Add('-ManifestJson') +$startInfo.ArgumentList.Add($manifest) +$startInfo.RedirectStandardOutput = $true +$startInfo.RedirectStandardError = $true +$startInfo.UseShellExecute = $false +$process = [Diagnostics.Process]::new() +$process.StartInfo = $startInfo +if (-not $process.Start()) { throw 'Could not start csrun.' } +$stdoutTask = $process.StandardOutput.ReadToEndAsync() +$stderrTask = $process.StandardError.ReadToEndAsync() +$process.WaitForExit() +$output = $stdoutTask.GetAwaiter().GetResult() +$diagnostics = $stderrTask.GetAwaiter().GetResult() +Write-Output $output +if ($diagnostics) { [Console]::Error.Write($diagnostics) } +} catch { + [Console]::Error.WriteLine("csrun diagnostics retained in: $engineDirectory") + throw +} finally { + $resolvedTemp = [IO.Path]::TrimEndingDirectorySeparator([IO.Path]::GetFullPath([IO.Path]::GetTempPath())) + $resolvedEngineDirectory = [IO.Path]::GetFullPath($engineDirectory) + if ([IO.Path]::GetDirectoryName($resolvedEngineDirectory) -ne $resolvedTemp -or + [IO.Path]::GetFileName($resolvedEngineDirectory) -cnotmatch '^csrun-[a-f0-9]{32}$') { throw 'Unsafe cleanup path.' } + if ($process -and $process.ExitCode -eq 0) { Remove-Item -LiteralPath $resolvedEngineDirectory -Recurse -Force } +} +if ($process.ExitCode -ne 0) { throw "csrun execution failed with exit code $($process.ExitCode). $diagnostics" } +if ($verifyTests) { Assert-CsrunTestOutput $output } +} \ No newline at end of file diff --git a/.docfx/run-actions/e3f79d1c0f2fa85276cee2fb/docker.ps1 b/.docfx/run-actions/e3f79d1c0f2fa85276cee2fb/docker.ps1 new file mode 100644 index 0000000..b68f80f --- /dev/null +++ b/.docfx/run-actions/e3f79d1c0f2fa85276cee2fb/docker.ps1 @@ -0,0 +1,82 @@ +& { +#requires -Version 7.0 +$ErrorActionPreference = 'Stop' +$PSNativeCommandUseErrorActionPreference = $false +$manifest = @' +{ + "dependsOn": [ + "Codebelt.Extensions.Xunit.Hosting@13.0.0", + "Microsoft.Extensions.Hosting@10.0.15" + ], + "framework": "net10.0", + "mode": "console", + "schemaVersion": 1, + "source": "using System;\nusing Codebelt.Extensions.Xunit.Hosting;\nusing Microsoft.Extensions.DependencyInjection;\n\nnamespace HostFixtureTests;\n\npublic class MinimalHostFactoryExample\n{\n public void Demonstrate()\n {\n using var host = MinimalHostTestFactory.Create(\n services => services.AddSingleton(new Version(1, 0, 0)));\n var version = host.Host.Services.GetRequiredService();\n Console.WriteLine(version);\n }\n}\n\ninternal static class RunExample\n{\n static void Main()\n {\n new MinimalHostFactoryExample().Demonstrate();\n }\n}" +} +'@ +$OutputEncoding = [Text.UTF8Encoding]::new($false) +[Console]::OutputEncoding = $OutputEncoding +$verifyTests = $false +function Assert-CsrunTestOutput([string] $Output) { + $lines = @($Output -split '\r?\n') + $headers = @($lines | Where-Object { $_ -match '^Test run summary: Passed! - .+\)$' }) + if ($headers.Count -ne 1) { throw 'Expected exactly one completed xUnit test summary.' } + $headerIndex = [Array]::IndexOf($lines, $headers[0]) + $summaryLines = @($lines | Select-Object -Skip ($headerIndex + 1) -First 4) + $counts = @{} + foreach ($line in $summaryLines) { + if ($line -match '^\s*(total|failed|succeeded|skipped):\s*(\d+)\s*$') { $counts[$Matches[1]] = [int]$Matches[2] } + } + if ($counts.Count -ne 4) { throw 'The xUnit test summary counts are incomplete or ambiguous.' } + $failed = $counts.failed + $passed = $counts.succeeded + $skipped = $counts.skipped + $total = $counts.total + if ($total -lt 1 -or $passed -lt 1 -or $failed -ne 0 -or $skipped -ne 0 -or $passed -ne $total) { + throw 'Tests must execute at least once, all pass, and none fail or skip.' + } +} +# Downloads and executes the latest stable csrun release with your permissions. +# Source and release history: https://github.com/codebeltnet/csrun +$engineDirectory = Join-Path ([IO.Path]::GetTempPath()) ('csrun-' + [guid]::NewGuid().ToString('N')) +$null = New-Item -ItemType Directory -Path $engineDirectory +$enginePath = Join-Path $engineDirectory 'csrun.ps1' +$process = $null +try { + $release = Invoke-RestMethod 'https://api.github.com/repos/codebeltnet/csrun/releases/latest' + $assets = @($release.assets | Where-Object name -CEQ 'csrun.ps1') + if ($assets.Count -ne 1 -or $assets[0].digest -notmatch '^sha256:[0-9a-f]{64}$') { + throw "csrun release $($release.tag_name) must publish one csrun.ps1 asset with a SHA-256 digest." + } + $asset = $assets[0] + Invoke-WebRequest $asset.browser_download_url -OutFile $enginePath + $actualHash = (Get-FileHash -LiteralPath $enginePath -Algorithm SHA256).Hash + if ("sha256:$actualHash" -ne $asset.digest) { throw "csrun asset checksum mismatch: $actualHash" } +$enginePayload = [Convert]::ToBase64String([IO.File]::ReadAllBytes($enginePath)) +$containerInput = $enginePayload + "`n" + $manifest +$command = ' +$ErrorActionPreference = "Stop" +$enginePath = Join-Path ([IO.Path]::GetTempPath()) ("csrun-release-" + [guid]::NewGuid().ToString("N") + ".ps1") +$engineBytes = [Convert]::FromBase64String([Console]::In.ReadLine()) +[IO.File]::WriteAllBytes($enginePath, $engineBytes) +$manifest = [Console]::In.ReadToEnd() +& $enginePath -ManifestJson $manifest +exit $LASTEXITCODE +' +$output = (@($containerInput | & docker run --rm -i --entrypoint pwsh 'codebeltnet/csrun:10' -NoProfile -NonInteractive -Command $command) -join [Environment]::NewLine) +$process = [pscustomobject]@{ ExitCode = $LASTEXITCODE } +$diagnostics = '' +Write-Output $output +} catch { + [Console]::Error.WriteLine("csrun diagnostics retained in: $engineDirectory") + throw +} finally { + $resolvedTemp = [IO.Path]::TrimEndingDirectorySeparator([IO.Path]::GetFullPath([IO.Path]::GetTempPath())) + $resolvedEngineDirectory = [IO.Path]::GetFullPath($engineDirectory) + if ([IO.Path]::GetDirectoryName($resolvedEngineDirectory) -ne $resolvedTemp -or + [IO.Path]::GetFileName($resolvedEngineDirectory) -cnotmatch '^csrun-[a-f0-9]{32}$') { throw 'Unsafe cleanup path.' } + if ($process -and $process.ExitCode -eq 0) { Remove-Item -LiteralPath $resolvedEngineDirectory -Recurse -Force } +} +if ($process.ExitCode -ne 0) { throw "csrun execution failed with exit code $($process.ExitCode). $diagnostics" } +if ($verifyTests) { Assert-CsrunTestOutput $output } +} \ No newline at end of file diff --git a/.docfx/run-actions/e3f79d1c0f2fa85276cee2fb/native.ps1 b/.docfx/run-actions/e3f79d1c0f2fa85276cee2fb/native.ps1 new file mode 100644 index 0000000..bf8e874 --- /dev/null +++ b/.docfx/run-actions/e3f79d1c0f2fa85276cee2fb/native.ps1 @@ -0,0 +1,85 @@ +& { +#requires -Version 7.0 +$ErrorActionPreference = 'Stop' +$PSNativeCommandUseErrorActionPreference = $false +$manifest = @' +{ + "dependsOn": [ + "Codebelt.Extensions.Xunit.Hosting@13.0.0", + "Microsoft.Extensions.Hosting@10.0.15" + ], + "framework": "net10.0", + "mode": "console", + "schemaVersion": 1, + "source": "using System;\nusing Codebelt.Extensions.Xunit.Hosting;\nusing Microsoft.Extensions.DependencyInjection;\n\nnamespace HostFixtureTests;\n\npublic class MinimalHostFactoryExample\n{\n public void Demonstrate()\n {\n using var host = MinimalHostTestFactory.Create(\n services => services.AddSingleton(new Version(1, 0, 0)));\n var version = host.Host.Services.GetRequiredService();\n Console.WriteLine(version);\n }\n}\n\ninternal static class RunExample\n{\n static void Main()\n {\n new MinimalHostFactoryExample().Demonstrate();\n }\n}" +} +'@ +$OutputEncoding = [Text.UTF8Encoding]::new($false) +[Console]::OutputEncoding = $OutputEncoding +$verifyTests = $false +function Assert-CsrunTestOutput([string] $Output) { + $lines = @($Output -split '\r?\n') + $headers = @($lines | Where-Object { $_ -match '^Test run summary: Passed! - .+\)$' }) + if ($headers.Count -ne 1) { throw 'Expected exactly one completed xUnit test summary.' } + $headerIndex = [Array]::IndexOf($lines, $headers[0]) + $summaryLines = @($lines | Select-Object -Skip ($headerIndex + 1) -First 4) + $counts = @{} + foreach ($line in $summaryLines) { + if ($line -match '^\s*(total|failed|succeeded|skipped):\s*(\d+)\s*$') { $counts[$Matches[1]] = [int]$Matches[2] } + } + if ($counts.Count -ne 4) { throw 'The xUnit test summary counts are incomplete or ambiguous.' } + $failed = $counts.failed + $passed = $counts.succeeded + $skipped = $counts.skipped + $total = $counts.total + if ($total -lt 1 -or $passed -lt 1 -or $failed -ne 0 -or $skipped -ne 0 -or $passed -ne $total) { + throw 'Tests must execute at least once, all pass, and none fail or skip.' + } +} +# Downloads and executes the latest stable csrun release with your permissions. +# Source and release history: https://github.com/codebeltnet/csrun +$engineDirectory = Join-Path ([IO.Path]::GetTempPath()) ('csrun-' + [guid]::NewGuid().ToString('N')) +$null = New-Item -ItemType Directory -Path $engineDirectory +$enginePath = Join-Path $engineDirectory 'csrun.ps1' +$process = $null +try { + $release = Invoke-RestMethod 'https://api.github.com/repos/codebeltnet/csrun/releases/latest' + $assets = @($release.assets | Where-Object name -CEQ 'csrun.ps1') + if ($assets.Count -ne 1 -or $assets[0].digest -notmatch '^sha256:[0-9a-f]{64}$') { + throw "csrun release $($release.tag_name) must publish one csrun.ps1 asset with a SHA-256 digest." + } + $asset = $assets[0] + Invoke-WebRequest $asset.browser_download_url -OutFile $enginePath + $actualHash = (Get-FileHash -LiteralPath $enginePath -Algorithm SHA256).Hash + if ("sha256:$actualHash" -ne $asset.digest) { throw "csrun asset checksum mismatch: $actualHash" } +$startInfo = [Diagnostics.ProcessStartInfo]::new('pwsh') +foreach ($argument in @('-NoProfile','-NonInteractive','-File')) { $startInfo.ArgumentList.Add($argument) } +$startInfo.ArgumentList.Add($enginePath) +$startInfo.ArgumentList.Add('-ManifestJson') +$startInfo.ArgumentList.Add($manifest) +$startInfo.RedirectStandardOutput = $true +$startInfo.RedirectStandardError = $true +$startInfo.UseShellExecute = $false +$process = [Diagnostics.Process]::new() +$process.StartInfo = $startInfo +if (-not $process.Start()) { throw 'Could not start csrun.' } +$stdoutTask = $process.StandardOutput.ReadToEndAsync() +$stderrTask = $process.StandardError.ReadToEndAsync() +$process.WaitForExit() +$output = $stdoutTask.GetAwaiter().GetResult() +$diagnostics = $stderrTask.GetAwaiter().GetResult() +Write-Output $output +if ($diagnostics) { [Console]::Error.Write($diagnostics) } +} catch { + [Console]::Error.WriteLine("csrun diagnostics retained in: $engineDirectory") + throw +} finally { + $resolvedTemp = [IO.Path]::TrimEndingDirectorySeparator([IO.Path]::GetFullPath([IO.Path]::GetTempPath())) + $resolvedEngineDirectory = [IO.Path]::GetFullPath($engineDirectory) + if ([IO.Path]::GetDirectoryName($resolvedEngineDirectory) -ne $resolvedTemp -or + [IO.Path]::GetFileName($resolvedEngineDirectory) -cnotmatch '^csrun-[a-f0-9]{32}$') { throw 'Unsafe cleanup path.' } + if ($process -and $process.ExitCode -eq 0) { Remove-Item -LiteralPath $resolvedEngineDirectory -Recurse -Force } +} +if ($process.ExitCode -ne 0) { throw "csrun execution failed with exit code $($process.ExitCode). $diagnostics" } +if ($verifyTests) { Assert-CsrunTestOutput $output } +} \ No newline at end of file diff --git a/.docfx/run-actions/e7dbb5ba733b205469239b03/docker.ps1 b/.docfx/run-actions/e7dbb5ba733b205469239b03/docker.ps1 new file mode 100644 index 0000000..d9e9557 --- /dev/null +++ b/.docfx/run-actions/e7dbb5ba733b205469239b03/docker.ps1 @@ -0,0 +1,83 @@ +& { +#requires -Version 7.0 +$ErrorActionPreference = 'Stop' +$PSNativeCommandUseErrorActionPreference = $false +$manifest = @' +{ + "dependsOn": [ + "Codebelt.Extensions.Xunit.Hosting@13.0.0", + "Microsoft.Extensions.Hosting@10.0.15", + "xunit.v3@4.0.3" + ], + "framework": "net10.0", + "mode": "test", + "schemaVersion": 1, + "source": "using Codebelt.Extensions.Xunit.Hosting;\nusing Xunit;\n\nnamespace HostFixtureTests;\n\npublic class HostStateGuard\n{\n public bool EnsureFixtureIsReady(IApplicationFixture fixture) where TEntryPoint : class\n {\n return fixture.HasValidState();\n }\n}\n\npublic sealed class RunExample\n{\n [Fact]\n public void ExercisesExample()\n {\n using var fixture = new ManagedApplicationFixture();\n Assert.False(new HostStateGuard().EnsureFixtureIsReady(fixture));\n }\n}" +} +'@ +$OutputEncoding = [Text.UTF8Encoding]::new($false) +[Console]::OutputEncoding = $OutputEncoding +$verifyTests = $true +function Assert-CsrunTestOutput([string] $Output) { + $lines = @($Output -split '\r?\n') + $headers = @($lines | Where-Object { $_ -match '^Test run summary: Passed! - .+\)$' }) + if ($headers.Count -ne 1) { throw 'Expected exactly one completed xUnit test summary.' } + $headerIndex = [Array]::IndexOf($lines, $headers[0]) + $summaryLines = @($lines | Select-Object -Skip ($headerIndex + 1) -First 4) + $counts = @{} + foreach ($line in $summaryLines) { + if ($line -match '^\s*(total|failed|succeeded|skipped):\s*(\d+)\s*$') { $counts[$Matches[1]] = [int]$Matches[2] } + } + if ($counts.Count -ne 4) { throw 'The xUnit test summary counts are incomplete or ambiguous.' } + $failed = $counts.failed + $passed = $counts.succeeded + $skipped = $counts.skipped + $total = $counts.total + if ($total -lt 1 -or $passed -lt 1 -or $failed -ne 0 -or $skipped -ne 0 -or $passed -ne $total) { + throw 'Tests must execute at least once, all pass, and none fail or skip.' + } +} +# Downloads and executes the latest stable csrun release with your permissions. +# Source and release history: https://github.com/codebeltnet/csrun +$engineDirectory = Join-Path ([IO.Path]::GetTempPath()) ('csrun-' + [guid]::NewGuid().ToString('N')) +$null = New-Item -ItemType Directory -Path $engineDirectory +$enginePath = Join-Path $engineDirectory 'csrun.ps1' +$process = $null +try { + $release = Invoke-RestMethod 'https://api.github.com/repos/codebeltnet/csrun/releases/latest' + $assets = @($release.assets | Where-Object name -CEQ 'csrun.ps1') + if ($assets.Count -ne 1 -or $assets[0].digest -notmatch '^sha256:[0-9a-f]{64}$') { + throw "csrun release $($release.tag_name) must publish one csrun.ps1 asset with a SHA-256 digest." + } + $asset = $assets[0] + Invoke-WebRequest $asset.browser_download_url -OutFile $enginePath + $actualHash = (Get-FileHash -LiteralPath $enginePath -Algorithm SHA256).Hash + if ("sha256:$actualHash" -ne $asset.digest) { throw "csrun asset checksum mismatch: $actualHash" } +$enginePayload = [Convert]::ToBase64String([IO.File]::ReadAllBytes($enginePath)) +$containerInput = $enginePayload + "`n" + $manifest +$command = ' +$ErrorActionPreference = "Stop" +$enginePath = Join-Path ([IO.Path]::GetTempPath()) ("csrun-release-" + [guid]::NewGuid().ToString("N") + ".ps1") +$engineBytes = [Convert]::FromBase64String([Console]::In.ReadLine()) +[IO.File]::WriteAllBytes($enginePath, $engineBytes) +$manifest = [Console]::In.ReadToEnd() +& $enginePath -ManifestJson $manifest +exit $LASTEXITCODE +' +$output = (@($containerInput | & docker run --rm -i --entrypoint pwsh 'codebeltnet/csrun:10' -NoProfile -NonInteractive -Command $command) -join [Environment]::NewLine) +$process = [pscustomobject]@{ ExitCode = $LASTEXITCODE } +$diagnostics = '' +Write-Output $output +} catch { + [Console]::Error.WriteLine("csrun diagnostics retained in: $engineDirectory") + throw +} finally { + $resolvedTemp = [IO.Path]::TrimEndingDirectorySeparator([IO.Path]::GetFullPath([IO.Path]::GetTempPath())) + $resolvedEngineDirectory = [IO.Path]::GetFullPath($engineDirectory) + if ([IO.Path]::GetDirectoryName($resolvedEngineDirectory) -ne $resolvedTemp -or + [IO.Path]::GetFileName($resolvedEngineDirectory) -cnotmatch '^csrun-[a-f0-9]{32}$') { throw 'Unsafe cleanup path.' } + if ($process -and $process.ExitCode -eq 0) { Remove-Item -LiteralPath $resolvedEngineDirectory -Recurse -Force } +} +if ($process.ExitCode -ne 0) { throw "csrun execution failed with exit code $($process.ExitCode). $diagnostics" } +if ($verifyTests) { Assert-CsrunTestOutput $output } +} \ No newline at end of file diff --git a/.docfx/run-actions/e7dbb5ba733b205469239b03/native.ps1 b/.docfx/run-actions/e7dbb5ba733b205469239b03/native.ps1 new file mode 100644 index 0000000..f5a0163 --- /dev/null +++ b/.docfx/run-actions/e7dbb5ba733b205469239b03/native.ps1 @@ -0,0 +1,86 @@ +& { +#requires -Version 7.0 +$ErrorActionPreference = 'Stop' +$PSNativeCommandUseErrorActionPreference = $false +$manifest = @' +{ + "dependsOn": [ + "Codebelt.Extensions.Xunit.Hosting@13.0.0", + "Microsoft.Extensions.Hosting@10.0.15", + "xunit.v3@4.0.3" + ], + "framework": "net10.0", + "mode": "test", + "schemaVersion": 1, + "source": "using Codebelt.Extensions.Xunit.Hosting;\nusing Xunit;\n\nnamespace HostFixtureTests;\n\npublic class HostStateGuard\n{\n public bool EnsureFixtureIsReady(IApplicationFixture fixture) where TEntryPoint : class\n {\n return fixture.HasValidState();\n }\n}\n\npublic sealed class RunExample\n{\n [Fact]\n public void ExercisesExample()\n {\n using var fixture = new ManagedApplicationFixture();\n Assert.False(new HostStateGuard().EnsureFixtureIsReady(fixture));\n }\n}" +} +'@ +$OutputEncoding = [Text.UTF8Encoding]::new($false) +[Console]::OutputEncoding = $OutputEncoding +$verifyTests = $true +function Assert-CsrunTestOutput([string] $Output) { + $lines = @($Output -split '\r?\n') + $headers = @($lines | Where-Object { $_ -match '^Test run summary: Passed! - .+\)$' }) + if ($headers.Count -ne 1) { throw 'Expected exactly one completed xUnit test summary.' } + $headerIndex = [Array]::IndexOf($lines, $headers[0]) + $summaryLines = @($lines | Select-Object -Skip ($headerIndex + 1) -First 4) + $counts = @{} + foreach ($line in $summaryLines) { + if ($line -match '^\s*(total|failed|succeeded|skipped):\s*(\d+)\s*$') { $counts[$Matches[1]] = [int]$Matches[2] } + } + if ($counts.Count -ne 4) { throw 'The xUnit test summary counts are incomplete or ambiguous.' } + $failed = $counts.failed + $passed = $counts.succeeded + $skipped = $counts.skipped + $total = $counts.total + if ($total -lt 1 -or $passed -lt 1 -or $failed -ne 0 -or $skipped -ne 0 -or $passed -ne $total) { + throw 'Tests must execute at least once, all pass, and none fail or skip.' + } +} +# Downloads and executes the latest stable csrun release with your permissions. +# Source and release history: https://github.com/codebeltnet/csrun +$engineDirectory = Join-Path ([IO.Path]::GetTempPath()) ('csrun-' + [guid]::NewGuid().ToString('N')) +$null = New-Item -ItemType Directory -Path $engineDirectory +$enginePath = Join-Path $engineDirectory 'csrun.ps1' +$process = $null +try { + $release = Invoke-RestMethod 'https://api.github.com/repos/codebeltnet/csrun/releases/latest' + $assets = @($release.assets | Where-Object name -CEQ 'csrun.ps1') + if ($assets.Count -ne 1 -or $assets[0].digest -notmatch '^sha256:[0-9a-f]{64}$') { + throw "csrun release $($release.tag_name) must publish one csrun.ps1 asset with a SHA-256 digest." + } + $asset = $assets[0] + Invoke-WebRequest $asset.browser_download_url -OutFile $enginePath + $actualHash = (Get-FileHash -LiteralPath $enginePath -Algorithm SHA256).Hash + if ("sha256:$actualHash" -ne $asset.digest) { throw "csrun asset checksum mismatch: $actualHash" } +$startInfo = [Diagnostics.ProcessStartInfo]::new('pwsh') +foreach ($argument in @('-NoProfile','-NonInteractive','-File')) { $startInfo.ArgumentList.Add($argument) } +$startInfo.ArgumentList.Add($enginePath) +$startInfo.ArgumentList.Add('-ManifestJson') +$startInfo.ArgumentList.Add($manifest) +$startInfo.RedirectStandardOutput = $true +$startInfo.RedirectStandardError = $true +$startInfo.UseShellExecute = $false +$process = [Diagnostics.Process]::new() +$process.StartInfo = $startInfo +if (-not $process.Start()) { throw 'Could not start csrun.' } +$stdoutTask = $process.StandardOutput.ReadToEndAsync() +$stderrTask = $process.StandardError.ReadToEndAsync() +$process.WaitForExit() +$output = $stdoutTask.GetAwaiter().GetResult() +$diagnostics = $stderrTask.GetAwaiter().GetResult() +Write-Output $output +if ($diagnostics) { [Console]::Error.Write($diagnostics) } +} catch { + [Console]::Error.WriteLine("csrun diagnostics retained in: $engineDirectory") + throw +} finally { + $resolvedTemp = [IO.Path]::TrimEndingDirectorySeparator([IO.Path]::GetFullPath([IO.Path]::GetTempPath())) + $resolvedEngineDirectory = [IO.Path]::GetFullPath($engineDirectory) + if ([IO.Path]::GetDirectoryName($resolvedEngineDirectory) -ne $resolvedTemp -or + [IO.Path]::GetFileName($resolvedEngineDirectory) -cnotmatch '^csrun-[a-f0-9]{32}$') { throw 'Unsafe cleanup path.' } + if ($process -and $process.ExitCode -eq 0) { Remove-Item -LiteralPath $resolvedEngineDirectory -Recurse -Force } +} +if ($process.ExitCode -ne 0) { throw "csrun execution failed with exit code $($process.ExitCode). $diagnostics" } +if ($verifyTests) { Assert-CsrunTestOutput $output } +} \ No newline at end of file diff --git a/.docfx/run-actions/f27f77d838407171b56f9073/docker.ps1 b/.docfx/run-actions/f27f77d838407171b56f9073/docker.ps1 new file mode 100644 index 0000000..9ce0032 --- /dev/null +++ b/.docfx/run-actions/f27f77d838407171b56f9073/docker.ps1 @@ -0,0 +1,86 @@ +& { +#requires -Version 7.0 +$ErrorActionPreference = 'Stop' +$PSNativeCommandUseErrorActionPreference = $false +$manifest = @' +{ + "dependsOn": [ + "Codebelt.Extensions.Xunit.Hosting.AspNetCore@13.0.0", + "Microsoft.AspNetCore.TestHost@10.0.15" + ], + "framework": "net10.0", + "frameworkReferences": [ + "Microsoft.AspNetCore.App" + ], + "mode": "console", + "schemaVersion": 1, + "sdk": "Microsoft.NET.Sdk.Web", + "source": "// Program.cs\nusing System;\nusing Codebelt.Extensions.Xunit.Hosting.AspNetCore;\nusing Microsoft.AspNetCore.Builder;\nusing Microsoft.AspNetCore.Http;\nusing Microsoft.AspNetCore.TestHost;\nusing Microsoft.Extensions.Hosting;\n\nusing var host = WebHostTestFactory.Create(\n pipelineSetup: app => app.Run(context =>\n context.Response.WriteAsync(\"started on demand\")),\n hostFixture: new SelfManagedWebHostFixture());\n\nawait host.Host.StartAsync().ConfigureAwait(false);\nusing var client = host.Host.GetTestClient();\n\nConsole.WriteLine(await client.GetStringAsync(\"/\").ConfigureAwait(false));" +} +'@ +$OutputEncoding = [Text.UTF8Encoding]::new($false) +[Console]::OutputEncoding = $OutputEncoding +$verifyTests = $false +function Assert-CsrunTestOutput([string] $Output) { + $lines = @($Output -split '\r?\n') + $headers = @($lines | Where-Object { $_ -match '^Test run summary: Passed! - .+\)$' }) + if ($headers.Count -ne 1) { throw 'Expected exactly one completed xUnit test summary.' } + $headerIndex = [Array]::IndexOf($lines, $headers[0]) + $summaryLines = @($lines | Select-Object -Skip ($headerIndex + 1) -First 4) + $counts = @{} + foreach ($line in $summaryLines) { + if ($line -match '^\s*(total|failed|succeeded|skipped):\s*(\d+)\s*$') { $counts[$Matches[1]] = [int]$Matches[2] } + } + if ($counts.Count -ne 4) { throw 'The xUnit test summary counts are incomplete or ambiguous.' } + $failed = $counts.failed + $passed = $counts.succeeded + $skipped = $counts.skipped + $total = $counts.total + if ($total -lt 1 -or $passed -lt 1 -or $failed -ne 0 -or $skipped -ne 0 -or $passed -ne $total) { + throw 'Tests must execute at least once, all pass, and none fail or skip.' + } +} +# Downloads and executes the latest stable csrun release with your permissions. +# Source and release history: https://github.com/codebeltnet/csrun +$engineDirectory = Join-Path ([IO.Path]::GetTempPath()) ('csrun-' + [guid]::NewGuid().ToString('N')) +$null = New-Item -ItemType Directory -Path $engineDirectory +$enginePath = Join-Path $engineDirectory 'csrun.ps1' +$process = $null +try { + $release = Invoke-RestMethod 'https://api.github.com/repos/codebeltnet/csrun/releases/latest' + $assets = @($release.assets | Where-Object name -CEQ 'csrun.ps1') + if ($assets.Count -ne 1 -or $assets[0].digest -notmatch '^sha256:[0-9a-f]{64}$') { + throw "csrun release $($release.tag_name) must publish one csrun.ps1 asset with a SHA-256 digest." + } + $asset = $assets[0] + Invoke-WebRequest $asset.browser_download_url -OutFile $enginePath + $actualHash = (Get-FileHash -LiteralPath $enginePath -Algorithm SHA256).Hash + if ("sha256:$actualHash" -ne $asset.digest) { throw "csrun asset checksum mismatch: $actualHash" } +$enginePayload = [Convert]::ToBase64String([IO.File]::ReadAllBytes($enginePath)) +$containerInput = $enginePayload + "`n" + $manifest +$command = ' +$ErrorActionPreference = "Stop" +$enginePath = Join-Path ([IO.Path]::GetTempPath()) ("csrun-release-" + [guid]::NewGuid().ToString("N") + ".ps1") +$engineBytes = [Convert]::FromBase64String([Console]::In.ReadLine()) +[IO.File]::WriteAllBytes($enginePath, $engineBytes) +$manifest = [Console]::In.ReadToEnd() +& $enginePath -ManifestJson $manifest +exit $LASTEXITCODE +' +$output = (@($containerInput | & docker run --rm -i --entrypoint pwsh 'codebeltnet/csrun:10' -NoProfile -NonInteractive -Command $command) -join [Environment]::NewLine) +$process = [pscustomobject]@{ ExitCode = $LASTEXITCODE } +$diagnostics = '' +Write-Output $output +} catch { + [Console]::Error.WriteLine("csrun diagnostics retained in: $engineDirectory") + throw +} finally { + $resolvedTemp = [IO.Path]::TrimEndingDirectorySeparator([IO.Path]::GetFullPath([IO.Path]::GetTempPath())) + $resolvedEngineDirectory = [IO.Path]::GetFullPath($engineDirectory) + if ([IO.Path]::GetDirectoryName($resolvedEngineDirectory) -ne $resolvedTemp -or + [IO.Path]::GetFileName($resolvedEngineDirectory) -cnotmatch '^csrun-[a-f0-9]{32}$') { throw 'Unsafe cleanup path.' } + if ($process -and $process.ExitCode -eq 0) { Remove-Item -LiteralPath $resolvedEngineDirectory -Recurse -Force } +} +if ($process.ExitCode -ne 0) { throw "csrun execution failed with exit code $($process.ExitCode). $diagnostics" } +if ($verifyTests) { Assert-CsrunTestOutput $output } +} \ No newline at end of file diff --git a/.docfx/run-actions/f27f77d838407171b56f9073/native.ps1 b/.docfx/run-actions/f27f77d838407171b56f9073/native.ps1 new file mode 100644 index 0000000..cb8804c --- /dev/null +++ b/.docfx/run-actions/f27f77d838407171b56f9073/native.ps1 @@ -0,0 +1,89 @@ +& { +#requires -Version 7.0 +$ErrorActionPreference = 'Stop' +$PSNativeCommandUseErrorActionPreference = $false +$manifest = @' +{ + "dependsOn": [ + "Codebelt.Extensions.Xunit.Hosting.AspNetCore@13.0.0", + "Microsoft.AspNetCore.TestHost@10.0.15" + ], + "framework": "net10.0", + "frameworkReferences": [ + "Microsoft.AspNetCore.App" + ], + "mode": "console", + "schemaVersion": 1, + "sdk": "Microsoft.NET.Sdk.Web", + "source": "// Program.cs\nusing System;\nusing Codebelt.Extensions.Xunit.Hosting.AspNetCore;\nusing Microsoft.AspNetCore.Builder;\nusing Microsoft.AspNetCore.Http;\nusing Microsoft.AspNetCore.TestHost;\nusing Microsoft.Extensions.Hosting;\n\nusing var host = WebHostTestFactory.Create(\n pipelineSetup: app => app.Run(context =>\n context.Response.WriteAsync(\"started on demand\")),\n hostFixture: new SelfManagedWebHostFixture());\n\nawait host.Host.StartAsync().ConfigureAwait(false);\nusing var client = host.Host.GetTestClient();\n\nConsole.WriteLine(await client.GetStringAsync(\"/\").ConfigureAwait(false));" +} +'@ +$OutputEncoding = [Text.UTF8Encoding]::new($false) +[Console]::OutputEncoding = $OutputEncoding +$verifyTests = $false +function Assert-CsrunTestOutput([string] $Output) { + $lines = @($Output -split '\r?\n') + $headers = @($lines | Where-Object { $_ -match '^Test run summary: Passed! - .+\)$' }) + if ($headers.Count -ne 1) { throw 'Expected exactly one completed xUnit test summary.' } + $headerIndex = [Array]::IndexOf($lines, $headers[0]) + $summaryLines = @($lines | Select-Object -Skip ($headerIndex + 1) -First 4) + $counts = @{} + foreach ($line in $summaryLines) { + if ($line -match '^\s*(total|failed|succeeded|skipped):\s*(\d+)\s*$') { $counts[$Matches[1]] = [int]$Matches[2] } + } + if ($counts.Count -ne 4) { throw 'The xUnit test summary counts are incomplete or ambiguous.' } + $failed = $counts.failed + $passed = $counts.succeeded + $skipped = $counts.skipped + $total = $counts.total + if ($total -lt 1 -or $passed -lt 1 -or $failed -ne 0 -or $skipped -ne 0 -or $passed -ne $total) { + throw 'Tests must execute at least once, all pass, and none fail or skip.' + } +} +# Downloads and executes the latest stable csrun release with your permissions. +# Source and release history: https://github.com/codebeltnet/csrun +$engineDirectory = Join-Path ([IO.Path]::GetTempPath()) ('csrun-' + [guid]::NewGuid().ToString('N')) +$null = New-Item -ItemType Directory -Path $engineDirectory +$enginePath = Join-Path $engineDirectory 'csrun.ps1' +$process = $null +try { + $release = Invoke-RestMethod 'https://api.github.com/repos/codebeltnet/csrun/releases/latest' + $assets = @($release.assets | Where-Object name -CEQ 'csrun.ps1') + if ($assets.Count -ne 1 -or $assets[0].digest -notmatch '^sha256:[0-9a-f]{64}$') { + throw "csrun release $($release.tag_name) must publish one csrun.ps1 asset with a SHA-256 digest." + } + $asset = $assets[0] + Invoke-WebRequest $asset.browser_download_url -OutFile $enginePath + $actualHash = (Get-FileHash -LiteralPath $enginePath -Algorithm SHA256).Hash + if ("sha256:$actualHash" -ne $asset.digest) { throw "csrun asset checksum mismatch: $actualHash" } +$startInfo = [Diagnostics.ProcessStartInfo]::new('pwsh') +foreach ($argument in @('-NoProfile','-NonInteractive','-File')) { $startInfo.ArgumentList.Add($argument) } +$startInfo.ArgumentList.Add($enginePath) +$startInfo.ArgumentList.Add('-ManifestJson') +$startInfo.ArgumentList.Add($manifest) +$startInfo.RedirectStandardOutput = $true +$startInfo.RedirectStandardError = $true +$startInfo.UseShellExecute = $false +$process = [Diagnostics.Process]::new() +$process.StartInfo = $startInfo +if (-not $process.Start()) { throw 'Could not start csrun.' } +$stdoutTask = $process.StandardOutput.ReadToEndAsync() +$stderrTask = $process.StandardError.ReadToEndAsync() +$process.WaitForExit() +$output = $stdoutTask.GetAwaiter().GetResult() +$diagnostics = $stderrTask.GetAwaiter().GetResult() +Write-Output $output +if ($diagnostics) { [Console]::Error.Write($diagnostics) } +} catch { + [Console]::Error.WriteLine("csrun diagnostics retained in: $engineDirectory") + throw +} finally { + $resolvedTemp = [IO.Path]::TrimEndingDirectorySeparator([IO.Path]::GetFullPath([IO.Path]::GetTempPath())) + $resolvedEngineDirectory = [IO.Path]::GetFullPath($engineDirectory) + if ([IO.Path]::GetDirectoryName($resolvedEngineDirectory) -ne $resolvedTemp -or + [IO.Path]::GetFileName($resolvedEngineDirectory) -cnotmatch '^csrun-[a-f0-9]{32}$') { throw 'Unsafe cleanup path.' } + if ($process -and $process.ExitCode -eq 0) { Remove-Item -LiteralPath $resolvedEngineDirectory -Recurse -Force } +} +if ($process.ExitCode -ne 0) { throw "csrun execution failed with exit code $($process.ExitCode). $diagnostics" } +if ($verifyTests) { Assert-CsrunTestOutput $output } +} \ No newline at end of file diff --git a/.docfx/run-actions/f3c0856195727da12ff2925f/docker.ps1 b/.docfx/run-actions/f3c0856195727da12ff2925f/docker.ps1 new file mode 100644 index 0000000..662bdd0 --- /dev/null +++ b/.docfx/run-actions/f3c0856195727da12ff2925f/docker.ps1 @@ -0,0 +1,85 @@ +& { +#requires -Version 7.0 +$ErrorActionPreference = 'Stop' +$PSNativeCommandUseErrorActionPreference = $false +$manifest = @' +{ + "dependsOn": [ + "Codebelt.Extensions.Xunit.Hosting.AspNetCore@13.0.0", + "xunit.v3@4.0.3" + ], + "framework": "net10.0", + "frameworkReferences": [ + "Microsoft.AspNetCore.App" + ], + "mode": "test", + "schemaVersion": 1, + "source": "using Codebelt.Extensions.Xunit.Hosting.AspNetCore;\nusing Microsoft.AspNetCore.Http;\nusing Microsoft.Extensions.DependencyInjection;\nusing Xunit;\n\nnamespace WebFixtureTests;\n\npublic class ExampleFixture\n{\n public IServiceCollection ConfigureServices(IServiceCollection services)\n {\n return services.AddFakeHttpContextAccessor(ServiceLifetime.Scoped);\n }\n}\n\npublic sealed class RunExample\n{\n [Fact]\n public void ExercisesExample()\n {\n using var provider = new ExampleFixture().ConfigureServices(new ServiceCollection()).BuildServiceProvider();\n using var scope = provider.CreateScope();\n Assert.IsType(scope.ServiceProvider.GetRequiredService());\n }\n}" +} +'@ +$OutputEncoding = [Text.UTF8Encoding]::new($false) +[Console]::OutputEncoding = $OutputEncoding +$verifyTests = $true +function Assert-CsrunTestOutput([string] $Output) { + $lines = @($Output -split '\r?\n') + $headers = @($lines | Where-Object { $_ -match '^Test run summary: Passed! - .+\)$' }) + if ($headers.Count -ne 1) { throw 'Expected exactly one completed xUnit test summary.' } + $headerIndex = [Array]::IndexOf($lines, $headers[0]) + $summaryLines = @($lines | Select-Object -Skip ($headerIndex + 1) -First 4) + $counts = @{} + foreach ($line in $summaryLines) { + if ($line -match '^\s*(total|failed|succeeded|skipped):\s*(\d+)\s*$') { $counts[$Matches[1]] = [int]$Matches[2] } + } + if ($counts.Count -ne 4) { throw 'The xUnit test summary counts are incomplete or ambiguous.' } + $failed = $counts.failed + $passed = $counts.succeeded + $skipped = $counts.skipped + $total = $counts.total + if ($total -lt 1 -or $passed -lt 1 -or $failed -ne 0 -or $skipped -ne 0 -or $passed -ne $total) { + throw 'Tests must execute at least once, all pass, and none fail or skip.' + } +} +# Downloads and executes the latest stable csrun release with your permissions. +# Source and release history: https://github.com/codebeltnet/csrun +$engineDirectory = Join-Path ([IO.Path]::GetTempPath()) ('csrun-' + [guid]::NewGuid().ToString('N')) +$null = New-Item -ItemType Directory -Path $engineDirectory +$enginePath = Join-Path $engineDirectory 'csrun.ps1' +$process = $null +try { + $release = Invoke-RestMethod 'https://api.github.com/repos/codebeltnet/csrun/releases/latest' + $assets = @($release.assets | Where-Object name -CEQ 'csrun.ps1') + if ($assets.Count -ne 1 -or $assets[0].digest -notmatch '^sha256:[0-9a-f]{64}$') { + throw "csrun release $($release.tag_name) must publish one csrun.ps1 asset with a SHA-256 digest." + } + $asset = $assets[0] + Invoke-WebRequest $asset.browser_download_url -OutFile $enginePath + $actualHash = (Get-FileHash -LiteralPath $enginePath -Algorithm SHA256).Hash + if ("sha256:$actualHash" -ne $asset.digest) { throw "csrun asset checksum mismatch: $actualHash" } +$enginePayload = [Convert]::ToBase64String([IO.File]::ReadAllBytes($enginePath)) +$containerInput = $enginePayload + "`n" + $manifest +$command = ' +$ErrorActionPreference = "Stop" +$enginePath = Join-Path ([IO.Path]::GetTempPath()) ("csrun-release-" + [guid]::NewGuid().ToString("N") + ".ps1") +$engineBytes = [Convert]::FromBase64String([Console]::In.ReadLine()) +[IO.File]::WriteAllBytes($enginePath, $engineBytes) +$manifest = [Console]::In.ReadToEnd() +& $enginePath -ManifestJson $manifest +exit $LASTEXITCODE +' +$output = (@($containerInput | & docker run --rm -i --entrypoint pwsh 'codebeltnet/csrun:10' -NoProfile -NonInteractive -Command $command) -join [Environment]::NewLine) +$process = [pscustomobject]@{ ExitCode = $LASTEXITCODE } +$diagnostics = '' +Write-Output $output +} catch { + [Console]::Error.WriteLine("csrun diagnostics retained in: $engineDirectory") + throw +} finally { + $resolvedTemp = [IO.Path]::TrimEndingDirectorySeparator([IO.Path]::GetFullPath([IO.Path]::GetTempPath())) + $resolvedEngineDirectory = [IO.Path]::GetFullPath($engineDirectory) + if ([IO.Path]::GetDirectoryName($resolvedEngineDirectory) -ne $resolvedTemp -or + [IO.Path]::GetFileName($resolvedEngineDirectory) -cnotmatch '^csrun-[a-f0-9]{32}$') { throw 'Unsafe cleanup path.' } + if ($process -and $process.ExitCode -eq 0) { Remove-Item -LiteralPath $resolvedEngineDirectory -Recurse -Force } +} +if ($process.ExitCode -ne 0) { throw "csrun execution failed with exit code $($process.ExitCode). $diagnostics" } +if ($verifyTests) { Assert-CsrunTestOutput $output } +} \ No newline at end of file diff --git a/.docfx/run-actions/f3c0856195727da12ff2925f/native.ps1 b/.docfx/run-actions/f3c0856195727da12ff2925f/native.ps1 new file mode 100644 index 0000000..590b9c2 --- /dev/null +++ b/.docfx/run-actions/f3c0856195727da12ff2925f/native.ps1 @@ -0,0 +1,88 @@ +& { +#requires -Version 7.0 +$ErrorActionPreference = 'Stop' +$PSNativeCommandUseErrorActionPreference = $false +$manifest = @' +{ + "dependsOn": [ + "Codebelt.Extensions.Xunit.Hosting.AspNetCore@13.0.0", + "xunit.v3@4.0.3" + ], + "framework": "net10.0", + "frameworkReferences": [ + "Microsoft.AspNetCore.App" + ], + "mode": "test", + "schemaVersion": 1, + "source": "using Codebelt.Extensions.Xunit.Hosting.AspNetCore;\nusing Microsoft.AspNetCore.Http;\nusing Microsoft.Extensions.DependencyInjection;\nusing Xunit;\n\nnamespace WebFixtureTests;\n\npublic class ExampleFixture\n{\n public IServiceCollection ConfigureServices(IServiceCollection services)\n {\n return services.AddFakeHttpContextAccessor(ServiceLifetime.Scoped);\n }\n}\n\npublic sealed class RunExample\n{\n [Fact]\n public void ExercisesExample()\n {\n using var provider = new ExampleFixture().ConfigureServices(new ServiceCollection()).BuildServiceProvider();\n using var scope = provider.CreateScope();\n Assert.IsType(scope.ServiceProvider.GetRequiredService());\n }\n}" +} +'@ +$OutputEncoding = [Text.UTF8Encoding]::new($false) +[Console]::OutputEncoding = $OutputEncoding +$verifyTests = $true +function Assert-CsrunTestOutput([string] $Output) { + $lines = @($Output -split '\r?\n') + $headers = @($lines | Where-Object { $_ -match '^Test run summary: Passed! - .+\)$' }) + if ($headers.Count -ne 1) { throw 'Expected exactly one completed xUnit test summary.' } + $headerIndex = [Array]::IndexOf($lines, $headers[0]) + $summaryLines = @($lines | Select-Object -Skip ($headerIndex + 1) -First 4) + $counts = @{} + foreach ($line in $summaryLines) { + if ($line -match '^\s*(total|failed|succeeded|skipped):\s*(\d+)\s*$') { $counts[$Matches[1]] = [int]$Matches[2] } + } + if ($counts.Count -ne 4) { throw 'The xUnit test summary counts are incomplete or ambiguous.' } + $failed = $counts.failed + $passed = $counts.succeeded + $skipped = $counts.skipped + $total = $counts.total + if ($total -lt 1 -or $passed -lt 1 -or $failed -ne 0 -or $skipped -ne 0 -or $passed -ne $total) { + throw 'Tests must execute at least once, all pass, and none fail or skip.' + } +} +# Downloads and executes the latest stable csrun release with your permissions. +# Source and release history: https://github.com/codebeltnet/csrun +$engineDirectory = Join-Path ([IO.Path]::GetTempPath()) ('csrun-' + [guid]::NewGuid().ToString('N')) +$null = New-Item -ItemType Directory -Path $engineDirectory +$enginePath = Join-Path $engineDirectory 'csrun.ps1' +$process = $null +try { + $release = Invoke-RestMethod 'https://api.github.com/repos/codebeltnet/csrun/releases/latest' + $assets = @($release.assets | Where-Object name -CEQ 'csrun.ps1') + if ($assets.Count -ne 1 -or $assets[0].digest -notmatch '^sha256:[0-9a-f]{64}$') { + throw "csrun release $($release.tag_name) must publish one csrun.ps1 asset with a SHA-256 digest." + } + $asset = $assets[0] + Invoke-WebRequest $asset.browser_download_url -OutFile $enginePath + $actualHash = (Get-FileHash -LiteralPath $enginePath -Algorithm SHA256).Hash + if ("sha256:$actualHash" -ne $asset.digest) { throw "csrun asset checksum mismatch: $actualHash" } +$startInfo = [Diagnostics.ProcessStartInfo]::new('pwsh') +foreach ($argument in @('-NoProfile','-NonInteractive','-File')) { $startInfo.ArgumentList.Add($argument) } +$startInfo.ArgumentList.Add($enginePath) +$startInfo.ArgumentList.Add('-ManifestJson') +$startInfo.ArgumentList.Add($manifest) +$startInfo.RedirectStandardOutput = $true +$startInfo.RedirectStandardError = $true +$startInfo.UseShellExecute = $false +$process = [Diagnostics.Process]::new() +$process.StartInfo = $startInfo +if (-not $process.Start()) { throw 'Could not start csrun.' } +$stdoutTask = $process.StandardOutput.ReadToEndAsync() +$stderrTask = $process.StandardError.ReadToEndAsync() +$process.WaitForExit() +$output = $stdoutTask.GetAwaiter().GetResult() +$diagnostics = $stderrTask.GetAwaiter().GetResult() +Write-Output $output +if ($diagnostics) { [Console]::Error.Write($diagnostics) } +} catch { + [Console]::Error.WriteLine("csrun diagnostics retained in: $engineDirectory") + throw +} finally { + $resolvedTemp = [IO.Path]::TrimEndingDirectorySeparator([IO.Path]::GetFullPath([IO.Path]::GetTempPath())) + $resolvedEngineDirectory = [IO.Path]::GetFullPath($engineDirectory) + if ([IO.Path]::GetDirectoryName($resolvedEngineDirectory) -ne $resolvedTemp -or + [IO.Path]::GetFileName($resolvedEngineDirectory) -cnotmatch '^csrun-[a-f0-9]{32}$') { throw 'Unsafe cleanup path.' } + if ($process -and $process.ExitCode -eq 0) { Remove-Item -LiteralPath $resolvedEngineDirectory -Recurse -Force } +} +if ($process.ExitCode -ne 0) { throw "csrun execution failed with exit code $($process.ExitCode). $diagnostics" } +if ($verifyTests) { Assert-CsrunTestOutput $output } +} \ No newline at end of file diff --git a/.docfx/run-actions/f5ed7c321a52580d7ce11408/docker.ps1 b/.docfx/run-actions/f5ed7c321a52580d7ce11408/docker.ps1 new file mode 100644 index 0000000..9cfda59 --- /dev/null +++ b/.docfx/run-actions/f5ed7c321a52580d7ce11408/docker.ps1 @@ -0,0 +1,85 @@ +& { +#requires -Version 7.0 +$ErrorActionPreference = 'Stop' +$PSNativeCommandUseErrorActionPreference = $false +$manifest = @' +{ + "dependsOn": [ + "Codebelt.Extensions.Xunit.Hosting.AspNetCore@13.0.0" + ], + "framework": "net10.0", + "frameworkReferences": [ + "Microsoft.AspNetCore.App" + ], + "mode": "console", + "schemaVersion": 1, + "sdk": "Microsoft.NET.Sdk.Web", + "source": "using System;\nusing Codebelt.Extensions.Xunit.Hosting.AspNetCore.Http.Features;\n\nnamespace WebFixtureTests;\n\npublic class RequestFeatureExample\n{\n public void Demonstrate()\n {\n var request = new FakeHttpRequestFeature();\n Console.WriteLine(request.Method);\n }\n}\n\ninternal static class RunExample\n{\n static void Main()\n {\n new RequestFeatureExample().Demonstrate();\n }\n}" +} +'@ +$OutputEncoding = [Text.UTF8Encoding]::new($false) +[Console]::OutputEncoding = $OutputEncoding +$verifyTests = $false +function Assert-CsrunTestOutput([string] $Output) { + $lines = @($Output -split '\r?\n') + $headers = @($lines | Where-Object { $_ -match '^Test run summary: Passed! - .+\)$' }) + if ($headers.Count -ne 1) { throw 'Expected exactly one completed xUnit test summary.' } + $headerIndex = [Array]::IndexOf($lines, $headers[0]) + $summaryLines = @($lines | Select-Object -Skip ($headerIndex + 1) -First 4) + $counts = @{} + foreach ($line in $summaryLines) { + if ($line -match '^\s*(total|failed|succeeded|skipped):\s*(\d+)\s*$') { $counts[$Matches[1]] = [int]$Matches[2] } + } + if ($counts.Count -ne 4) { throw 'The xUnit test summary counts are incomplete or ambiguous.' } + $failed = $counts.failed + $passed = $counts.succeeded + $skipped = $counts.skipped + $total = $counts.total + if ($total -lt 1 -or $passed -lt 1 -or $failed -ne 0 -or $skipped -ne 0 -or $passed -ne $total) { + throw 'Tests must execute at least once, all pass, and none fail or skip.' + } +} +# Downloads and executes the latest stable csrun release with your permissions. +# Source and release history: https://github.com/codebeltnet/csrun +$engineDirectory = Join-Path ([IO.Path]::GetTempPath()) ('csrun-' + [guid]::NewGuid().ToString('N')) +$null = New-Item -ItemType Directory -Path $engineDirectory +$enginePath = Join-Path $engineDirectory 'csrun.ps1' +$process = $null +try { + $release = Invoke-RestMethod 'https://api.github.com/repos/codebeltnet/csrun/releases/latest' + $assets = @($release.assets | Where-Object name -CEQ 'csrun.ps1') + if ($assets.Count -ne 1 -or $assets[0].digest -notmatch '^sha256:[0-9a-f]{64}$') { + throw "csrun release $($release.tag_name) must publish one csrun.ps1 asset with a SHA-256 digest." + } + $asset = $assets[0] + Invoke-WebRequest $asset.browser_download_url -OutFile $enginePath + $actualHash = (Get-FileHash -LiteralPath $enginePath -Algorithm SHA256).Hash + if ("sha256:$actualHash" -ne $asset.digest) { throw "csrun asset checksum mismatch: $actualHash" } +$enginePayload = [Convert]::ToBase64String([IO.File]::ReadAllBytes($enginePath)) +$containerInput = $enginePayload + "`n" + $manifest +$command = ' +$ErrorActionPreference = "Stop" +$enginePath = Join-Path ([IO.Path]::GetTempPath()) ("csrun-release-" + [guid]::NewGuid().ToString("N") + ".ps1") +$engineBytes = [Convert]::FromBase64String([Console]::In.ReadLine()) +[IO.File]::WriteAllBytes($enginePath, $engineBytes) +$manifest = [Console]::In.ReadToEnd() +& $enginePath -ManifestJson $manifest +exit $LASTEXITCODE +' +$output = (@($containerInput | & docker run --rm -i --entrypoint pwsh 'codebeltnet/csrun:10' -NoProfile -NonInteractive -Command $command) -join [Environment]::NewLine) +$process = [pscustomobject]@{ ExitCode = $LASTEXITCODE } +$diagnostics = '' +Write-Output $output +} catch { + [Console]::Error.WriteLine("csrun diagnostics retained in: $engineDirectory") + throw +} finally { + $resolvedTemp = [IO.Path]::TrimEndingDirectorySeparator([IO.Path]::GetFullPath([IO.Path]::GetTempPath())) + $resolvedEngineDirectory = [IO.Path]::GetFullPath($engineDirectory) + if ([IO.Path]::GetDirectoryName($resolvedEngineDirectory) -ne $resolvedTemp -or + [IO.Path]::GetFileName($resolvedEngineDirectory) -cnotmatch '^csrun-[a-f0-9]{32}$') { throw 'Unsafe cleanup path.' } + if ($process -and $process.ExitCode -eq 0) { Remove-Item -LiteralPath $resolvedEngineDirectory -Recurse -Force } +} +if ($process.ExitCode -ne 0) { throw "csrun execution failed with exit code $($process.ExitCode). $diagnostics" } +if ($verifyTests) { Assert-CsrunTestOutput $output } +} \ No newline at end of file diff --git a/.docfx/run-actions/f5ed7c321a52580d7ce11408/native.ps1 b/.docfx/run-actions/f5ed7c321a52580d7ce11408/native.ps1 new file mode 100644 index 0000000..4afa911 --- /dev/null +++ b/.docfx/run-actions/f5ed7c321a52580d7ce11408/native.ps1 @@ -0,0 +1,88 @@ +& { +#requires -Version 7.0 +$ErrorActionPreference = 'Stop' +$PSNativeCommandUseErrorActionPreference = $false +$manifest = @' +{ + "dependsOn": [ + "Codebelt.Extensions.Xunit.Hosting.AspNetCore@13.0.0" + ], + "framework": "net10.0", + "frameworkReferences": [ + "Microsoft.AspNetCore.App" + ], + "mode": "console", + "schemaVersion": 1, + "sdk": "Microsoft.NET.Sdk.Web", + "source": "using System;\nusing Codebelt.Extensions.Xunit.Hosting.AspNetCore.Http.Features;\n\nnamespace WebFixtureTests;\n\npublic class RequestFeatureExample\n{\n public void Demonstrate()\n {\n var request = new FakeHttpRequestFeature();\n Console.WriteLine(request.Method);\n }\n}\n\ninternal static class RunExample\n{\n static void Main()\n {\n new RequestFeatureExample().Demonstrate();\n }\n}" +} +'@ +$OutputEncoding = [Text.UTF8Encoding]::new($false) +[Console]::OutputEncoding = $OutputEncoding +$verifyTests = $false +function Assert-CsrunTestOutput([string] $Output) { + $lines = @($Output -split '\r?\n') + $headers = @($lines | Where-Object { $_ -match '^Test run summary: Passed! - .+\)$' }) + if ($headers.Count -ne 1) { throw 'Expected exactly one completed xUnit test summary.' } + $headerIndex = [Array]::IndexOf($lines, $headers[0]) + $summaryLines = @($lines | Select-Object -Skip ($headerIndex + 1) -First 4) + $counts = @{} + foreach ($line in $summaryLines) { + if ($line -match '^\s*(total|failed|succeeded|skipped):\s*(\d+)\s*$') { $counts[$Matches[1]] = [int]$Matches[2] } + } + if ($counts.Count -ne 4) { throw 'The xUnit test summary counts are incomplete or ambiguous.' } + $failed = $counts.failed + $passed = $counts.succeeded + $skipped = $counts.skipped + $total = $counts.total + if ($total -lt 1 -or $passed -lt 1 -or $failed -ne 0 -or $skipped -ne 0 -or $passed -ne $total) { + throw 'Tests must execute at least once, all pass, and none fail or skip.' + } +} +# Downloads and executes the latest stable csrun release with your permissions. +# Source and release history: https://github.com/codebeltnet/csrun +$engineDirectory = Join-Path ([IO.Path]::GetTempPath()) ('csrun-' + [guid]::NewGuid().ToString('N')) +$null = New-Item -ItemType Directory -Path $engineDirectory +$enginePath = Join-Path $engineDirectory 'csrun.ps1' +$process = $null +try { + $release = Invoke-RestMethod 'https://api.github.com/repos/codebeltnet/csrun/releases/latest' + $assets = @($release.assets | Where-Object name -CEQ 'csrun.ps1') + if ($assets.Count -ne 1 -or $assets[0].digest -notmatch '^sha256:[0-9a-f]{64}$') { + throw "csrun release $($release.tag_name) must publish one csrun.ps1 asset with a SHA-256 digest." + } + $asset = $assets[0] + Invoke-WebRequest $asset.browser_download_url -OutFile $enginePath + $actualHash = (Get-FileHash -LiteralPath $enginePath -Algorithm SHA256).Hash + if ("sha256:$actualHash" -ne $asset.digest) { throw "csrun asset checksum mismatch: $actualHash" } +$startInfo = [Diagnostics.ProcessStartInfo]::new('pwsh') +foreach ($argument in @('-NoProfile','-NonInteractive','-File')) { $startInfo.ArgumentList.Add($argument) } +$startInfo.ArgumentList.Add($enginePath) +$startInfo.ArgumentList.Add('-ManifestJson') +$startInfo.ArgumentList.Add($manifest) +$startInfo.RedirectStandardOutput = $true +$startInfo.RedirectStandardError = $true +$startInfo.UseShellExecute = $false +$process = [Diagnostics.Process]::new() +$process.StartInfo = $startInfo +if (-not $process.Start()) { throw 'Could not start csrun.' } +$stdoutTask = $process.StandardOutput.ReadToEndAsync() +$stderrTask = $process.StandardError.ReadToEndAsync() +$process.WaitForExit() +$output = $stdoutTask.GetAwaiter().GetResult() +$diagnostics = $stderrTask.GetAwaiter().GetResult() +Write-Output $output +if ($diagnostics) { [Console]::Error.Write($diagnostics) } +} catch { + [Console]::Error.WriteLine("csrun diagnostics retained in: $engineDirectory") + throw +} finally { + $resolvedTemp = [IO.Path]::TrimEndingDirectorySeparator([IO.Path]::GetFullPath([IO.Path]::GetTempPath())) + $resolvedEngineDirectory = [IO.Path]::GetFullPath($engineDirectory) + if ([IO.Path]::GetDirectoryName($resolvedEngineDirectory) -ne $resolvedTemp -or + [IO.Path]::GetFileName($resolvedEngineDirectory) -cnotmatch '^csrun-[a-f0-9]{32}$') { throw 'Unsafe cleanup path.' } + if ($process -and $process.ExitCode -eq 0) { Remove-Item -LiteralPath $resolvedEngineDirectory -Recurse -Force } +} +if ($process.ExitCode -ne 0) { throw "csrun execution failed with exit code $($process.ExitCode). $diagnostics" } +if ($verifyTests) { Assert-CsrunTestOutput $output } +} \ No newline at end of file diff --git a/.docfx/run-actions/ff2e361441bdc3028ab188a9/docker.ps1 b/.docfx/run-actions/ff2e361441bdc3028ab188a9/docker.ps1 new file mode 100644 index 0000000..ccd3895 --- /dev/null +++ b/.docfx/run-actions/ff2e361441bdc3028ab188a9/docker.ps1 @@ -0,0 +1,82 @@ +& { +#requires -Version 7.0 +$ErrorActionPreference = 'Stop' +$PSNativeCommandUseErrorActionPreference = $false +$manifest = @' +{ + "dependsOn": [ + "Codebelt.Extensions.Xunit.Hosting@13.0.0", + "Microsoft.Extensions.Hosting@10.0.15" + ], + "framework": "net10.0", + "mode": "console", + "schemaVersion": 1, + "source": "using System;\nusing Codebelt.Extensions.Xunit.Hosting;\nusing Microsoft.Extensions.DependencyInjection;\nusing Microsoft.Extensions.Hosting;\n\nnamespace WorkerApp.Tests;\n\npublic sealed class ApplicationHostFactoryExample\n{\n public string GetTestIdentity()\n {\n using IHost host = ApplicationHostFactory.Create(builder =>\n {\n builder.ConfigureServices(services =>\n services.AddSingleton(new WorkerIdentity(\"Test inventory worker\")));\n });\n\n var identity = host.Services.GetRequiredService();\n return identity.Name;\n }\n}\n\npublic sealed record WorkerIdentity(string Name);\n\npublic sealed class WorkerProgram\n{\n public static IHostBuilder CreateHostBuilder(string[] args)\n {\n return Host.CreateDefaultBuilder(args);\n }\n\n public static void Main(string[] args)\n {\n var identity = new ApplicationHostFactoryExample().GetTestIdentity();\n if (identity != \"Test inventory worker\")\n {\n throw new InvalidOperationException(identity);\n }\n\n Console.WriteLine(identity);\n }\n}" +} +'@ +$OutputEncoding = [Text.UTF8Encoding]::new($false) +[Console]::OutputEncoding = $OutputEncoding +$verifyTests = $false +function Assert-CsrunTestOutput([string] $Output) { + $lines = @($Output -split '\r?\n') + $headers = @($lines | Where-Object { $_ -match '^Test run summary: Passed! - .+\)$' }) + if ($headers.Count -ne 1) { throw 'Expected exactly one completed xUnit test summary.' } + $headerIndex = [Array]::IndexOf($lines, $headers[0]) + $summaryLines = @($lines | Select-Object -Skip ($headerIndex + 1) -First 4) + $counts = @{} + foreach ($line in $summaryLines) { + if ($line -match '^\s*(total|failed|succeeded|skipped):\s*(\d+)\s*$') { $counts[$Matches[1]] = [int]$Matches[2] } + } + if ($counts.Count -ne 4) { throw 'The xUnit test summary counts are incomplete or ambiguous.' } + $failed = $counts.failed + $passed = $counts.succeeded + $skipped = $counts.skipped + $total = $counts.total + if ($total -lt 1 -or $passed -lt 1 -or $failed -ne 0 -or $skipped -ne 0 -or $passed -ne $total) { + throw 'Tests must execute at least once, all pass, and none fail or skip.' + } +} +# Downloads and executes the latest stable csrun release with your permissions. +# Source and release history: https://github.com/codebeltnet/csrun +$engineDirectory = Join-Path ([IO.Path]::GetTempPath()) ('csrun-' + [guid]::NewGuid().ToString('N')) +$null = New-Item -ItemType Directory -Path $engineDirectory +$enginePath = Join-Path $engineDirectory 'csrun.ps1' +$process = $null +try { + $release = Invoke-RestMethod 'https://api.github.com/repos/codebeltnet/csrun/releases/latest' + $assets = @($release.assets | Where-Object name -CEQ 'csrun.ps1') + if ($assets.Count -ne 1 -or $assets[0].digest -notmatch '^sha256:[0-9a-f]{64}$') { + throw "csrun release $($release.tag_name) must publish one csrun.ps1 asset with a SHA-256 digest." + } + $asset = $assets[0] + Invoke-WebRequest $asset.browser_download_url -OutFile $enginePath + $actualHash = (Get-FileHash -LiteralPath $enginePath -Algorithm SHA256).Hash + if ("sha256:$actualHash" -ne $asset.digest) { throw "csrun asset checksum mismatch: $actualHash" } +$enginePayload = [Convert]::ToBase64String([IO.File]::ReadAllBytes($enginePath)) +$containerInput = $enginePayload + "`n" + $manifest +$command = ' +$ErrorActionPreference = "Stop" +$enginePath = Join-Path ([IO.Path]::GetTempPath()) ("csrun-release-" + [guid]::NewGuid().ToString("N") + ".ps1") +$engineBytes = [Convert]::FromBase64String([Console]::In.ReadLine()) +[IO.File]::WriteAllBytes($enginePath, $engineBytes) +$manifest = [Console]::In.ReadToEnd() +& $enginePath -ManifestJson $manifest +exit $LASTEXITCODE +' +$output = (@($containerInput | & docker run --rm -i --entrypoint pwsh 'codebeltnet/csrun:10' -NoProfile -NonInteractive -Command $command) -join [Environment]::NewLine) +$process = [pscustomobject]@{ ExitCode = $LASTEXITCODE } +$diagnostics = '' +Write-Output $output +} catch { + [Console]::Error.WriteLine("csrun diagnostics retained in: $engineDirectory") + throw +} finally { + $resolvedTemp = [IO.Path]::TrimEndingDirectorySeparator([IO.Path]::GetFullPath([IO.Path]::GetTempPath())) + $resolvedEngineDirectory = [IO.Path]::GetFullPath($engineDirectory) + if ([IO.Path]::GetDirectoryName($resolvedEngineDirectory) -ne $resolvedTemp -or + [IO.Path]::GetFileName($resolvedEngineDirectory) -cnotmatch '^csrun-[a-f0-9]{32}$') { throw 'Unsafe cleanup path.' } + if ($process -and $process.ExitCode -eq 0) { Remove-Item -LiteralPath $resolvedEngineDirectory -Recurse -Force } +} +if ($process.ExitCode -ne 0) { throw "csrun execution failed with exit code $($process.ExitCode). $diagnostics" } +if ($verifyTests) { Assert-CsrunTestOutput $output } +} \ No newline at end of file diff --git a/.docfx/run-actions/ff2e361441bdc3028ab188a9/native.ps1 b/.docfx/run-actions/ff2e361441bdc3028ab188a9/native.ps1 new file mode 100644 index 0000000..36eb6bc --- /dev/null +++ b/.docfx/run-actions/ff2e361441bdc3028ab188a9/native.ps1 @@ -0,0 +1,85 @@ +& { +#requires -Version 7.0 +$ErrorActionPreference = 'Stop' +$PSNativeCommandUseErrorActionPreference = $false +$manifest = @' +{ + "dependsOn": [ + "Codebelt.Extensions.Xunit.Hosting@13.0.0", + "Microsoft.Extensions.Hosting@10.0.15" + ], + "framework": "net10.0", + "mode": "console", + "schemaVersion": 1, + "source": "using System;\nusing Codebelt.Extensions.Xunit.Hosting;\nusing Microsoft.Extensions.DependencyInjection;\nusing Microsoft.Extensions.Hosting;\n\nnamespace WorkerApp.Tests;\n\npublic sealed class ApplicationHostFactoryExample\n{\n public string GetTestIdentity()\n {\n using IHost host = ApplicationHostFactory.Create(builder =>\n {\n builder.ConfigureServices(services =>\n services.AddSingleton(new WorkerIdentity(\"Test inventory worker\")));\n });\n\n var identity = host.Services.GetRequiredService();\n return identity.Name;\n }\n}\n\npublic sealed record WorkerIdentity(string Name);\n\npublic sealed class WorkerProgram\n{\n public static IHostBuilder CreateHostBuilder(string[] args)\n {\n return Host.CreateDefaultBuilder(args);\n }\n\n public static void Main(string[] args)\n {\n var identity = new ApplicationHostFactoryExample().GetTestIdentity();\n if (identity != \"Test inventory worker\")\n {\n throw new InvalidOperationException(identity);\n }\n\n Console.WriteLine(identity);\n }\n}" +} +'@ +$OutputEncoding = [Text.UTF8Encoding]::new($false) +[Console]::OutputEncoding = $OutputEncoding +$verifyTests = $false +function Assert-CsrunTestOutput([string] $Output) { + $lines = @($Output -split '\r?\n') + $headers = @($lines | Where-Object { $_ -match '^Test run summary: Passed! - .+\)$' }) + if ($headers.Count -ne 1) { throw 'Expected exactly one completed xUnit test summary.' } + $headerIndex = [Array]::IndexOf($lines, $headers[0]) + $summaryLines = @($lines | Select-Object -Skip ($headerIndex + 1) -First 4) + $counts = @{} + foreach ($line in $summaryLines) { + if ($line -match '^\s*(total|failed|succeeded|skipped):\s*(\d+)\s*$') { $counts[$Matches[1]] = [int]$Matches[2] } + } + if ($counts.Count -ne 4) { throw 'The xUnit test summary counts are incomplete or ambiguous.' } + $failed = $counts.failed + $passed = $counts.succeeded + $skipped = $counts.skipped + $total = $counts.total + if ($total -lt 1 -or $passed -lt 1 -or $failed -ne 0 -or $skipped -ne 0 -or $passed -ne $total) { + throw 'Tests must execute at least once, all pass, and none fail or skip.' + } +} +# Downloads and executes the latest stable csrun release with your permissions. +# Source and release history: https://github.com/codebeltnet/csrun +$engineDirectory = Join-Path ([IO.Path]::GetTempPath()) ('csrun-' + [guid]::NewGuid().ToString('N')) +$null = New-Item -ItemType Directory -Path $engineDirectory +$enginePath = Join-Path $engineDirectory 'csrun.ps1' +$process = $null +try { + $release = Invoke-RestMethod 'https://api.github.com/repos/codebeltnet/csrun/releases/latest' + $assets = @($release.assets | Where-Object name -CEQ 'csrun.ps1') + if ($assets.Count -ne 1 -or $assets[0].digest -notmatch '^sha256:[0-9a-f]{64}$') { + throw "csrun release $($release.tag_name) must publish one csrun.ps1 asset with a SHA-256 digest." + } + $asset = $assets[0] + Invoke-WebRequest $asset.browser_download_url -OutFile $enginePath + $actualHash = (Get-FileHash -LiteralPath $enginePath -Algorithm SHA256).Hash + if ("sha256:$actualHash" -ne $asset.digest) { throw "csrun asset checksum mismatch: $actualHash" } +$startInfo = [Diagnostics.ProcessStartInfo]::new('pwsh') +foreach ($argument in @('-NoProfile','-NonInteractive','-File')) { $startInfo.ArgumentList.Add($argument) } +$startInfo.ArgumentList.Add($enginePath) +$startInfo.ArgumentList.Add('-ManifestJson') +$startInfo.ArgumentList.Add($manifest) +$startInfo.RedirectStandardOutput = $true +$startInfo.RedirectStandardError = $true +$startInfo.UseShellExecute = $false +$process = [Diagnostics.Process]::new() +$process.StartInfo = $startInfo +if (-not $process.Start()) { throw 'Could not start csrun.' } +$stdoutTask = $process.StandardOutput.ReadToEndAsync() +$stderrTask = $process.StandardError.ReadToEndAsync() +$process.WaitForExit() +$output = $stdoutTask.GetAwaiter().GetResult() +$diagnostics = $stderrTask.GetAwaiter().GetResult() +Write-Output $output +if ($diagnostics) { [Console]::Error.Write($diagnostics) } +} catch { + [Console]::Error.WriteLine("csrun diagnostics retained in: $engineDirectory") + throw +} finally { + $resolvedTemp = [IO.Path]::TrimEndingDirectorySeparator([IO.Path]::GetFullPath([IO.Path]::GetTempPath())) + $resolvedEngineDirectory = [IO.Path]::GetFullPath($engineDirectory) + if ([IO.Path]::GetDirectoryName($resolvedEngineDirectory) -ne $resolvedTemp -or + [IO.Path]::GetFileName($resolvedEngineDirectory) -cnotmatch '^csrun-[a-f0-9]{32}$') { throw 'Unsafe cleanup path.' } + if ($process -and $process.ExitCode -eq 0) { Remove-Item -LiteralPath $resolvedEngineDirectory -Recurse -Force } +} +if ($process.ExitCode -ne 0) { throw "csrun execution failed with exit code $($process.ExitCode). $diagnostics" } +if ($verifyTests) { Assert-CsrunTestOutput $output } +} \ No newline at end of file diff --git a/.docfx/run-actions/index.json b/.docfx/run-actions/index.json new file mode 100644 index 0000000..46bec1f --- /dev/null +++ b/.docfx/run-actions/index.json @@ -0,0 +1,692 @@ +{ + "examples": [ + { + "id": "e7dbb5ba733b205469239b03", + "file": ".docfx/api/types/Codebelt.Extensions.Xunit.Hosting.ApplicationFixtureExtensions.md", + "uid": "Codebelt.Extensions.Xunit.Hosting.ApplicationFixtureExtensions", + "sourceSha256": "90B08550FC34DE0144BF28F6ADB2577A59AEC596EB8B6060D545A9B56CD34377", + "status": "ready", + "coverage": "Paired", + "reason": null, + "native": "Unverified", + "docker": "Unverified", + "strategy": "standalone", + "executionSourceSha256": "90B08550FC34DE0144BF28F6ADB2577A59AEC596EB8B6060D545A9B56CD34377", + "nativeSha256": "4DE0DB60FDC7F3CAE0D8E0D09DB207BE30F595F2AB1996AACAF932C237F629DA", + "dockerSha256": "8351E14031CD450FB45EE3F66F343365C5311411013063512ADBCC9D3E6B825D", + "fingerprint": "1BABA39EAFFCD3CCCCD1352184B8769095AAC1083AE7C34BEB94E0A749F7F570" + }, + { + "id": "ff2e361441bdc3028ab188a9", + "file": ".docfx/api/types/Codebelt.Extensions.Xunit.Hosting.ApplicationHostFactory.md", + "uid": "Codebelt.Extensions.Xunit.Hosting.ApplicationHostFactory", + "sourceSha256": "42FEDED83B95259C5771DBE3B83C0323599941985C3D71B510F80C1448BB3771", + "status": "ready", + "coverage": "Paired", + "reason": null, + "native": "Unverified", + "docker": "Unverified", + "strategy": "standalone", + "executionSourceSha256": "42FEDED83B95259C5771DBE3B83C0323599941985C3D71B510F80C1448BB3771", + "nativeSha256": "DE1D6A10381B52052B18B4DEC4C9452EB204D815942F2E28CFED09581632E150", + "dockerSha256": "EE0B55D0723058A2719B42EF6464BC3CD7FD187E1EDA7B7F440BD3099762BD74", + "fingerprint": "92F7147B52A0BFA09E4FCA43FCA08AD8665F82A1D3A5718D5809A8315047C895" + }, + { + "id": "90a8cd444bd08a0115613e58", + "file": ".docfx/api/types/Codebelt.Extensions.Xunit.Hosting.ApplicationTestFactory.md", + "uid": "Codebelt.Extensions.Xunit.Hosting.ApplicationTestFactory", + "sourceSha256": "7473E8AE20820AD58942D6212B5A7DCD428922FD0EEF1985E7D05F9CAC6E8D23", + "status": "ready", + "coverage": "Paired", + "reason": null, + "native": "Unverified", + "docker": "Unverified", + "strategy": "repository", + "nativeSha256": "00C7A8327F5EFCE49526FA7525D78890D14EB274111A434BD88D5D2AABA5CA20", + "dockerSha256": "8A5C860C687FAA281F30644370454337777E46FA9BD9EFFC7E57B1A39B659CFF", + "explanation": "The scripts run the maintained worker integration test and verify its registered marker and Development environment.", + "fingerprint": "E8D9055BAF8F4A43CD8C388ABD03961A61E76743EF83E0D3A09632B6FDF0555B" + }, + { + "id": "21b422ce67f920d801901db0", + "file": ".docfx/api/types/Codebelt.Extensions.Xunit.Hosting.AspNetCore.BlockingManagedWebHostFixture.md", + "uid": "Codebelt.Extensions.Xunit.Hosting.AspNetCore.BlockingManagedWebHostFixture", + "sourceSha256": "CD729B010424B55A26B7607AC78059BC5F610C522C2DCF312E7AD6A8A602E7FC", + "status": "ready", + "coverage": "Paired", + "reason": null, + "native": "Unverified", + "docker": "Unverified", + "strategy": "standalone", + "executionSourceSha256": "CD729B010424B55A26B7607AC78059BC5F610C522C2DCF312E7AD6A8A602E7FC", + "nativeSha256": "31C861D2FB151613E0BD98029ABD8BA81DBC534DCAAD0A982D10130AAD83F7C3", + "dockerSha256": "872671B77DCBD4496E7E4D7083E1634B01A56B2AA03AC8AC4040E190D46ECC55", + "fingerprint": "D077B13EEABDD6F498356984B871DC0FE938F12D92B91B76F75B6A479A3C4D77" + }, + { + "id": "d565f9c40d015b247963fdee", + "file": ".docfx/api/types/Codebelt.Extensions.Xunit.Hosting.AspNetCore.HostBuilderApplicationExtensions.md", + "uid": "Codebelt.Extensions.Xunit.Hosting.AspNetCore.HostBuilderApplicationExtensions", + "sourceSha256": "340FBC3BD83E80B5B8AD6FAA66020C285458A08A608961D7D33BFA1B841FEFF4", + "status": "ready", + "coverage": "Paired", + "reason": null, + "native": "Unverified", + "docker": "Unverified", + "strategy": "standalone", + "executionSourceSha256": "340FBC3BD83E80B5B8AD6FAA66020C285458A08A608961D7D33BFA1B841FEFF4", + "nativeSha256": "4CAB1FB584706805F33D5C3AA646B2853778144B1D33C5F69EA3DEBD19485EE1", + "dockerSha256": "9BDB7866F9163C5545D0BFB5794A0AA0203919A8D8B00F23D540026D98F8F9F0", + "fingerprint": "3E4DADD169E201FC40D08DA8B204136D205C2FE35B50B4B4319D1B37C0C3745D" + }, + { + "id": "3a1dbfc0e010519636b7091e", + "file": ".docfx/api/types/Codebelt.Extensions.Xunit.Hosting.AspNetCore.Http.FakeHttpContextAccessor.md", + "uid": "Codebelt.Extensions.Xunit.Hosting.AspNetCore.Http.FakeHttpContextAccessor", + "sourceSha256": "DCFB8604280E9AC15FFABA700B4055745F26AB9AD9E2F25C3A455EB50AEE7376", + "status": "ready", + "coverage": "Paired", + "reason": null, + "native": "Unverified", + "docker": "Unverified", + "strategy": "standalone", + "executionSourceSha256": "DCFB8604280E9AC15FFABA700B4055745F26AB9AD9E2F25C3A455EB50AEE7376", + "nativeSha256": "7F3DF3F66AD015449F60260D41ACCC8393695A6F0942D1935D8ECD49E23A6BE9", + "dockerSha256": "B3728E1458DBA2796585622B3173788A39E8997C45C6C4A4DBEF167B06B9F43C", + "fingerprint": "D28A47B38C5AAC3C9E17BBC1BCDC8E39E697AF4D5D92400E15704AAB52529B8D" + }, + { + "id": "f5ed7c321a52580d7ce11408", + "file": ".docfx/api/types/Codebelt.Extensions.Xunit.Hosting.AspNetCore.Http.Features.FakeHttpRequestFeature.md", + "uid": "Codebelt.Extensions.Xunit.Hosting.AspNetCore.Http.Features.FakeHttpRequestFeature", + "sourceSha256": "A68A4CA3ACD2C8F668D4D343A9B36AB6E84D6CC1B506473700E973B97D053B94", + "status": "ready", + "coverage": "Paired", + "reason": null, + "native": "Unverified", + "docker": "Unverified", + "strategy": "standalone", + "executionSourceSha256": "A68A4CA3ACD2C8F668D4D343A9B36AB6E84D6CC1B506473700E973B97D053B94", + "nativeSha256": "C8A1CA0ABD69A8498D251F76155638B20760427AB79FEBAE64D5553DC85C3C07", + "dockerSha256": "EE34C5CD5FCB7B29AC03464AEF5E15B6D2DCD822B79062F7AF783DBC08B2AEEE", + "fingerprint": "6FCE39E028BF1CCCCC590995F21A8BF654401C3B4860BC91B71346A08417B063" + }, + { + "id": "08b911ef79f0b743282e37c9", + "file": ".docfx/api/types/Codebelt.Extensions.Xunit.Hosting.AspNetCore.Http.Features.FakeHttpResponseFeature.md", + "uid": "Codebelt.Extensions.Xunit.Hosting.AspNetCore.Http.Features.FakeHttpResponseFeature", + "sourceSha256": "7549EF36EB77D3203099D1DFEF5584A8AAEBD3ED8E537D6BF752D3231191C33D", + "status": "ready", + "coverage": "Paired", + "reason": null, + "native": "Unverified", + "docker": "Unverified", + "strategy": "standalone", + "executionSourceSha256": "7549EF36EB77D3203099D1DFEF5584A8AAEBD3ED8E537D6BF752D3231191C33D", + "nativeSha256": "130FF453A10C707D1199665C806B85611375C886F024AA87BAC536E8C0057AAA", + "dockerSha256": "00968DFBD11C62B26CDBDFBD5D0722D623C0FF2F79276587D9431E28D966D054", + "fingerprint": "3909C3B574F4FDA5C486A33E9786550C9AB70788E50BCE93898ED25049158B80" + }, + { + "id": "947406357e3e26b26a71a538", + "file": ".docfx/api/types/Codebelt.Extensions.Xunit.Hosting.AspNetCore.HttpClientExtensions.md", + "uid": "Codebelt.Extensions.Xunit.Hosting.AspNetCore.HttpClientExtensions", + "sourceSha256": "FABF1EB669FF7CC6B2BDB803E7CC6120EF9FE117823C720690A57522435C1468", + "status": "ready", + "coverage": "Paired", + "reason": null, + "native": "Unverified", + "docker": "Unverified", + "strategy": "standalone", + "executionSourceSha256": "FABF1EB669FF7CC6B2BDB803E7CC6120EF9FE117823C720690A57522435C1468", + "nativeSha256": "C890FC1E5741BB76F57978D2C5A0F35D99DBDC8DDF28358B2C03DB811F4D2E7E", + "dockerSha256": "A91F296DCA868E40610A535D8434916C32DBB97224A329694E472095821FAF42", + "fingerprint": "5D485141E98495D6FEBA00ADE1F737A09D14F48C993583D0E80D6CE336192F2F" + }, + { + "id": "4c5e94adccd20cab4da52078", + "file": ".docfx/api/types/Codebelt.Extensions.Xunit.Hosting.AspNetCore.ManagedWebApplicationFixture%601.md", + "uid": "Codebelt.Extensions.Xunit.Hosting.AspNetCore.ManagedWebApplicationFixture`1", + "sourceSha256": "8A75CECB985C8FCE6F9C0C1211311D40867D82B83ED060008D75E7A3F963EFE3", + "status": "ready", + "coverage": "Paired", + "reason": null, + "native": "Unverified", + "docker": "Unverified", + "strategy": "repository", + "nativeSha256": "7CA33C5DA5E344F5D304ACFD4F9D647CD86AF0A16CD8703BE3A5B4C985C249A1", + "dockerSha256": "F480E508DEE48C294129847AF07388A8380B73426101FF17F7F16F2868C9F80D", + "explanation": "The scripts start the maintained ASP.NET Core application through the same fixture and verify its HTTP response.", + "fingerprint": "BDED27159743FF0AFD2F2194AB13DB270C4683784DA246A416B5FB3C7CB72B6D" + }, + { + "id": "927ca9f6a3bf893bc52887f4", + "file": ".docfx/api/types/Codebelt.Extensions.Xunit.Hosting.AspNetCore.ManagedWebHostFixture.md", + "uid": "Codebelt.Extensions.Xunit.Hosting.AspNetCore.ManagedWebHostFixture", + "sourceSha256": "2CC0B80DE03471AD6DD8210B4FDF2FA037751EF8B38AD43B1C611FC553EDA979", + "status": "ready", + "coverage": "Paired", + "reason": null, + "native": "Unverified", + "docker": "Unverified", + "strategy": "standalone", + "executionSourceSha256": "2CC0B80DE03471AD6DD8210B4FDF2FA037751EF8B38AD43B1C611FC553EDA979", + "nativeSha256": "4EF5AC9FAC282678956D5BC6A4AB1905183820457A2197ED1C67CE3A8B9709AA", + "dockerSha256": "DF3CFE553ACDC7C67454233C5383A0E6F50F9FEE4BF947E13C138CB04A3F2F2B", + "fingerprint": "9972E2493E26F0B44F44AADBB8C278447EE93EE1399F2798E0FD2ADDE4753313" + }, + { + "id": "00acdae546dce87b654496e1", + "file": ".docfx/api/types/Codebelt.Extensions.Xunit.Hosting.AspNetCore.ManagedWebMinimalHostFixture.md", + "uid": "Codebelt.Extensions.Xunit.Hosting.AspNetCore.ManagedWebMinimalHostFixture", + "sourceSha256": "9D12413E06F45213763C5BAD14B3B2796097B1F773D18BDA1F8CBF90F7CF1268", + "status": "ready", + "coverage": "Paired", + "reason": null, + "native": "Unverified", + "docker": "Unverified", + "strategy": "standalone", + "executionSourceSha256": "9D12413E06F45213763C5BAD14B3B2796097B1F773D18BDA1F8CBF90F7CF1268", + "nativeSha256": "313D557C16CBC735E1AB28E16FF49CB08EF7E9E606EC6FDDC6B18B3CE2508515", + "dockerSha256": "F1160FDEBD047F6E9C1D4796CABD0DCF9DF3BA4BCD248C9C7CED61B269CD45CD", + "fingerprint": "D263C48D97068DDCD50FF2AB1DCF68DE568B3113557DBE0666CD04EDD2F85855" + }, + { + "id": "1e869fe39c4833386733c21f", + "file": ".docfx/api/types/Codebelt.Extensions.Xunit.Hosting.AspNetCore.MinimalWebHostTestFactory.md", + "uid": "Codebelt.Extensions.Xunit.Hosting.AspNetCore.MinimalWebHostTestFactory", + "sourceSha256": "869F4EDAF75D120A8A7F73B37C8E87002B0B006BABF480ECA0BFDCD5939E1F73", + "status": "ready", + "coverage": "Paired", + "reason": null, + "native": "Unverified", + "docker": "Unverified", + "strategy": "standalone", + "executionSourceSha256": "869F4EDAF75D120A8A7F73B37C8E87002B0B006BABF480ECA0BFDCD5939E1F73", + "nativeSha256": "FB95BAECD391A61E27BDF1B6E86E8FF4FF11B22D250465E93B83A1B3E6F6362D", + "dockerSha256": "C130C15E83B7F1CEAD1245BB3F550AFF71CE3A81537F124EE682E599794CC3C4", + "fingerprint": "264A534ACE258BD3C3E88EF13F175D17B8C33FEE4ACC72E4A7CA5A6A1CC8AA24" + }, + { + "id": "f27f77d838407171b56f9073", + "file": ".docfx/api/types/Codebelt.Extensions.Xunit.Hosting.AspNetCore.SelfManagedWebHostFixture.md", + "uid": "Codebelt.Extensions.Xunit.Hosting.AspNetCore.SelfManagedWebHostFixture", + "sourceSha256": "8C67EA9DD2F57A0DB37E7EE5E5516CE5655B61EE90C4097CFAE7EC8CD9B9F59D", + "status": "ready", + "coverage": "Paired", + "reason": null, + "native": "Unverified", + "docker": "Unverified", + "strategy": "standalone", + "executionSourceSha256": "8C67EA9DD2F57A0DB37E7EE5E5516CE5655B61EE90C4097CFAE7EC8CD9B9F59D", + "nativeSha256": "81A906B0589518110EFAE86BFE6B3348FCE3FCEDAD9E6DCF9A7F9DB93B2B8410", + "dockerSha256": "52DDBC16B9C15011CAD0960BD6BEDEE5E1B5F90BF6031E6F5777A57F5579308E", + "fingerprint": "336B4A0D09DF623D43144C0F8E29EA9DC327B655591B6A77C6EC35C94AADD62A" + }, + { + "id": "3c3b98167b30d6985017ec27", + "file": ".docfx/api/types/Codebelt.Extensions.Xunit.Hosting.AspNetCore.SelfManagedWebMinimalHostFixture.md", + "uid": "Codebelt.Extensions.Xunit.Hosting.AspNetCore.SelfManagedWebMinimalHostFixture", + "sourceSha256": "BD4DED8434BE4E8F5C88402103358DBCC12C4548C89FC48C060587BDB9CE3C5C", + "status": "ready", + "coverage": "Paired", + "reason": null, + "native": "Unverified", + "docker": "Unverified", + "strategy": "standalone", + "executionSourceSha256": "BD4DED8434BE4E8F5C88402103358DBCC12C4548C89FC48C060587BDB9CE3C5C", + "nativeSha256": "A9EA5F93E58E9331D99EEFC4EDBD0FA1A234FA7837578B56EBEE996E9CF52D95", + "dockerSha256": "8D4B344F5739DBD9779CD4F673135837AEE266F4FB139BAEAFD722E89BFB3EF2", + "fingerprint": "45D6B2B661E054208195D3822A130390F4F0E00D09D1DF91BFDAA2169D93F2A2" + }, + { + "id": "f3c0856195727da12ff2925f", + "file": ".docfx/api/types/Codebelt.Extensions.Xunit.Hosting.AspNetCore.ServiceCollectionExtensions.md", + "uid": "Codebelt.Extensions.Xunit.Hosting.AspNetCore.ServiceCollectionExtensions", + "sourceSha256": "FFE4DD6394228DC8E7DF1EF37C5377AF341AD84C0E18D3B83CFE51ED671CC8F0", + "status": "ready", + "coverage": "Paired", + "reason": null, + "native": "Unverified", + "docker": "Unverified", + "strategy": "standalone", + "executionSourceSha256": "FFE4DD6394228DC8E7DF1EF37C5377AF341AD84C0E18D3B83CFE51ED671CC8F0", + "nativeSha256": "F2BEE9D8CB95A6B817174B56B95F8E7FDA659F24772FBEAA9DE9D366499EFA60", + "dockerSha256": "62FF334C87C75812C2253716E8A6DFFA5A752E572C0594C480DBE759505E08F3", + "fingerprint": "BA8E7250D6E7639ABC218267B26D528A2AF4163B18AB0E4F20403CC11148FB14" + }, + { + "id": "549c3e82bd0bcb99e9f05bfa", + "file": ".docfx/api/types/Codebelt.Extensions.Xunit.Hosting.AspNetCore.WebApplicationFixtureExtensions.md", + "uid": "Codebelt.Extensions.Xunit.Hosting.AspNetCore.WebApplicationFixtureExtensions", + "sourceSha256": "9C8A41C5E80934D69DF60798533A7E8BE07CA4210608BBDD2230C757179A8EC5", + "status": "ready", + "coverage": "Paired", + "reason": null, + "native": "Unverified", + "docker": "Unverified", + "strategy": "standalone", + "executionSourceSha256": "9C8A41C5E80934D69DF60798533A7E8BE07CA4210608BBDD2230C757179A8EC5", + "nativeSha256": "CB1E905B217B54C3893A0796CF95ED2F35AD1B082F5065485439B2B0D5D91DE5", + "dockerSha256": "0D53E0C09D1ADD025CD4D50BEB2572B2BFE59DCFF88A55CF4D9C85414FC3C244", + "fingerprint": "EB995FBD5C973FE46D91E992F3356F1FB7B7F3F95B810CC831C25BB60083EBC3" + }, + { + "id": "38b60f4b4c1a588bbefe92f1", + "file": ".docfx/api/types/Codebelt.Extensions.Xunit.Hosting.AspNetCore.WebApplicationTestFactory.md", + "uid": "Codebelt.Extensions.Xunit.Hosting.AspNetCore.WebApplicationTestFactory", + "sourceSha256": "1DB1DAAA9965BF42F736A4BC3788B4261DF4EF52799B83E6F733AB1BD53EA7D3", + "status": "ready", + "coverage": "Paired", + "reason": null, + "native": "Unverified", + "docker": "Unverified", + "strategy": "repository", + "nativeSha256": "69FDA93954B1FD1242343B73F7BDBE189191572F1F84721F6ED6B4517FB83FA6", + "dockerSha256": "D4F431F447435C826AB63A6BC28FF32C489EB19A4F31A956458A4EF9B82B59EB", + "explanation": "The scripts run the maintained integration test, which overrides services and configuration and verifies the results through HTTP endpoints.", + "fingerprint": "829297A6A6D255195BA01DB7F8DC8FF5675B2A7C40E1C817099F1D2F6B772165" + }, + { + "id": "dfdd064179bf4643e1a0b2bf", + "file": ".docfx/api/types/Codebelt.Extensions.Xunit.Hosting.AspNetCore.WebHostFixtureExtensions.md", + "uid": "Codebelt.Extensions.Xunit.Hosting.AspNetCore.WebHostFixtureExtensions", + "sourceSha256": "CEDFFF39E914FF47421AE5A4F37CA1564DCAC8252903585B3B53DB069663492B", + "status": "ready", + "coverage": "Paired", + "reason": null, + "native": "Unverified", + "docker": "Unverified", + "strategy": "standalone", + "executionSourceSha256": "CEDFFF39E914FF47421AE5A4F37CA1564DCAC8252903585B3B53DB069663492B", + "nativeSha256": "AB5F11B6455048AB8A913B28B56EE0B9066456F66A6A765EB40BFC28E33FFA0A", + "dockerSha256": "0A3B147AB81262F151FA38ED1A42514797F1148B86101022DBBEC20356A8AE2E", + "fingerprint": "110EDB7870A95DD8C2BA7F53DBBB927175DECF3D08F5D44B0BB54FF6AF5AD045" + }, + { + "id": "d71e8ed85f1221cb41308b31", + "file": ".docfx/api/types/Codebelt.Extensions.Xunit.Hosting.AspNetCore.WebHostTestFactory.md", + "uid": "Codebelt.Extensions.Xunit.Hosting.AspNetCore.WebHostTestFactory", + "sourceSha256": "F2DCAE2A6B67B77ADED3A2B726B4ABA20276D3C0FBDFB57F153447D8312005EE", + "status": "ready", + "coverage": "Paired", + "reason": null, + "native": "Unverified", + "docker": "Unverified", + "strategy": "standalone", + "executionSourceSha256": "F2DCAE2A6B67B77ADED3A2B726B4ABA20276D3C0FBDFB57F153447D8312005EE", + "nativeSha256": "4395294663D1EABA0514999B70FCCBA79F45D11CEEF9AAFF4F9E3D1C8F821251", + "dockerSha256": "915DB06EF218173F65642FB4705527B6D5E51E84250CDBF3465A700C28191130", + "fingerprint": "2FC31107F86602B357FA65E9398D455F724268C87F2BF2A29EA2D811E45DACBA" + }, + { + "id": "dd2fa1a038dbc1220b366a53", + "file": ".docfx/api/types/Codebelt.Extensions.Xunit.Hosting.AspNetCore.WebMinimalHostFixtureExtensions.md", + "uid": "Codebelt.Extensions.Xunit.Hosting.AspNetCore.WebMinimalHostFixtureExtensions", + "sourceSha256": "F30F392FC9E68CBA4BCCB949F0CF36307DCC6A0FFF2DEA05F4641ACB4EA13900", + "status": "ready", + "coverage": "Paired", + "reason": null, + "native": "Unverified", + "docker": "Unverified", + "strategy": "standalone", + "executionSourceSha256": "F30F392FC9E68CBA4BCCB949F0CF36307DCC6A0FFF2DEA05F4641ACB4EA13900", + "nativeSha256": "BE4CBA9D128D88F26DD18A33AC2D09A139BBF0C580F90D302426C832F4CC8DD3", + "dockerSha256": "8D64AF7C519A8413BC1C161D043A9B0AEB2852FF201A1655521CEDD7FA9A5917", + "fingerprint": "5890C6FABD20CB7382698233228136AA4568648889D27615B34045506C335200" + }, + { + "id": "1130af506703020850fdadea", + "file": ".docfx/api/types/Codebelt.Extensions.Xunit.Hosting.GenericHostFixtureExtensions.md", + "uid": "Codebelt.Extensions.Xunit.Hosting.GenericHostFixtureExtensions", + "sourceSha256": "6DA99A91947A5C64953DDD8F7B42EC74AE39C3EDFBF9F2DB69A31B9B2D0B90AC", + "status": "ready", + "coverage": "Paired", + "reason": null, + "native": "Unverified", + "docker": "Unverified", + "strategy": "standalone", + "executionSourceSha256": "6DA99A91947A5C64953DDD8F7B42EC74AE39C3EDFBF9F2DB69A31B9B2D0B90AC", + "nativeSha256": "F4D79D2A5B2B52462AF433796E36F27BE2160C8F478EB54545FC3409C746294D", + "dockerSha256": "A82D197296B23978BC16D3BD52C94A3414DED8655C65979F37A90761C4E769CA", + "fingerprint": "700A6049B9F2E6A1C8213A33092ED449B4F4B3C91A1954BAD94509D95D75A34D" + }, + { + "id": "9cdeb08f8ba8f3b361a98c58", + "file": ".docfx/api/types/Codebelt.Extensions.Xunit.Hosting.HostTestFactory.md", + "uid": "Codebelt.Extensions.Xunit.Hosting.HostTestFactory", + "sourceSha256": "DBB1A94CF50D0C71616D4482DFD2FF1A4D5F8EA387340B6D4C98A5A4F84E6652", + "status": "ready", + "coverage": "Paired", + "reason": null, + "native": "Unverified", + "docker": "Unverified", + "strategy": "standalone", + "executionSourceSha256": "DBB1A94CF50D0C71616D4482DFD2FF1A4D5F8EA387340B6D4C98A5A4F84E6652", + "nativeSha256": "E006BE44A9936D50BABC7FD9588D88D5AFF0867620E70C39C0211959EB3E9986", + "dockerSha256": "5DC664410B9F74D7B95B1779EE0944E004D0E086D0A869A2983876918C803155", + "fingerprint": "B7876A355FD35F53A4358AF0B9ED49CB603AEAFA56C2F3E45646758202A12D44" + }, + { + "id": "513a785b0e0abbe2284270b9", + "file": ".docfx/api/types/Codebelt.Extensions.Xunit.Hosting.LoggerExtensions.md", + "uid": "Codebelt.Extensions.Xunit.Hosting.LoggerExtensions", + "sourceSha256": "D2C65C928AF86623AF7F8B754C254F1A64B7FEB61F6168559FD1FC1862A08DEB", + "status": "ready", + "coverage": "Paired", + "reason": null, + "native": "Unverified", + "docker": "Unverified", + "strategy": "standalone", + "executionSourceSha256": "D2C65C928AF86623AF7F8B754C254F1A64B7FEB61F6168559FD1FC1862A08DEB", + "nativeSha256": "1AE855A54C56279F55ED6C4C5400688083A06CBC1D9A7143DB54BFC67187526A", + "dockerSha256": "ABF4E0E98596EA711DF07C0F8C2D5DA4D044B80D560A2897429E09F2C6D672F9", + "fingerprint": "B8F9DA134B445F92CECA956D84A4FA864AF6F6FFA94F8C17E4730F358632BE61" + }, + { + "id": "1ec9196292addaca42a7eef1", + "file": ".docfx/api/types/Codebelt.Extensions.Xunit.Hosting.ManagedApplicationFixture%601.md", + "uid": "Codebelt.Extensions.Xunit.Hosting.ManagedApplicationFixture`1", + "sourceSha256": "47B0C1FBA94E7B43C8753D0A8242801B328E6B463B6EEDAEB640D4F8A262633E", + "status": "ready", + "coverage": "Paired", + "reason": null, + "native": "Unverified", + "docker": "Unverified", + "strategy": "repository", + "nativeSha256": "CBC8F4768833FBF5B62523F466C1763AB20C52424852F49F2CCDA2C276B2A727", + "dockerSha256": "AF143DDB933F4589D3E33A489DA0483A40A05C470ADFBD6033B32A33A9EF7107", + "explanation": "The scripts run this test in its original application and test projects.", + "fingerprint": "C6F81EE75B4F5776C3CB88C0790CCE40A8B0FB14EB2795E34BA071A24C053D00" + }, + { + "id": "aa478d74f298d8c98e6cd1bf", + "file": ".docfx/api/types/Codebelt.Extensions.Xunit.Hosting.ManagedHostFixture.md", + "uid": "Codebelt.Extensions.Xunit.Hosting.ManagedHostFixture", + "sourceSha256": "6F9E6E2F82AB916A7A36CC2259AA97366A800843E8B1913EE7C2D79580861DA8", + "status": "ready", + "coverage": "Paired", + "reason": null, + "native": "Unverified", + "docker": "Unverified", + "strategy": "standalone", + "executionSourceSha256": "6F9E6E2F82AB916A7A36CC2259AA97366A800843E8B1913EE7C2D79580861DA8", + "nativeSha256": "EF304F357CADAA92BAFAE377C398A55E38DFDB48A2EC353243C80D4E81E77B9B", + "dockerSha256": "2F749D571D43DB8120BB7FA70FE171034D04095A7838ADDB508A39F42F808EC6", + "fingerprint": "CA30DC883593BFA97EAA8943231C79E90CD16CD297DA30AA78CE90A18E337389" + }, + { + "id": "6a59b7744a7d9994ffc04782", + "file": ".docfx/api/types/Codebelt.Extensions.Xunit.Hosting.ManagedMinimalHostFixture.md", + "uid": "Codebelt.Extensions.Xunit.Hosting.ManagedMinimalHostFixture", + "sourceSha256": "D0D64093FAF614E7658650534934F6771BB45486D43E7A241D573347840E6DBE", + "status": "ready", + "coverage": "Paired", + "reason": null, + "native": "Unverified", + "docker": "Unverified", + "strategy": "standalone", + "executionSourceSha256": "D0D64093FAF614E7658650534934F6771BB45486D43E7A241D573347840E6DBE", + "nativeSha256": "3E9A37ABCAA30C862A5FE6DF7354F02887711F8CB6F13144948B67C4859CB4C7", + "dockerSha256": "D092406830169606E94AFB3E260AC9150F5FD8537D97949AEAADCF2390EB8335", + "fingerprint": "5A8BC97B33361F12BDB4ACB1E3200DC5D7DBDA9EA79EC375A66E64F6CB7C6FF6" + }, + { + "id": "becb2fe7446fc1571dc86953", + "file": ".docfx/api/types/Codebelt.Extensions.Xunit.Hosting.MinimalHostFixtureExtensions.md", + "uid": "Codebelt.Extensions.Xunit.Hosting.MinimalHostFixtureExtensions", + "sourceSha256": "47A5CB15CC0563C81176ADE58748B75704DA88BCA3549BEF914BD63CED52125C", + "status": "ready", + "coverage": "Paired", + "reason": null, + "native": "Unverified", + "docker": "Unverified", + "strategy": "standalone", + "executionSourceSha256": "47A5CB15CC0563C81176ADE58748B75704DA88BCA3549BEF914BD63CED52125C", + "nativeSha256": "A01D226ACD37BD7A84079360C6D08F781F79071FDEB150509E7D6488D71EF6CD", + "dockerSha256": "2C48C5E7520D3260315548203BCB81821BCC4CB4AFFD04F40C008A43AEC443E3", + "fingerprint": "F8BC0F8D737E91FFF677EA9DEA538B892A8F4BAABF47CC0DBABCA4B1A0EE6438" + }, + { + "id": "e3f79d1c0f2fa85276cee2fb", + "file": ".docfx/api/types/Codebelt.Extensions.Xunit.Hosting.MinimalHostTestFactory.md", + "uid": "Codebelt.Extensions.Xunit.Hosting.MinimalHostTestFactory", + "sourceSha256": "45A7CCD7F1EF9A48A33565AEAC7B5A005AD4AA11E12ADD506911B10614205E87", + "status": "ready", + "coverage": "Paired", + "reason": null, + "native": "Unverified", + "docker": "Unverified", + "strategy": "standalone", + "executionSourceSha256": "45A7CCD7F1EF9A48A33565AEAC7B5A005AD4AA11E12ADD506911B10614205E87", + "nativeSha256": "652AA1DF3EFE2C767DC6BB49231655D70C5FB692176C2D4EE44A2C0F7E544351", + "dockerSha256": "D1A74874F6ECC77D3805F95937912E8CD5332354451F6352EE1E1844EC00ED9A", + "fingerprint": "DF06A1017F8A03A4E0AA021AE4F640FC50B3E62741CDAC93AE81F4B141E4CE64" + }, + { + "id": "515575be5bb7683cac9903a5", + "file": ".docfx/api/types/Codebelt.Extensions.Xunit.Hosting.SelfManagedHostFixture.md", + "uid": "Codebelt.Extensions.Xunit.Hosting.SelfManagedHostFixture", + "sourceSha256": "7B4FC8E01BFCFACAF488EB329E5F50B3F9EEB7F42BF26D59D54C6F69754FB32B", + "status": "ready", + "coverage": "Paired", + "reason": null, + "native": "Unverified", + "docker": "Unverified", + "strategy": "standalone", + "executionSourceSha256": "7B4FC8E01BFCFACAF488EB329E5F50B3F9EEB7F42BF26D59D54C6F69754FB32B", + "nativeSha256": "EC33997C2955527BE5B6D6DFE7A319EFBF797949CF91787E71215B0FF76BEB10", + "dockerSha256": "DEA080C70296E4B0AA6331EFB197A7B56CB5AF3F94E56E29B6BBA19E3EC999DC", + "fingerprint": "F48F89EE3931E463919D79B831586F4F9798EE12378580840DC0DA3F0743DD87" + }, + { + "id": "b4149382f121a5ffc3c057df", + "file": ".docfx/api/types/Codebelt.Extensions.Xunit.Hosting.SelfManagedMinimalHostFixture.md", + "uid": "Codebelt.Extensions.Xunit.Hosting.SelfManagedMinimalHostFixture", + "sourceSha256": "E1641265DF178540A21BD769CA1A9CD162901D03813C9D723B18349652B19A6B", + "status": "ready", + "coverage": "Paired", + "reason": null, + "native": "Unverified", + "docker": "Unverified", + "strategy": "standalone", + "executionSourceSha256": "E1641265DF178540A21BD769CA1A9CD162901D03813C9D723B18349652B19A6B", + "nativeSha256": "2EFA535B23B695DC37AD2B57EA35F34E1C74BFF3A6F1D0412533A44A83D8CB47", + "dockerSha256": "0E4457B530E5F0A88699557320B075D67AA1EDCF6C29E23DF65F47703783DE10", + "fingerprint": "61BC9501333A2EB14D92E8690516F50E2EC76E35BB255C4C75655F51F8CF2C0D" + }, + { + "id": "18b0746bf3da1d84f81b5274", + "file": ".docfx/api/types/Codebelt.Extensions.Xunit.Hosting.ServiceCollectionExtensions.md", + "uid": "Codebelt.Extensions.Xunit.Hosting.ServiceCollectionExtensions", + "sourceSha256": "96463CFB4DADE2AA027CBD21C1A8E380C83914669832CEE2C447DEDDCCAFC9C6", + "status": "ready", + "coverage": "Paired", + "reason": null, + "native": "Unverified", + "docker": "Unverified", + "strategy": "standalone", + "executionSourceSha256": "96463CFB4DADE2AA027CBD21C1A8E380C83914669832CEE2C447DEDDCCAFC9C6", + "nativeSha256": "04DFB6C123D4F64BBFD676004301C230C4890079AEE786268DE55F29FD9A0524", + "dockerSha256": "315963205760A4F53E6741B1E7644845BB86E126E2966B24B0CB2CC7C575784A", + "fingerprint": "4201A700A1FA92753B76E2C7099670B9723441B88BF131C021EEB25DCD5397F6" + }, + { + "id": "5e35a33e56470f93afbedf19", + "file": ".docfx/api/types/Codebelt.Extensions.Xunit.Hosting.ServiceProviderExtensions.md", + "uid": "Codebelt.Extensions.Xunit.Hosting.ServiceProviderExtensions", + "sourceSha256": "C9C4438BD3D356FA0C39F5F86FAF6E984D9A1253A0A5D8EAEAD280AAAB31569B", + "status": "ready", + "coverage": "Paired", + "reason": null, + "native": "Unverified", + "docker": "Unverified", + "strategy": "standalone", + "executionSourceSha256": "C9C4438BD3D356FA0C39F5F86FAF6E984D9A1253A0A5D8EAEAD280AAAB31569B", + "nativeSha256": "1F1F4DF2A749538293F3C8ED001011A8DD138AF5B0165BB074014F88C912D5AE", + "dockerSha256": "AF7459ACD9413EA459C895D20B663CD31C98627630C8EC2C8A7607F12269E0EE", + "fingerprint": "7E28693772859804C7B2AE8894C1F71A9CBA13E576832E0710E91B8BA2FDEF86" + }, + { + "id": "9a558a9a581c6b11ccb28057", + "file": ".docfx/api/types/Codebelt.Extensions.Xunit.Hosting.XunitTestLoggerEntry.md", + "uid": "Codebelt.Extensions.Xunit.Hosting.XunitTestLoggerEntry", + "sourceSha256": "5DBC97E4CD56C7D3072FE73E9BBA6F90326CFE7952A57823024464DA85802D3C", + "status": "ready", + "coverage": "Paired", + "reason": null, + "native": "Unverified", + "docker": "Unverified", + "strategy": "standalone", + "executionSourceSha256": "5DBC97E4CD56C7D3072FE73E9BBA6F90326CFE7952A57823024464DA85802D3C", + "nativeSha256": "0BE3FB9403B1DF69B5184F36076B931DFA28079CFC50831E6572D9F5D39F2FD5", + "dockerSha256": "D30CC9E29A61B6855437B25AA6CC9334E5100058EA557D6ECC237021E5F16A2C", + "fingerprint": "BC422D634237902A39DCE1A68C10E1A3BC9373A9C48211DCD15F145516495597" + }, + { + "id": "a31971b360a8c557b87f6684", + "file": ".docfx/api/types/Codebelt.Extensions.Xunit.InMemoryTestStore%601.md", + "uid": "Codebelt.Extensions.Xunit.InMemoryTestStore`1", + "sourceSha256": "71987946D4476C5106392E6DB007FE7B11CFE39D4EAA4CA1B04539D1EC7C7F7C", + "status": "ready", + "coverage": "Paired", + "reason": null, + "native": "Unverified", + "docker": "Unverified", + "strategy": "standalone", + "executionSourceSha256": "71987946D4476C5106392E6DB007FE7B11CFE39D4EAA4CA1B04539D1EC7C7F7C", + "nativeSha256": "48ECDD07B2B3FBF009FF56420A84B8E4BDA50E4BD11037D5449EF2E0753940CD", + "dockerSha256": "14610BFC498745D5F0F65A479E1F0948FEEFAD88ECE5E1CA9E908DD9E66D5A06", + "fingerprint": "D5911042EA2FB574417E1EB82A2DA5AF78C46C2B08252AACDFAEB6F27B64C733" + }, + { + "id": "812efaa205554c7bdcd80831", + "file": ".docfx/api/types/Codebelt.Extensions.Xunit.PriorityAttribute.md", + "uid": "Codebelt.Extensions.Xunit.PriorityAttribute", + "sourceSha256": "93FF0CA8DBB21BE3475B9DED2131644055C82C6BF81A6D5F51DE91564C44FD78", + "status": "ready", + "coverage": "Paired", + "reason": null, + "native": "Unverified", + "docker": "Unverified", + "strategy": "standalone", + "executionSourceSha256": "93FF0CA8DBB21BE3475B9DED2131644055C82C6BF81A6D5F51DE91564C44FD78", + "nativeSha256": "1FCF507A856F3FA1FCCD3D9EED5EC665166C6400C97531F8453D486293EF865E", + "dockerSha256": "21E060673DAD81133E5A4E64B1933DBC2F470B58D305124D84C36EAA036A13A3", + "fingerprint": "F2A918013C78A09A9F54561EFE5AB411D8D243D7DE0107F8480AA79B55B300AA" + }, + { + "id": "782f24d34260070258f6d164", + "file": ".docfx/api/types/Codebelt.Extensions.Xunit.PriorityTestMethodOrderer.md", + "uid": "Codebelt.Extensions.Xunit.PriorityTestMethodOrderer", + "sourceSha256": "8A21672EB35CB508A5A70D51D8813A009DE6C9B7099E766FDA6BBF8A6DA360BF", + "status": "ready", + "coverage": "Paired", + "reason": null, + "native": "Unverified", + "docker": "Unverified", + "strategy": "standalone", + "executionSourceSha256": "8A21672EB35CB508A5A70D51D8813A009DE6C9B7099E766FDA6BBF8A6DA360BF", + "nativeSha256": "3C454C6B5D05CFC25A6F25BCCAAA17399BB0C80101FDBBFACC7432C957693C76", + "dockerSha256": "1481D2DEF8DAD9F63BA7D6A63F2E38FDF949305C39AC9F5EECE536F2323C468A", + "fingerprint": "A2FF981D09ACB0024CB724A2BD47C52FDCFDF7D4514AC4C7E7FF5C6EA9CC2A76" + }, + { + "id": "545543e49c6bf054a9e06186", + "file": ".docfx/api/types/Codebelt.Extensions.Xunit.TestOutputHelperAccessor.md", + "uid": "Codebelt.Extensions.Xunit.TestOutputHelperAccessor", + "sourceSha256": "4C6461C6EBDE9468850148117F4972F3C9C25E6F22138521AAB7852B60162109", + "status": "ready", + "coverage": "Paired", + "reason": null, + "native": "Unverified", + "docker": "Unverified", + "strategy": "standalone", + "executionSourceSha256": "4C6461C6EBDE9468850148117F4972F3C9C25E6F22138521AAB7852B60162109", + "nativeSha256": "E295F5790E2B3AA6ED42E8FDAF044206BFC67C86181A3CB0BF99ADE740A00AD0", + "dockerSha256": "4EDE36D0EF2CAE28C9F28038DEF44F2A252586F7E00B4BFDD3CD31C4AD12FC29", + "fingerprint": "AC583D390F9AF07204935640F985FD019DCFE3F46B992BCCB960CF149A00BC05" + }, + { + "id": "45fcccef5fc861315b50c55e", + "file": ".docfx/api/types/Codebelt.Extensions.Xunit.TestOutputHelperExtensions.md", + "uid": "Codebelt.Extensions.Xunit.TestOutputHelperExtensions", + "sourceSha256": "BE11774854DE0AF823285BDCAD5BF6B02FD6CFF9D1673B10C6F0CE3D043E5799", + "status": "ready", + "coverage": "Paired", + "reason": null, + "native": "Unverified", + "docker": "Unverified", + "strategy": "standalone", + "executionSourceSha256": "BE11774854DE0AF823285BDCAD5BF6B02FD6CFF9D1673B10C6F0CE3D043E5799", + "nativeSha256": "C5D9FE38737F8405E2A24F62E0BE1123CE726946DC2B470ABC66885A3A7D0FE3", + "dockerSha256": "E85250AB23232BBC8A39A415D29851684E1E5840D6BB74E9F9E163DCB88E2D27", + "fingerprint": "202AD27A002509FFDB47270EEF56FF4F9F0D984B6F10A4EAF63B43B41C74F282" + }, + { + "id": "578d467fd203f66cc41b0364", + "file": ".docfx/api/types/Codebelt.Extensions.Xunit.TestOutputHelperExtensions.md", + "uid": "Codebelt.Extensions.Xunit.TestOutputHelperExtensions.WriteLines(Xunit.ITestOutputHelper,System.Object[])", + "sourceSha256": "985FBA10ABE737D5BEE72A19B028BCA6739A84C7B790695AEEC66BCC73BE7713", + "status": "ready", + "coverage": "Paired", + "reason": null, + "native": "Unverified", + "docker": "Unverified", + "strategy": "standalone", + "executionSourceSha256": "985FBA10ABE737D5BEE72A19B028BCA6739A84C7B790695AEEC66BCC73BE7713", + "nativeSha256": "EB8430E3CB36D238D0A3FB224FB3964F25AB50BE7A58E6A6281D8F6383E15FE7", + "dockerSha256": "D48979DD608DC5AF7114556E34565563A73881D76F48CF0332749E07B14A02B0", + "fingerprint": "D431B184DFEF46EC133B1A4262BC6206EB416457A369B3E3829D9FF347988F92" + }, + { + "id": "10457ac34cce1cbadb26aee1", + "file": ".docfx/api/types/Codebelt.Extensions.Xunit.TestOutputHelperExtensions.md", + "uid": "Codebelt.Extensions.Xunit.TestOutputHelperExtensions.WriteLines``1(Xunit.ITestOutputHelper,``0[])", + "sourceSha256": "32E90B18345F4AF2EDBA67EDA4F5D6B231292147F40B9B541243F22A2DE71426", + "status": "ready", + "coverage": "Paired", + "reason": null, + "native": "Unverified", + "docker": "Unverified", + "strategy": "standalone", + "executionSourceSha256": "32E90B18345F4AF2EDBA67EDA4F5D6B231292147F40B9B541243F22A2DE71426", + "nativeSha256": "9D0818019F4175B95983A9A7E26083327E94FCE332DD048D52C0A64F8A8CDBC4", + "dockerSha256": "D5885F41A9F6571A9DC3EDA2B4A70C043F7BBA64ECBC9C396902AF9E51E3F861", + "fingerprint": "7FA9A89BFA46E211F8ED3828265F18FEA26501F62BF39626F36111718268B943" + }, + { + "id": "0308118a47b5c02daa7b32be", + "file": ".docfx/api/types/Codebelt.Extensions.Xunit.TestOutputHelperExtensions.md", + "uid": "Codebelt.Extensions.Xunit.TestOutputHelperExtensions.WriteLines``1(Xunit.ITestOutputHelper,System.Collections.Generic.IEnumerable{``0})", + "sourceSha256": "6BF4CBD17324584A087D6EF92F873474DD288AA42EAB5DB33665CADCFEF49734", + "status": "ready", + "coverage": "Paired", + "reason": null, + "native": "Unverified", + "docker": "Unverified", + "strategy": "standalone", + "executionSourceSha256": "6BF4CBD17324584A087D6EF92F873474DD288AA42EAB5DB33665CADCFEF49734", + "nativeSha256": "C516047E808D34DE61362463930D041534EDCB37E1259A39D0389BCB678E25AC", + "dockerSha256": "6E87D2E82F764DBD8CB4F85B93252FEFCAB8412D2A96420F152334A3FEF08A2F", + "fingerprint": "ABD62270C56A09E35C9D0661558F886AE9AE1701277F5B066E2CC47ECD457C32" + }, + { + "id": "038a1c806225b412a6f986c1", + "file": ".docfx/api/types/Codebelt.Extensions.Xunit.WildcardOptions.md", + "uid": "Codebelt.Extensions.Xunit.WildcardOptions", + "sourceSha256": "9E421444D2AB0A979A150637043D0070DCB60D5517C3E595AB902F7C3A7A17E9", + "status": "ready", + "coverage": "Paired", + "reason": null, + "native": "Unverified", + "docker": "Unverified", + "strategy": "standalone", + "executionSourceSha256": "9E421444D2AB0A979A150637043D0070DCB60D5517C3E595AB902F7C3A7A17E9", + "nativeSha256": "32DBA22B6B9B7D8747E9A56E40246D796B1B839C9CBCC199D050020AEF20577F", + "dockerSha256": "3696C9F661DEF0F6756F83F6ADE46D0FCCDE062EE72CE2D25DE3083AC2CB889A", + "fingerprint": "E748694BBF63611BC8E483D9F5AB3C9E915224B68C75FE22BF6A7B39F7F0DF39" + } + ] +} diff --git a/.docfx/templates/modern/public/main.js b/.docfx/templates/modern/public/main.js index 520a512..15800c8 100644 --- a/.docfx/templates/modern/public/main.js +++ b/.docfx/templates/modern/public/main.js @@ -10,3 +10,5 @@ export default { document.body.appendChild(script); } }; + +import './run-actions.js'; diff --git a/.docfx/templates/modern/public/run-actions.js b/.docfx/templates/modern/public/run-actions.js new file mode 100644 index 0000000..7106777 --- /dev/null +++ b/.docfx/templates/modern/public/run-actions.js @@ -0,0 +1,269 @@ +// Optional modern-template enhancement. The association remains usable without JavaScript. +const icons = { + native: '' + + '', + docker: '' + + '', +}; +const waitingForCopy = new WeakSet(); +// Generated scripts are one complete `& { ... }` paste unit, so execution and verification run together. +const executionScript = /^& \{\r?\n#requires -Version 7\.0\r?\n[\s\S]*\r?\n\}\r?\n?$/; + +async function fetchScript(link) { + const url = new URL(link.href); + if (url.origin !== location.origin) throw new Error('Script must be hosted on this site.'); + // Asset URLs are stable per example, so always revalidate rather than copy a stale cached script. + const response = await fetch(url, { mode: 'same-origin', cache: 'no-cache' }); + if (!response.ok) throw new Error('Script unavailable.'); + const script = await response.text(); + if (!executionScript.test(script)) throw new Error('Response is not an execution script.'); + return script; +} + +function previewScript(script, label) { + const dialog = document.createElement('dialog'); + dialog.className = 'docfx-run-preview'; + dialog.setAttribute('aria-label', label + ' run script'); + const heading = document.createElement('h2'); + heading.textContent = label + ' run script'; + const source = document.createElement('pre'); + source.tabIndex = 0; + source.textContent = script; + const close = document.createElement('button'); + close.type = 'button'; + close.className = 'btn btn-secondary'; + close.textContent = 'Close'; + close.addEventListener('click', () => dialog.close()); + dialog.addEventListener('close', () => dialog.remove(), { once: true }); + dialog.append(heading, source, close); + document.body.append(dialog); + dialog.showModal(); +} + +function createAction(link, report) { + const transport = link.dataset.transport; + const label = transport === 'native' ? 'Native' : 'Docker'; + const name = 'Copy ' + label + ' run script'; + const button = document.createElement('button'); + button.type = 'button'; + button.className = 'btn border-0 docfx-run-copy'; + button.title = name + '\nShift-click or right-click to preview'; + button.setAttribute('aria-label', name); + button.setAttribute('aria-description', 'Press Shift+Enter to preview the PowerShell script.'); + button.innerHTML = ''; + const icon = button.firstElementChild; + const check = document.createElement('i'); + check.className = 'bi bi-check-lg'; + check.setAttribute('aria-hidden', 'true'); + + let pending = false; + let resetIcon; + async function act(preview) { + if (pending) return; + pending = true; + report(''); + try { + const script = fetchScript(link); + if (preview) { + previewScript(await script, label); + } else { + // Start the clipboard write during the user's gesture, including while the fetch is pending. + const clipboard = navigator.clipboard; + if (clipboard?.write && typeof ClipboardItem === 'function') { + const text = script.then(value => new Blob([value], { type: 'text/plain' })); + await Promise.all([text, clipboard.write([new ClipboardItem({ 'text/plain': text })])]); + } else { + const text = await script; + await clipboard.writeText(text); + } + clearTimeout(resetIcon); + // Measure DocFX's success markup in the same code block so template overrides apply. + const reference = document.createElement('a'); + reference.className = 'btn border-0 link-success code-action'; + reference.hidden = true; + reference.setAttribute('aria-hidden', 'true'); + reference.style.transition = 'none'; + const referenceIcon = check.cloneNode(false); + referenceIcon.removeAttribute('style'); + reference.append(referenceIcon); + button.closest('pre').prepend(reference); + const appearance = getComputedStyle(referenceIcon, '::before'); + check.style.color = appearance.color; + check.style.fontSize = appearance.fontSize; + reference.remove(); + button.replaceChildren(check); + resetIcon = setTimeout(() => button.replaceChildren(icon), 1000); + report(label + ' script copied.', true); + } + } catch { + report('Could not ' + (preview ? 'preview ' : 'copy ') + label + ' script.'); + } finally { + pending = false; + } + } + + button.addEventListener('click', event => act(event.shiftKey)); + button.addEventListener('contextmenu', event => { + event.preventDefault(); + act(true); + }); + button.addEventListener('keydown', event => { + if (event.shiftKey && event.key === 'Enter') { + event.preventDefault(); + act(true); + } + }); + return button; +} + +export function enhanceRunActions(root = document) { + for (const links of root.querySelectorAll('.docfx-run-actions:not([data-enhanced])')) { + const previous = links.previousElementSibling; + const pre = previous?.matches('pre') ? previous : previous?.querySelector('pre'); + if (!pre?.querySelector(':scope > code:is(.lang-csharp, .language-csharp, .lang-cs, .language-cs)')) continue; + const assets = [...links.querySelectorAll('a[data-transport="native"], a[data-transport="docker"]')]; + if (!assets.length) continue; + + // DocFX imports the custom module before rendering its Lit-managed copy anchor. + if (!pre.querySelector(':scope > a.code-action')) { + if (waitingForCopy.has(pre)) continue; + waitingForCopy.add(pre); + const observer = new MutationObserver(() => { + if (!pre.querySelector(':scope > a.code-action')) return; + observer.disconnect(); + waitingForCopy.delete(pre); + attachToolbar(pre, links, assets); + }); + observer.observe(pre, { childList: true }); + continue; + } + + attachToolbar(pre, links, assets); + } +} + +function attachToolbar(pre, links, assets) { + if (links.hasAttribute('data-enhanced')) return; + const toolbar = document.createElement('span'); + toolbar.className = 'docfx-run-toolbar'; + toolbar.setAttribute('role', 'group'); + toolbar.setAttribute('aria-label', 'Run scripts'); + const status = document.createElement('span'); + status.setAttribute('role', 'status'); + status.className = 'docfx-run-status'; + let clearStatus; + function report(message, visuallyHidden = false) { + clearTimeout(clearStatus); + status.classList.toggle('visually-hidden', visuallyHidden); + status.textContent = message; + if (message) clearStatus = setTimeout(() => { status.textContent = ''; }, 3000); + } + toolbar.append(...assets.map(link => createAction(link, report))); + // Keep our nodes before DocFX's Lit render range, which replaces the original anchor on copy. + pre.prepend(toolbar, status); + pre.classList.add('docfx-runnable'); + links.dataset.enhanced = 'true'; + // Keep the recipe explanation visible when the toolbar replaces the fallback links. + links.after(...links.querySelectorAll(':scope > p')); + links.hidden = true; +} + +if (typeof document !== 'undefined') { + const style = document.createElement('style'); + style.textContent = ` +pre.docfx-runnable { + --run-action-size: 2.25rem; +} +.docfx-run-icon-native { + color: #926bbb; +} +.docfx-run-icon-docker { + color: #4d79d7; +} +.docfx-run-play { + color: #628b2f; +} +pre.docfx-runnable > .code-action, +.docfx-run-toolbar { + display: flex; + position: absolute; + top: .25rem; + opacity: 0; + pointer-events: none; + z-index: 1; +} +pre.docfx-runnable > .code-action, +.docfx-run-copy { + align-items: center; + justify-content: center; + inline-size: var(--run-action-size); + block-size: var(--run-action-size); + padding: 0; + background-color: var(--bs-body-bg); +} +.docfx-run-toolbar { + right: calc(.35rem + var(--run-action-size)); + gap: .15rem; +} +.docfx-run-copy { + display: inline-flex; +} +.docfx-run-copy .bi-check-lg { + pointer-events: none; +} +.docfx-run-copy:hover { + background-color: var(--bs-tertiary-bg); +} +pre.docfx-runnable:hover > :is(.code-action, .docfx-run-toolbar), +pre.docfx-runnable:focus-within > :is(.code-action, .docfx-run-toolbar) { + opacity: 1; + pointer-events: auto; +} +pre.docfx-runnable > .code-action:focus-visible, +.docfx-run-copy:focus-visible { + outline: 2px solid currentColor; + outline-offset: -2px; +} +.docfx-run-status { + position: absolute; + z-index: 1; + top: .25rem; + left: .25rem; + max-inline-size: calc(100% - 3 * var(--run-action-size) - 1rem); + white-space: normal; + pointer-events: none; +} +.docfx-run-status:not(:empty) { + padding: .3rem .5rem; + border-radius: .25rem; + background: var(--bs-body-bg); + color: var(--bs-body-color); +} +.docfx-run-preview { + inline-size: min(52rem, 94vw); + padding: 1rem; + color: var(--bs-body-color); + background: var(--bs-body-bg); + border: 1px solid var(--bs-border-color); + border-radius: .5rem; +} +.docfx-run-preview::backdrop { + background: rgb(0 0 0 / 45%); +} +.docfx-run-preview pre { + max-block-size: 65vh; + padding: .75rem; + background: var(--bs-tertiary-bg); +} +@media (hover: none), (any-pointer: coarse) { + pre.docfx-runnable > :is(.code-action, .docfx-run-toolbar) { + opacity: 1; + pointer-events: auto; + } +} +`; + document.head.append(style); + if (document.readyState === 'loading') document.addEventListener('DOMContentLoaded', () => enhanceRunActions(), { once: true }); + else enhanceRunActions(); +} From 1726c9f6c12ea41e2d834f00edb734f2aa0ea515 Mon Sep 17 00:00:00 2001 From: aicia-bot Date: Fri, 20 Nov 2026 03:24:31 +0100 Subject: [PATCH 02/12] =?UTF-8?q?=F0=9F=93=9D=20refresh=20api=20type=20exa?= =?UTF-8?q?mples=20and=20run-action=20links?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Type pages now link each runnable example to its native and Docker run scripts. Several examples were also rewritten so they compile as standalone programs and state their intent in the surrounding prose. --- ...it.Hosting.ApplicationFixtureExtensions.md | 15 ++ ...ns.Xunit.Hosting.ApplicationHostFactory.md | 16 +- ...ns.Xunit.Hosting.ApplicationTestFactory.md | 43 ++--- ...spNetCore.BlockingManagedWebHostFixture.md | 25 +-- ...etCore.HostBuilderApplicationExtensions.md | 16 ++ ...AspNetCore.Http.FakeHttpContextAccessor.md | 12 ++ ...re.Http.Features.FakeHttpRequestFeature.md | 12 ++ ...e.Http.Features.FakeHttpResponseFeature.md | 12 ++ ...Hosting.AspNetCore.HttpClientExtensions.md | 20 +++ ...etCore.ManagedWebApplicationFixture%601.md | 50 +++--- ...osting.AspNetCore.ManagedWebHostFixture.md | 8 +- ...AspNetCore.ManagedWebMinimalHostFixture.md | 24 ++- ...ng.AspNetCore.MinimalWebHostTestFactory.md | 14 ++ ...ng.AspNetCore.SelfManagedWebHostFixture.md | 29 ++-- ...etCore.SelfManagedWebMinimalHostFixture.md | 14 ++ ....AspNetCore.ServiceCollectionExtensions.md | 17 ++ ...NetCore.WebApplicationFixtureExtensions.md | 15 ++ ...ng.AspNetCore.WebApplicationTestFactory.md | 62 ++++--- ...ing.AspNetCore.WebHostFixtureExtensions.md | 17 ++ ...t.Hosting.AspNetCore.WebHostTestFactory.md | 14 ++ ...NetCore.WebMinimalHostFixtureExtensions.md | 17 ++ ...it.Hosting.GenericHostFixtureExtensions.md | 17 ++ ...xtensions.Xunit.Hosting.HostTestFactory.md | 14 ++ ...tensions.Xunit.Hosting.LoggerExtensions.md | 22 +++ ...t.Hosting.ManagedApplicationFixture%601.md | 159 ++++++++++++++++-- ...nsions.Xunit.Hosting.ManagedHostFixture.md | 4 + ...Xunit.Hosting.ManagedMinimalHostFixture.md | 4 + ...it.Hosting.MinimalHostFixtureExtensions.md | 17 ++ ...ns.Xunit.Hosting.MinimalHostTestFactory.md | 12 ++ ...ns.Xunit.Hosting.SelfManagedHostFixture.md | 13 ++ ...t.Hosting.SelfManagedMinimalHostFixture.md | 13 ++ ...nit.Hosting.ServiceCollectionExtensions.md | 18 ++ ...Xunit.Hosting.ServiceProviderExtensions.md | 20 +++ ...ions.Xunit.Hosting.XunitTestLoggerEntry.md | 14 ++ ....Extensions.Xunit.InMemoryTestStore%601.md | 14 ++ ...belt.Extensions.Xunit.PriorityAttribute.md | 4 + ...ensions.Xunit.PriorityTestMethodOrderer.md | 4 + ...tensions.Xunit.TestOutputHelperAccessor.md | 4 + ...nsions.Xunit.TestOutputHelperExtensions.md | 16 ++ ...debelt.Extensions.Xunit.WildcardOptions.md | 4 + 40 files changed, 689 insertions(+), 136 deletions(-) diff --git a/.docfx/api/types/Codebelt.Extensions.Xunit.Hosting.ApplicationFixtureExtensions.md b/.docfx/api/types/Codebelt.Extensions.Xunit.Hosting.ApplicationFixtureExtensions.md index 4fcbc29..f6ffe8a 100644 --- a/.docfx/api/types/Codebelt.Extensions.Xunit.Hosting.ApplicationFixtureExtensions.md +++ b/.docfx/api/types/Codebelt.Extensions.Xunit.Hosting.ApplicationFixtureExtensions.md @@ -8,6 +8,7 @@ The following example validates that an `IApplicationFixture` has b ```csharp using Codebelt.Extensions.Xunit.Hosting; +using Xunit; namespace HostFixtureTests; @@ -18,4 +19,18 @@ public class HostStateGuard return fixture.HasValidState(); } } + +public sealed class RunExample +{ + [Fact] + public void ExercisesExample() + { + using var fixture = new ManagedApplicationFixture(); + Assert.False(new HostStateGuard().EnsureFixtureIsReady(fixture)); + } +} ``` + + + + diff --git a/.docfx/api/types/Codebelt.Extensions.Xunit.Hosting.ApplicationHostFactory.md b/.docfx/api/types/Codebelt.Extensions.Xunit.Hosting.ApplicationHostFactory.md index afe7e9f..702cf87 100644 --- a/.docfx/api/types/Codebelt.Extensions.Xunit.Hosting.ApplicationHostFactory.md +++ b/.docfx/api/types/Codebelt.Extensions.Xunit.Hosting.ApplicationHostFactory.md @@ -4,9 +4,10 @@ example: - *content --- -The test project references a worker application's entry-point assembly. `ApplicationHostFactory.Create` preserves the compatibility path, including direct use of an application's `CreateHostBuilder` when it is available. `ApplicationTestFactory.Create` uses `ManagedApplicationFixture` by default when the application entry point should own startup; pass an explicit fixture when a shared test context needs to customize its lifecycle. Because this lower-level factory returns the host directly, the caller still owns disposal. +Use `ApplicationHostFactory.Create` when you need a built `IHost` and will own its disposal. This standalone console example uses its own executable as the entry-point assembly to demonstrate the compatibility path. The factory calls `CreateHostBuilder` directly, applies the service registration supplied by the caller, and builds the host. `Main` resolves and prints the configured worker identity. In a test of an existing worker, reference the application project and use its entry-point type as `TEntryPoint`. Use `ApplicationTestFactory.Create` when the application entry point should own startup. ```csharp +using System; using Codebelt.Extensions.Xunit.Hosting; using Microsoft.Extensions.DependencyInjection; using Microsoft.Extensions.Hosting; @@ -39,8 +40,17 @@ public sealed class WorkerProgram public static void Main(string[] args) { - using var host = CreateHostBuilder(args).Build(); - host.Run(); + var identity = new ApplicationHostFactoryExample().GetTestIdentity(); + if (identity != "Test inventory worker") + { + throw new InvalidOperationException(identity); + } + + Console.WriteLine(identity); } } ``` + + + + diff --git a/.docfx/api/types/Codebelt.Extensions.Xunit.Hosting.ApplicationTestFactory.md b/.docfx/api/types/Codebelt.Extensions.Xunit.Hosting.ApplicationTestFactory.md index 641c4d0..db7fd1b 100644 --- a/.docfx/api/types/Codebelt.Extensions.Xunit.Hosting.ApplicationTestFactory.md +++ b/.docfx/api/types/Codebelt.Extensions.Xunit.Hosting.ApplicationTestFactory.md @@ -4,41 +4,28 @@ example: - *content --- -The test project references a worker application whose entry point registers `WorkerIdentity`. `ApplicationTestFactory` uses `ManagedApplicationFixture` by default, runs that application's real host setup, and exposes its services and environment through an owned test context so the test can verify application behavior without recreating `Program` configuration. Pass an explicit `IApplicationFixture` when the test needs a different lifecycle. +Use `ApplicationTestFactory.Create` to test an existing worker application in an owned test context. The default `ManagedApplicationFixture` lets the worker entry point own host startup. The excerpt below belongs to an xUnit test project that references the separate `BootstrapperMinimalWorker` application. It verifies the marker registered by the application, the Development environment, and the availability of `IHostApplicationLifetime`. Pass an explicit `IApplicationFixture` when the test needs a different lifecycle. ```csharp -using Codebelt.Extensions.Xunit.Hosting; -using Microsoft.Extensions.DependencyInjection; -using Microsoft.Extensions.Hosting; -using Xunit; - -namespace WorkerApp.Tests; - -public sealed class ApplicationTestFactoryExample -{ +// docfx-context: test/Codebelt.Extensions.Xunit.Hosting.FunctionalTests/Codebelt.Extensions.Xunit.Hosting.FunctionalTests.csproj +// docfx-source: test/Codebelt.Extensions.Xunit.Hosting.FunctionalTests/ApplicationTestFactoryTest.cs [Fact] - public void Create_BootstrapsWorkerApplicationServices() + public void Create_ShouldBootstrapApplication_WhenEntryPointUsesBootstrapperMinimalWorkerProgram() { - using var application = ApplicationTestFactory.Create(); + using var application = ApplicationTestFactory.Create(); - var identity = application.Host.Services.GetRequiredService(); + var marker = application.Host.Services.GetRequiredService(); - Assert.Equal("Inventory worker", identity.Name); - Assert.Equal(Environments.Development, application.Environment.EnvironmentName); + Assert.Equal("Bootstrapper Minimal Worker", marker.Value); + Assert.Equal("Development", application.Environment.EnvironmentName); + Assert.NotNull(application.Host.Services.GetRequiredService()); } -} +``` -public sealed record WorkerIdentity(string Name); + +
View Native Script · View Docker Script

Runs the pinned repository test Codebelt.Extensions.Xunit.Hosting.ApplicationTestFactoryTest.Create_ShouldBootstrapApplication_WhenEntryPointUsesBootstrapperMinimalWorkerProgram.

The scripts run the maintained worker integration test and verify its registered marker and Development environment.

+ -public sealed class WorkerProgram -{ - public static void Main(string[] args) - { - var builder = Host.CreateApplicationBuilder(args); - builder.Services.AddSingleton(new WorkerIdentity("Inventory worker")); +The [maintained worker test](https://github.com/codebeltnet/xunit/blob/84b13767cb9484f8f3a36a71875662edfdb3e511/test/Codebelt.Extensions.Xunit.Hosting.FunctionalTests/ApplicationTestFactoryTest.cs) checks the same service resolution and environment against a worker in its own application project. - using var host = builder.Build(); - host.Run(); - } -} -``` +The [application entry point](https://github.com/codebeltnet/xunit/blob/84b13767cb9484f8f3a36a71875662edfdb3e511/app/Codebelt.Extensions.Xunit.Hosting.BootstrapperMinimalWorker.App/Program.cs) defines the behavior the test exercises. The [functional test project](https://github.com/codebeltnet/xunit/blob/84b13767cb9484f8f3a36a71875662edfdb3e511/test/Codebelt.Extensions.Xunit.Hosting.FunctionalTests/Codebelt.Extensions.Xunit.Hosting.FunctionalTests.csproj) references that executable project. diff --git a/.docfx/api/types/Codebelt.Extensions.Xunit.Hosting.AspNetCore.BlockingManagedWebHostFixture.md b/.docfx/api/types/Codebelt.Extensions.Xunit.Hosting.AspNetCore.BlockingManagedWebHostFixture.md index 42b28db..6f7ade3 100644 --- a/.docfx/api/types/Codebelt.Extensions.Xunit.Hosting.AspNetCore.BlockingManagedWebHostFixture.md +++ b/.docfx/api/types/Codebelt.Extensions.Xunit.Hosting.AspNetCore.BlockingManagedWebHostFixture.md @@ -4,28 +4,33 @@ example: - *content --- -The following example uses `BlockingManagedWebHostFixture` as a fixture for xUnit tests that need a synchronously started web host. The fixture manages the full web host lifecycle and blocks until the host is started before returning control to the test. +The following example passes a `BlockingManagedWebHostFixture` to `WebHostTestFactory.Create` when a test needs a synchronously started web host. The factory configures the host and returns control after startup, so the test can check `ApplicationStarted` immediately. ```csharp using Codebelt.Extensions.Xunit.Hosting.AspNetCore; using Microsoft.Extensions.DependencyInjection; +using Microsoft.Extensions.Hosting; using Xunit; namespace WebFixtureTests; -public class WebHostIntegrationTest : IClassFixture +public class WebHostIntegrationTest { - private readonly BlockingManagedWebHostFixture _fixture; - - public WebHostIntegrationTest(BlockingManagedWebHostFixture fixture) - { - _fixture = fixture; - } - [Fact] public void HostShouldBeStarted() { - Assert.True(_fixture.HasValidState()); + using var fixture = new BlockingManagedWebHostFixture(); + using var app = WebHostTestFactory.Create(hostFixture: fixture); + + Assert.True(fixture.HasValidState()); + var lifetime = app.Host.Services.GetRequiredService(); + Assert.True(lifetime.ApplicationStarted.IsCancellationRequested); } } ``` + + + + + +The [maintained fixture test](https://github.com/codebeltnet/xunit/blob/84b13767cb9484f8f3a36a71875662edfdb3e511/test/Codebelt.Extensions.Xunit.Hosting.AspNetCore.Tests/BlockingManagedWebHostFixtureTest.cs) shows the basic factory setup in the repository’s test suite. diff --git a/.docfx/api/types/Codebelt.Extensions.Xunit.Hosting.AspNetCore.HostBuilderApplicationExtensions.md b/.docfx/api/types/Codebelt.Extensions.Xunit.Hosting.AspNetCore.HostBuilderApplicationExtensions.md index d439206..b030c3a 100644 --- a/.docfx/api/types/Codebelt.Extensions.Xunit.Hosting.AspNetCore.HostBuilderApplicationExtensions.md +++ b/.docfx/api/types/Codebelt.Extensions.Xunit.Hosting.AspNetCore.HostBuilderApplicationExtensions.md @@ -8,7 +8,9 @@ The following example converts an `IHostApplicationBuilder` to an `IHostBuilder` ```csharp using Codebelt.Extensions.Xunit.Hosting.AspNetCore; +using Microsoft.AspNetCore.Builder; using Microsoft.Extensions.Hosting; +using Xunit; namespace WebFixtureTests; @@ -19,4 +21,18 @@ public class BuilderConverter return builder.ToHostBuilder(); } } + +public sealed class RunExample +{ + [Fact] + public void ReturnsTheWebHostBuilder() + { + var builder = WebApplication.CreateBuilder(); + Assert.Same(builder.Host, new BuilderConverter().Convert(builder)); + } +} ``` + + + + diff --git a/.docfx/api/types/Codebelt.Extensions.Xunit.Hosting.AspNetCore.Http.FakeHttpContextAccessor.md b/.docfx/api/types/Codebelt.Extensions.Xunit.Hosting.AspNetCore.Http.FakeHttpContextAccessor.md index 597e628..8f80a5b 100644 --- a/.docfx/api/types/Codebelt.Extensions.Xunit.Hosting.AspNetCore.Http.FakeHttpContextAccessor.md +++ b/.docfx/api/types/Codebelt.Extensions.Xunit.Hosting.AspNetCore.Http.FakeHttpContextAccessor.md @@ -20,4 +20,16 @@ public class HttpContextExample Console.WriteLine(accessor.HttpContext.Request.Method); } } + +internal static class RunExample +{ + static void Main() + { + new HttpContextExample().Demonstrate(); + } +} ``` + + + + diff --git a/.docfx/api/types/Codebelt.Extensions.Xunit.Hosting.AspNetCore.Http.Features.FakeHttpRequestFeature.md b/.docfx/api/types/Codebelt.Extensions.Xunit.Hosting.AspNetCore.Http.Features.FakeHttpRequestFeature.md index 258eb86..a668c93 100644 --- a/.docfx/api/types/Codebelt.Extensions.Xunit.Hosting.AspNetCore.Http.Features.FakeHttpRequestFeature.md +++ b/.docfx/api/types/Codebelt.Extensions.Xunit.Hosting.AspNetCore.Http.Features.FakeHttpRequestFeature.md @@ -20,4 +20,16 @@ public class RequestFeatureExample Console.WriteLine(request.Method); } } + +internal static class RunExample +{ + static void Main() + { + new RequestFeatureExample().Demonstrate(); + } +} ``` + + + + diff --git a/.docfx/api/types/Codebelt.Extensions.Xunit.Hosting.AspNetCore.Http.Features.FakeHttpResponseFeature.md b/.docfx/api/types/Codebelt.Extensions.Xunit.Hosting.AspNetCore.Http.Features.FakeHttpResponseFeature.md index adbebfa..29db8f6 100644 --- a/.docfx/api/types/Codebelt.Extensions.Xunit.Hosting.AspNetCore.Http.Features.FakeHttpResponseFeature.md +++ b/.docfx/api/types/Codebelt.Extensions.Xunit.Hosting.AspNetCore.Http.Features.FakeHttpResponseFeature.md @@ -20,4 +20,16 @@ public class ResponseFeatureExample Console.WriteLine(response.StatusCode); } } + +internal static class RunExample +{ + static void Main() + { + new ResponseFeatureExample().Demonstrate(); + } +} ``` + + + + diff --git a/.docfx/api/types/Codebelt.Extensions.Xunit.Hosting.AspNetCore.HttpClientExtensions.md b/.docfx/api/types/Codebelt.Extensions.Xunit.Hosting.AspNetCore.HttpClientExtensions.md index 566e5df..82bc8cd 100644 --- a/.docfx/api/types/Codebelt.Extensions.Xunit.Hosting.AspNetCore.HttpClientExtensions.md +++ b/.docfx/api/types/Codebelt.Extensions.Xunit.Hosting.AspNetCore.HttpClientExtensions.md @@ -11,6 +11,8 @@ using System; using System.Net.Http; using System.Threading.Tasks; using Codebelt.Extensions.Xunit.Hosting.AspNetCore; +using Microsoft.AspNetCore.Builder; +using Microsoft.AspNetCore.TestHost; namespace WebFixtureTests; @@ -22,4 +24,22 @@ public class HttpClientExample Console.WriteLine(response.StatusCode); } } + +internal static class RunExample +{ + static async Task Main() + { + using var app = WebHostTestFactory.Create(pipelineSetup: app => app.Run(context => + { + context.Response.StatusCode = 202; + return Task.CompletedTask; + })); + using var client = app.Host.GetTestClient(); + await new HttpClientExample().DemonstrateAsync(client); + } +} ``` + + + + diff --git a/.docfx/api/types/Codebelt.Extensions.Xunit.Hosting.AspNetCore.ManagedWebApplicationFixture%601.md b/.docfx/api/types/Codebelt.Extensions.Xunit.Hosting.AspNetCore.ManagedWebApplicationFixture%601.md index 4926258..49b7d72 100644 --- a/.docfx/api/types/Codebelt.Extensions.Xunit.Hosting.AspNetCore.ManagedWebApplicationFixture%601.md +++ b/.docfx/api/types/Codebelt.Extensions.Xunit.Hosting.AspNetCore.ManagedWebApplicationFixture%601.md @@ -4,47 +4,47 @@ example: - *content --- -Use `ManagedWebApplicationFixture` when an xUnit class fixture should exercise an ASP.NET Core application's real entry point and let that entry point start the in-memory server. Derive the test from `WebApplicationTest` and pass the fixture to its base constructor so the base class initializes the fixture through `ConfigureHost` before the test reads `Server`. Fixture setup remains lazy; consuming the test host starts the deferred host, after which the test can create a client from the exposed `TestServer` and verify the application's endpoint behavior. `WebApplicationTestFactory` uses this fixture by default. +Use `ManagedWebApplicationFixture` with `WebApplicationTest` when an xUnit test class needs the real ASP.NET Core entry point and an in-memory `TestServer`. In this excerpt, xUnit supplies the fixture to the constructor, and the base class configures it before the test accesses `Host`. The test project references the separate `Program.App` executable. A request to `/` verifies that the application resolves its registered marker and reports the Development environment. ```csharp +// docfx-context: test/Codebelt.Extensions.Xunit.Hosting.AspNetCore.FunctionalTests/Codebelt.Extensions.Xunit.Hosting.AspNetCore.FunctionalTests.csproj +// docfx-source: test/Codebelt.Extensions.Xunit.Hosting.AspNetCore.FunctionalTests/WebApplicationTestTest.cs +using System; +using System.Collections.Generic; using System.Threading.Tasks; -using Codebelt.Extensions.Xunit.Hosting.AspNetCore; -using Microsoft.AspNetCore.Builder; +using Codebelt.Extensions.Xunit.Hosting.Program.App; +using Microsoft.AspNetCore.Hosting; +using Microsoft.AspNetCore.TestHost; +using Microsoft.Extensions.Configuration; using Microsoft.Extensions.DependencyInjection; using Xunit; +using ModernProgram = Codebelt.Extensions.Xunit.Hosting.Program.App.Program; -namespace CatalogApi.Tests; +namespace Codebelt.Extensions.Xunit.Hosting.AspNetCore; -public sealed class CatalogApiTest : WebApplicationTest> +public class WebApplicationTestTest : WebApplicationTest> { - public CatalogApiTest(ManagedWebApplicationFixture fixture, ITestOutputHelper output) - : base(fixture, output) + public WebApplicationTestTest(ManagedWebApplicationFixture hostFixture, ITestOutputHelper output) : base(hostFixture, output) { } [Fact] - public async Task HealthEndpoint_ReturnsApplicationState() + public async Task ShouldBootstrapApplication_WhenEntryPointUsesModernProgramPattern() { - using var client = Server.CreateClient(); + using var client = Host.GetTestClient(); - var body = await client.GetStringAsync("/health").ConfigureAwait(false); + var response = await client.GetAsync("/").ConfigureAwait(false); + var body = await response.Content.ReadAsStringAsync().ConfigureAwait(false); - Assert.Equal("ready", body); + Assert.True(response.IsSuccessStatusCode); + Assert.Equal("Modern Program|Development", body); } -} +``` -public sealed record CatalogStatus(string Value); + +
View Native Script · View Docker Script

Runs the pinned repository test Codebelt.Extensions.Xunit.Hosting.AspNetCore.WebApplicationTestTest.ShouldBootstrapApplication_WhenEntryPointUsesModernProgramPattern.

The scripts start the maintained ASP.NET Core application through the same fixture and verify its HTTP response.

+ -public sealed class CatalogProgram -{ - public static void Main(string[] args) - { - var builder = WebApplication.CreateBuilder(args); - builder.Services.AddSingleton(new CatalogStatus("ready")); +The [maintained web application test](https://github.com/codebeltnet/xunit/blob/84b13767cb9484f8f3a36a71875662edfdb3e511/test/Codebelt.Extensions.Xunit.Hosting.AspNetCore.FunctionalTests/WebApplicationTestTest.cs) uses the managed fixture with a separate ASP.NET Core entry-point assembly. - var app = builder.Build(); - app.MapGet("/health", (CatalogStatus status) => status.Value); - app.Run(); - } -} -``` +The [application entry point](https://github.com/codebeltnet/xunit/blob/84b13767cb9484f8f3a36a71875662edfdb3e511/app/Codebelt.Extensions.Xunit.Hosting.Program.App/Program.cs) defines the behavior the test exercises. The [functional test project](https://github.com/codebeltnet/xunit/blob/84b13767cb9484f8f3a36a71875662edfdb3e511/test/Codebelt.Extensions.Xunit.Hosting.AspNetCore.FunctionalTests/Codebelt.Extensions.Xunit.Hosting.AspNetCore.FunctionalTests.csproj) references that executable project. diff --git a/.docfx/api/types/Codebelt.Extensions.Xunit.Hosting.AspNetCore.ManagedWebHostFixture.md b/.docfx/api/types/Codebelt.Extensions.Xunit.Hosting.AspNetCore.ManagedWebHostFixture.md index 36bddc9..2fc39ed 100644 --- a/.docfx/api/types/Codebelt.Extensions.Xunit.Hosting.AspNetCore.ManagedWebHostFixture.md +++ b/.docfx/api/types/Codebelt.Extensions.Xunit.Hosting.AspNetCore.ManagedWebHostFixture.md @@ -42,12 +42,16 @@ public class MiddlewareTest : WebHostTest } } -public class TestMiddleware +public class TestMiddleware(RequestDelegate next) { - public async Task InvokeAsync(HttpContext context, RequestDelegate next) + public async Task InvokeAsync(HttpContext context) { context.Response.Headers["X-Test"] = "true"; await next(context); } } ``` + + + + diff --git a/.docfx/api/types/Codebelt.Extensions.Xunit.Hosting.AspNetCore.ManagedWebMinimalHostFixture.md b/.docfx/api/types/Codebelt.Extensions.Xunit.Hosting.AspNetCore.ManagedWebMinimalHostFixture.md index 860ad0a..e6926f7 100644 --- a/.docfx/api/types/Codebelt.Extensions.Xunit.Hosting.AspNetCore.ManagedWebMinimalHostFixture.md +++ b/.docfx/api/types/Codebelt.Extensions.Xunit.Hosting.AspNetCore.ManagedWebMinimalHostFixture.md @@ -34,11 +34,31 @@ public class MinimalApiTest : MinimalWebHostTest } } -internal class TestMiddleware +public class TestMiddleware(RequestDelegate next) { - public async Task InvokeAsync(HttpContext context, RequestDelegate next) + public async Task InvokeAsync(HttpContext context) { + context.Response.Headers["X-Test"] = "true"; await next(context); } } + +public sealed class RunExample(ManagedWebMinimalHostFixture fixture, ITestOutputHelper output) : MinimalApiTest(fixture, output) +{ + [Fact] + public async Task BuildsAndInvokesTheConfiguredPipeline() + { + var context = new DefaultHttpContext + { + RequestServices = Application.ApplicationServices + }; + await Application.Build()(context); + Assert.Equal("true", context.Response.Headers["X-Test"].ToString()); + Assert.NotNull(context.RequestServices.GetRequiredService()); + } +} ``` + + + + diff --git a/.docfx/api/types/Codebelt.Extensions.Xunit.Hosting.AspNetCore.MinimalWebHostTestFactory.md b/.docfx/api/types/Codebelt.Extensions.Xunit.Hosting.AspNetCore.MinimalWebHostTestFactory.md index 6ba6a8d..cdec5e8 100644 --- a/.docfx/api/types/Codebelt.Extensions.Xunit.Hosting.AspNetCore.MinimalWebHostTestFactory.md +++ b/.docfx/api/types/Codebelt.Extensions.Xunit.Hosting.AspNetCore.MinimalWebHostTestFactory.md @@ -12,6 +12,7 @@ using Codebelt.Extensions.Xunit.Hosting.AspNetCore; using Microsoft.AspNetCore.Builder; using Microsoft.AspNetCore.Http; using Microsoft.Extensions.DependencyInjection; +using Xunit; namespace HealthEndpoint.Tests; @@ -32,4 +33,17 @@ public sealed class MinimalWebHostTestFactoryExample } public sealed record HealthState(string Value); + +public sealed class RunExample +{ + [Fact] + public async Task ExercisesExample() + { + Assert.Equal("healthy", await new MinimalWebHostTestFactoryExample().ReadHealthStateAsync()); + } +} ``` + + + + diff --git a/.docfx/api/types/Codebelt.Extensions.Xunit.Hosting.AspNetCore.SelfManagedWebHostFixture.md b/.docfx/api/types/Codebelt.Extensions.Xunit.Hosting.AspNetCore.SelfManagedWebHostFixture.md index a0bbfed..f036a2f 100644 --- a/.docfx/api/types/Codebelt.Extensions.Xunit.Hosting.AspNetCore.SelfManagedWebHostFixture.md +++ b/.docfx/api/types/Codebelt.Extensions.Xunit.Hosting.AspNetCore.SelfManagedWebHostFixture.md @@ -7,28 +7,25 @@ example: Use `SelfManagedWebHostFixture` when a conventional test pipeline must exist before the server starts. The example builds middleware, explicitly starts the host, and then sends a request through `TestServer`, making the startup boundary and resulting response visible. ```csharp -using System.Threading.Tasks; +// Program.cs +using System; using Codebelt.Extensions.Xunit.Hosting.AspNetCore; using Microsoft.AspNetCore.Builder; using Microsoft.AspNetCore.Http; using Microsoft.AspNetCore.TestHost; using Microsoft.Extensions.Hosting; -namespace DeferredPipeline.Tests; +using var host = WebHostTestFactory.Create( + pipelineSetup: app => app.Run(context => + context.Response.WriteAsync("started on demand")), + hostFixture: new SelfManagedWebHostFixture()); -public sealed class SelfManagedWebHostFixtureExample -{ - public async Task StartPipelineWhenReadyAsync() - { - using var host = WebHostTestFactory.Create( - pipelineSetup: app => app.Run(context => - context.Response.WriteAsync("started on demand")), - hostFixture: new SelfManagedWebHostFixture()); +await host.Host.StartAsync().ConfigureAwait(false); +using var client = host.Host.GetTestClient(); - await host.Host.StartAsync().ConfigureAwait(false); - using var client = host.Host.GetTestClient(); - - return await client.GetStringAsync("/").ConfigureAwait(false); - } -} +Console.WriteLine(await client.GetStringAsync("/").ConfigureAwait(false)); ``` + + + + diff --git a/.docfx/api/types/Codebelt.Extensions.Xunit.Hosting.AspNetCore.SelfManagedWebMinimalHostFixture.md b/.docfx/api/types/Codebelt.Extensions.Xunit.Hosting.AspNetCore.SelfManagedWebMinimalHostFixture.md index 633fd47..20f0256 100644 --- a/.docfx/api/types/Codebelt.Extensions.Xunit.Hosting.AspNetCore.SelfManagedWebMinimalHostFixture.md +++ b/.docfx/api/types/Codebelt.Extensions.Xunit.Hosting.AspNetCore.SelfManagedWebMinimalHostFixture.md @@ -14,6 +14,7 @@ using Microsoft.AspNetCore.Http; using Microsoft.AspNetCore.TestHost; using Microsoft.Extensions.DependencyInjection; using Microsoft.Extensions.Hosting; +using Xunit; namespace DeferredHealthEndpoint.Tests; @@ -38,4 +39,17 @@ public sealed class SelfManagedWebMinimalHostFixtureExample } public sealed record HealthState(string Value); + +public sealed class RunExample +{ + [Fact] + public async Task ExercisesExample() + { + Assert.Equal("healthy", await new SelfManagedWebMinimalHostFixtureExample().StartHealthEndpointWhenReadyAsync()); + } +} ``` + + + + diff --git a/.docfx/api/types/Codebelt.Extensions.Xunit.Hosting.AspNetCore.ServiceCollectionExtensions.md b/.docfx/api/types/Codebelt.Extensions.Xunit.Hosting.AspNetCore.ServiceCollectionExtensions.md index 1095e01..6021637 100644 --- a/.docfx/api/types/Codebelt.Extensions.Xunit.Hosting.AspNetCore.ServiceCollectionExtensions.md +++ b/.docfx/api/types/Codebelt.Extensions.Xunit.Hosting.AspNetCore.ServiceCollectionExtensions.md @@ -8,7 +8,9 @@ The following example registers a fake `IHttpContextAccessor` on an `IServiceCol ```csharp using Codebelt.Extensions.Xunit.Hosting.AspNetCore; +using Microsoft.AspNetCore.Http; using Microsoft.Extensions.DependencyInjection; +using Xunit; namespace WebFixtureTests; @@ -19,4 +21,19 @@ public class ExampleFixture return services.AddFakeHttpContextAccessor(ServiceLifetime.Scoped); } } + +public sealed class RunExample +{ + [Fact] + public void ExercisesExample() + { + using var provider = new ExampleFixture().ConfigureServices(new ServiceCollection()).BuildServiceProvider(); + using var scope = provider.CreateScope(); + Assert.IsType(scope.ServiceProvider.GetRequiredService()); + } +} ``` + + + + diff --git a/.docfx/api/types/Codebelt.Extensions.Xunit.Hosting.AspNetCore.WebApplicationFixtureExtensions.md b/.docfx/api/types/Codebelt.Extensions.Xunit.Hosting.AspNetCore.WebApplicationFixtureExtensions.md index 9ddc25f..8bf9b74 100644 --- a/.docfx/api/types/Codebelt.Extensions.Xunit.Hosting.AspNetCore.WebApplicationFixtureExtensions.md +++ b/.docfx/api/types/Codebelt.Extensions.Xunit.Hosting.AspNetCore.WebApplicationFixtureExtensions.md @@ -8,6 +8,7 @@ The following example validates that an `IWebApplicationFixture` ha ```csharp using Codebelt.Extensions.Xunit.Hosting.AspNetCore; +using Xunit; namespace WebFixtureTests; @@ -18,4 +19,18 @@ public class WebAppStateGuard return fixture.HasValidState(); } } + +public sealed class RunExample +{ + [Fact] + public void ExercisesExample() + { + using var fixture = new ManagedWebApplicationFixture(); + Assert.False(new WebAppStateGuard().EnsureFixtureIsReady(fixture)); + } +} ``` + + + + diff --git a/.docfx/api/types/Codebelt.Extensions.Xunit.Hosting.AspNetCore.WebApplicationTestFactory.md b/.docfx/api/types/Codebelt.Extensions.Xunit.Hosting.AspNetCore.WebApplicationTestFactory.md index 0d93104..2cb4ded 100644 --- a/.docfx/api/types/Codebelt.Extensions.Xunit.Hosting.AspNetCore.WebApplicationTestFactory.md +++ b/.docfx/api/types/Codebelt.Extensions.Xunit.Hosting.AspNetCore.WebApplicationTestFactory.md @@ -4,49 +4,47 @@ example: - *content --- -The test project references a minimal ASP.NET Core application with a `/health` endpoint. `WebApplicationTestFactory` uses `ManagedWebApplicationFixture` by default, runs that real entry point on `TestServer`, applies a test-only service override through `IWebHostBuilder`, and gives the test an owned host from which it creates an HTTP client. Pass an explicit `IWebApplicationFixture` when the test needs a different lifecycle. +Use `WebApplicationTestFactory.Create` to exercise an existing ASP.NET Core application through `TestServer`. The default `ManagedWebApplicationFixture` runs the entry point from the separate `Program.App` project. In this excerpt from the functional test, the web-host setup supplies configuration and registers a service. Requests to `/configuration` and `/custom-service` verify that the application endpoints see both changes. The test disposes the client and the factory context. ```csharp -using System.Threading.Tasks; -using Codebelt.Extensions.Xunit.Hosting.AspNetCore; -using Microsoft.AspNetCore.Builder; -using Microsoft.AspNetCore.Hosting; -using Microsoft.AspNetCore.TestHost; -using Microsoft.Extensions.DependencyInjection; -using Xunit; - -namespace CatalogApi.Tests; - -public sealed class WebApplicationTestFactoryExample -{ +// docfx-context: test/Codebelt.Extensions.Xunit.Hosting.AspNetCore.FunctionalTests/Codebelt.Extensions.Xunit.Hosting.AspNetCore.FunctionalTests.csproj +// docfx-source: test/Codebelt.Extensions.Xunit.Hosting.AspNetCore.FunctionalTests/WebApplicationTestFactoryTest.cs [Fact] - public async Task Create_UsesTheApplicationPipelineAndTestOverrides() + public async Task Create_ShouldApplyWebHostConfiguration_WhenWebHostSetupIsProvided() { - using var application = WebApplicationTestFactory.Create(builder => + using var application = WebApplicationTestFactory.Create(builder => { + builder.ConfigureAppConfiguration((_, configuration) => + { + configuration.AddInMemoryCollection(new Dictionary + { + ["ProgramLane:Message"] = "Configured from WebApplicationTestFactory" + }); + }); + builder.ConfigureServices(services => - services.AddSingleton(new CatalogStatus("test-ready"))); + { + services.AddSingleton(new ProgramCustomization("Custom service from WebApplicationTestFactory")); + }); }); using var client = application.Host.GetTestClient(); - var body = await client.GetStringAsync("/health").ConfigureAwait(false); + var configurationResponse = await client.GetAsync("/configuration").ConfigureAwait(false); + var configurationBody = await configurationResponse.Content.ReadAsStringAsync().ConfigureAwait(false); + var serviceResponse = await client.GetAsync("/custom-service").ConfigureAwait(false); + var serviceBody = await serviceResponse.Content.ReadAsStringAsync().ConfigureAwait(false); - Assert.Equal("test-ready", body); + Assert.True(configurationResponse.IsSuccessStatusCode); + Assert.Equal("Configured from WebApplicationTestFactory", configurationBody); + Assert.True(serviceResponse.IsSuccessStatusCode); + Assert.Equal("Custom service from WebApplicationTestFactory", serviceBody); } -} +``` -public sealed record CatalogStatus(string Value); + +
View Native Script · View Docker Script

Runs the pinned repository test Codebelt.Extensions.Xunit.Hosting.AspNetCore.WebApplicationTestFactoryTest.Create_ShouldApplyWebHostConfiguration_WhenWebHostSetupIsProvided.

The scripts run the maintained integration test, which overrides services and configuration and verifies the results through HTTP endpoints.

+ -public sealed class CatalogProgram -{ - public static void Main(string[] args) - { - var builder = WebApplication.CreateBuilder(args); - builder.Services.AddSingleton(new CatalogStatus("ready")); +The [maintained factory test](https://github.com/codebeltnet/xunit/blob/84b13767cb9484f8f3a36a71875662edfdb3e511/test/Codebelt.Extensions.Xunit.Hosting.AspNetCore.FunctionalTests/WebApplicationTestFactoryTest.cs) shows how service and configuration overrides reach the application endpoints. - var app = builder.Build(); - app.MapGet("/health", (CatalogStatus status) => status.Value); - app.Run(); - } -} -``` +The [application entry point](https://github.com/codebeltnet/xunit/blob/84b13767cb9484f8f3a36a71875662edfdb3e511/app/Codebelt.Extensions.Xunit.Hosting.Program.App/Program.cs) defines the behavior the test exercises. The [functional test project](https://github.com/codebeltnet/xunit/blob/84b13767cb9484f8f3a36a71875662edfdb3e511/test/Codebelt.Extensions.Xunit.Hosting.AspNetCore.FunctionalTests/Codebelt.Extensions.Xunit.Hosting.AspNetCore.FunctionalTests.csproj) references that executable project. diff --git a/.docfx/api/types/Codebelt.Extensions.Xunit.Hosting.AspNetCore.WebHostFixtureExtensions.md b/.docfx/api/types/Codebelt.Extensions.Xunit.Hosting.AspNetCore.WebHostFixtureExtensions.md index e835847..0923559 100644 --- a/.docfx/api/types/Codebelt.Extensions.Xunit.Hosting.AspNetCore.WebHostFixtureExtensions.md +++ b/.docfx/api/types/Codebelt.Extensions.Xunit.Hosting.AspNetCore.WebHostFixtureExtensions.md @@ -8,6 +8,7 @@ The following example validates that an `IWebHostFixture` has a valid initialize ```csharp using Codebelt.Extensions.Xunit.Hosting.AspNetCore; +using Xunit; namespace WebFixtureTests; @@ -18,4 +19,20 @@ public class WebHostStateGuard return fixture.HasValidState(); } } + +public sealed class RunExample +{ + [Fact] + public void ExercisesExample() + { + using var fixture = new ManagedWebHostFixture(); + Assert.False(new WebHostStateGuard().EnsureFixtureIsReady(fixture)); + using var app = WebHostTestFactory.Create(hostFixture: fixture); + Assert.True(new WebHostStateGuard().EnsureFixtureIsReady(fixture)); + } +} ``` + + + + diff --git a/.docfx/api/types/Codebelt.Extensions.Xunit.Hosting.AspNetCore.WebHostTestFactory.md b/.docfx/api/types/Codebelt.Extensions.Xunit.Hosting.AspNetCore.WebHostTestFactory.md index 0f08606..b1967fa 100644 --- a/.docfx/api/types/Codebelt.Extensions.Xunit.Hosting.AspNetCore.WebHostTestFactory.md +++ b/.docfx/api/types/Codebelt.Extensions.Xunit.Hosting.AspNetCore.WebHostTestFactory.md @@ -12,6 +12,7 @@ using Codebelt.Extensions.Xunit.Hosting.AspNetCore; using Microsoft.AspNetCore.Builder; using Microsoft.AspNetCore.Http; using Microsoft.Extensions.DependencyInjection; +using Xunit; namespace RequestPipeline.Tests; @@ -32,4 +33,17 @@ public sealed class WebHostTestFactoryExample } public sealed record PipelineStatus(string Value); + +public sealed class RunExample +{ + [Fact] + public async Task ExercisesExample() + { + Assert.Equal("ready", await new WebHostTestFactoryExample().InvokeStatusMiddlewareAsync()); + } +} ``` + + + + diff --git a/.docfx/api/types/Codebelt.Extensions.Xunit.Hosting.AspNetCore.WebMinimalHostFixtureExtensions.md b/.docfx/api/types/Codebelt.Extensions.Xunit.Hosting.AspNetCore.WebMinimalHostFixtureExtensions.md index 43a1464..fb95f15 100644 --- a/.docfx/api/types/Codebelt.Extensions.Xunit.Hosting.AspNetCore.WebMinimalHostFixtureExtensions.md +++ b/.docfx/api/types/Codebelt.Extensions.Xunit.Hosting.AspNetCore.WebMinimalHostFixtureExtensions.md @@ -8,6 +8,7 @@ The following example validates that an `IWebMinimalHostFixture` has a valid ini ```csharp using Codebelt.Extensions.Xunit.Hosting.AspNetCore; +using Xunit; namespace WebFixtureTests; @@ -18,4 +19,20 @@ public class WebMinimalHostStateGuard return fixture.HasValidState(); } } + +public sealed class RunExample +{ + [Fact] + public void ExercisesExample() + { + using var fixture = new ManagedWebMinimalHostFixture(); + Assert.False(new WebMinimalHostStateGuard().EnsureFixtureIsReady(fixture)); + using var app = MinimalWebHostTestFactory.Create(hostFixture: fixture); + Assert.True(new WebMinimalHostStateGuard().EnsureFixtureIsReady(fixture)); + } +} ``` + + + + diff --git a/.docfx/api/types/Codebelt.Extensions.Xunit.Hosting.GenericHostFixtureExtensions.md b/.docfx/api/types/Codebelt.Extensions.Xunit.Hosting.GenericHostFixtureExtensions.md index dac9d14..f70c725 100644 --- a/.docfx/api/types/Codebelt.Extensions.Xunit.Hosting.GenericHostFixtureExtensions.md +++ b/.docfx/api/types/Codebelt.Extensions.Xunit.Hosting.GenericHostFixtureExtensions.md @@ -8,6 +8,7 @@ The following example validates that an `IGenericHostFixture` has been fully con ```csharp using Codebelt.Extensions.Xunit.Hosting; +using Xunit; namespace HostFixtureTests; @@ -18,4 +19,20 @@ public class HostStateGuard return fixture.HasValidState(); } } + +public sealed class RunExample +{ + [Fact] + public void ExercisesExample() + { + using var fixture = new ManagedHostFixture(); + Assert.False(new HostStateGuard().EnsureFixtureIsReady(fixture)); + using var app = HostTestFactory.Create(hostFixture: fixture); + Assert.True(new HostStateGuard().EnsureFixtureIsReady(fixture)); + } +} ``` + + + + diff --git a/.docfx/api/types/Codebelt.Extensions.Xunit.Hosting.HostTestFactory.md b/.docfx/api/types/Codebelt.Extensions.Xunit.Hosting.HostTestFactory.md index 49e4c6a..4d40eab 100644 --- a/.docfx/api/types/Codebelt.Extensions.Xunit.Hosting.HostTestFactory.md +++ b/.docfx/api/types/Codebelt.Extensions.Xunit.Hosting.HostTestFactory.md @@ -9,6 +9,7 @@ Use `HostTestFactory` when the test owns the Generic Host setup instead of loadi ```csharp using Codebelt.Extensions.Xunit.Hosting; using Microsoft.Extensions.DependencyInjection; +using Xunit; namespace WorkerServices.Tests; @@ -25,4 +26,17 @@ public sealed class HostTestFactoryExample } public sealed record WorkerStatus(string Value); + +public sealed class RunExample +{ + [Fact] + public void ExercisesExample() + { + Assert.Equal("ready", new HostTestFactoryExample().ResolveWorkerStatus()); + } +} ``` + + + + diff --git a/.docfx/api/types/Codebelt.Extensions.Xunit.Hosting.LoggerExtensions.md b/.docfx/api/types/Codebelt.Extensions.Xunit.Hosting.LoggerExtensions.md index 3a60966..99cdd1e 100644 --- a/.docfx/api/types/Codebelt.Extensions.Xunit.Hosting.LoggerExtensions.md +++ b/.docfx/api/types/Codebelt.Extensions.Xunit.Hosting.LoggerExtensions.md @@ -9,7 +9,9 @@ The following example retrieves the captured log entries from an `ILogger` af ```csharp using Codebelt.Extensions.Xunit; using Codebelt.Extensions.Xunit.Hosting; +using Microsoft.Extensions.DependencyInjection; using Microsoft.Extensions.Logging; +using Xunit; namespace HostFixtureTests; @@ -25,4 +27,24 @@ public class LogInspector return logger.GetTestStore(); } } + +public sealed class RunExample +{ + [Fact] + public void ExercisesExample() + { + var services = new ServiceCollection(); + services.AddXunitTestLogging(); + using var provider = services.BuildServiceProvider(); + var logger = provider.GetRequiredService>(); + logger.LogWarning("queue ready"); + var inspector = new LogInspector(); + Assert.Contains(inspector.GetEntries((ILogger)logger).Query(), entry => entry.Severity == LogLevel.Warning && entry.Message == "Warning: queue ready"); + Assert.Contains(inspector.GetEntries(logger).Query(), entry => entry.Severity == LogLevel.Warning && entry.Message == "Warning: queue ready"); + } +} ``` + + + + diff --git a/.docfx/api/types/Codebelt.Extensions.Xunit.Hosting.ManagedApplicationFixture%601.md b/.docfx/api/types/Codebelt.Extensions.Xunit.Hosting.ManagedApplicationFixture%601.md index 65cde41..4ec356e 100644 --- a/.docfx/api/types/Codebelt.Extensions.Xunit.Hosting.ManagedApplicationFixture%601.md +++ b/.docfx/api/types/Codebelt.Extensions.Xunit.Hosting.ManagedApplicationFixture%601.md @@ -4,43 +4,166 @@ example: - *content --- -Use `ManagedApplicationFixture` when an xUnit class fixture should exercise the application's real entry point and let that entry point start the host. Derive the test from `ApplicationTest` and pass the fixture to its base constructor so the base class initializes the fixture through `ConfigureHost` before the test reads `Host`. Fixture setup remains lazy; accessing the test host starts the deferred host and surfaces startup failures at the point the test consumes it. `ApplicationTestFactory` uses this fixture by default. +Use `ManagedApplicationFixture` when an xUnit test should run the application's real entry point and inspect services registered by that application. `TEntryPoint` identifies the executable application assembly; keep its `Program` and startup registrations in the application project, separate from the xUnit runner assembly. Derive the test from `ApplicationTest` and inject the fixture so the base class initializes it before the test accesses `Host`. + +The maintained worker test below resolves a marker registered by the worker's real `Program` and checks the marker value, Development environment, and host lifetime service. Its test project references the worker application as a separate executable project, preserving the assembly identity required by `ManagedApplicationFixture`. ```csharp -using Codebelt.Extensions.Xunit.Hosting; +// docfx-context: test/Codebelt.Extensions.Xunit.Hosting.FunctionalTests/Codebelt.Extensions.Xunit.Hosting.FunctionalTests.csproj +// docfx-source: test/Codebelt.Extensions.Xunit.Hosting.FunctionalTests/BootstrapperMinimalWorkerApplicationTestTest.cs using Microsoft.Extensions.DependencyInjection; using Microsoft.Extensions.Hosting; using Xunit; +using BootstrapperMinimalWorkerMarker = Codebelt.Extensions.Xunit.Hosting.BootstrapperMinimalWorker.App.BootstrapperMinimalWorkerMarker; +using BootstrapperMinimalWorkerProgram = Codebelt.Extensions.Xunit.Hosting.BootstrapperMinimalWorker.App.Program; -namespace InventoryWorker.Tests; +namespace Codebelt.Extensions.Xunit.Hosting; -public sealed class InventoryWorkerTest : ApplicationTest> +public class BootstrapperMinimalWorkerApplicationTestTest : ApplicationTest> { - public InventoryWorkerTest(ManagedApplicationFixture fixture, ITestOutputHelper output) - : base(fixture, output) + public BootstrapperMinimalWorkerApplicationTestTest(ManagedApplicationFixture hostFixture, ITestOutputHelper output) : base(hostFixture, output) { } [Fact] - public void Host_ContainsApplicationService() + public void ShouldBootstrapMinimalWorkerProgram() { - var identity = Host.Services.GetRequiredService(); + var marker = Host.Services.GetRequiredService(); - Assert.Equal("Inventory worker", identity.Name); + Assert.Equal("Bootstrapper Minimal Worker", marker.Value); + Assert.Equal("Development", Environment.EnvironmentName); + Assert.NotNull(Host.Services.GetRequiredService()); } } +``` -public sealed record WorkerIdentity(string Name); + +
View Native Script · View Docker Script

Runs the pinned repository test Codebelt.Extensions.Xunit.Hosting.BootstrapperMinimalWorkerApplicationTestTest.ShouldBootstrapMinimalWorkerProgram.

The scripts run this test in its original application and test projects.

+ -public sealed class WorkerProgram -{ - public static void Main(string[] args) - { - var builder = Host.CreateApplicationBuilder(args); - builder.Services.AddSingleton(new WorkerIdentity("Inventory worker")); +To reproduce this exact test without assembling its multi-project context, run either complete PowerShell 7 option below. Each script downloads the same pinned repository revision and runs the maintained test without creating a substitute application or changing its assertions; the test verifies one passed result and checks the runner report for the exact test name. + +## Native: PowerShell 7 and .NET 11 SDK + +```powershell +#requires -Version 7.0 +& { + $ErrorActionPreference = 'Stop' + $PSNativeCommandUseErrorActionPreference = $false + # Executes trusted repository build tasks and NuGet packages with your permissions. + # Review the pinned source before running; a container is not a security sandbox. + $null = Get-Command dotnet -ErrorAction Stop + $work = Join-Path ([IO.Path]::GetTempPath()) ('dx-' + [guid]::NewGuid().ToString('N').Substring(0, 8)) + $null = New-Item -ItemType Directory -Path $work + try { + $commit = '84b13767cb9484f8f3a36a71875662edfdb3e511' + Invoke-WebRequest "https://codeload.github.com/codebeltnet/xunit/zip/$commit" -OutFile "$work/source.zip" + Expand-Archive -LiteralPath "$work/source.zip" -DestinationPath "$work/extracted" + Move-Item -LiteralPath "$work/extracted/xunit-$commit" -Destination "$work/repo" + $project = 'test/Codebelt.Extensions.Xunit.Hosting.FunctionalTests/Codebelt.Extensions.Xunit.Hosting.FunctionalTests.csproj' + $test = 'Codebelt.Extensions.Xunit.Hosting.BootstrapperMinimalWorkerApplicationTestTest.ShouldBootstrapMinimalWorkerProgram' + Push-Location "$work/repo" + try { + dotnet run --project $project --framework net11.0 -p:SkipSignAssembly=true -- --filter-method $test --report-xunit-xml --report-xunit-xml-filename result.xml --results-directory "$work/results" 2>&1 | Tee-Object -FilePath "$work/run.log" + } + finally { Pop-Location } + $code = $LASTEXITCODE + if ($code -ne 0) { throw "Repository test failed with exit code $code. See $work/run.log" } + # Require exactly the original test, executed and passing, with no runner errors. + [xml] $report = Get-Content -LiteralPath "$work/results/result.xml" -Raw + $tests = @($report.SelectNodes('/assemblies/assembly/collection/test')) + $assemblies = @($report.SelectNodes('/assemblies/assembly')) + if ($assemblies.Count -ne 1 -or $assemblies[0].total -ne '1' -or $assemblies[0].passed -ne '1' -or + $assemblies[0].errors -ne '0' -or $tests.Count -ne 1 -or $tests[0].name -cne $test -or $tests[0].result -cne 'Pass') { + throw "Expected exactly one passing $test; inspect $work/results/result.xml" + } + Write-Host "Verified: $test (1 executed, 1 passed)." + } + catch { + # Preserve diagnostics outside the repository even though downloaded source is cleaned. + $diagnostics = "$work-diagnostics" + $null = New-Item -ItemType Directory -Path $diagnostics -Force + foreach ($name in @('run.log', 'results')) { + if (Test-Path -LiteralPath "$work/$name") { Copy-Item -LiteralPath "$work/$name" -Destination $diagnostics -Recurse } + } + Write-Warning "Execution not verified. Diagnostics: $diagnostics" + throw + } + finally { + $resolved = [IO.Path]::GetFullPath($work) + $temp = [IO.Path]::GetFullPath([IO.Path]::GetTempPath()).TrimEnd('/','\') + [IO.Path]::DirectorySeparatorChar + if (-not $resolved.StartsWith($temp, [StringComparison]::OrdinalIgnoreCase)) { throw 'Unsafe cleanup path.' } + Remove-Item -LiteralPath $resolved -Recurse -Force + } +} +``` + +## Docker: PowerShell 7 and Docker with Linux containers - using var host = builder.Build(); - host.Run(); +No host .NET SDK is required. The official SDK image supplies it; first use pulls the image. The `11.0` image tag can move as Microsoft publishes SDK updates. On Linux, the container runs with the host UID and GID so build and test outputs remain removable during cleanup. Its home and .NET CLI state use container-local `/tmp`, which is writable by that identity. + +```powershell +#requires -Version 7.0 +& { + $ErrorActionPreference = 'Stop' + $PSNativeCommandUseErrorActionPreference = $false + # Executes trusted repository build tasks and NuGet packages with your permissions. + # Review the pinned source before running; a container is not a security sandbox. + $null = Get-Command docker -ErrorAction Stop + docker info *> $null + if ($LASTEXITCODE -ne 0) { throw 'Docker daemon unavailable.' } + $work = Join-Path ([IO.Path]::GetTempPath()) ('dx-' + [guid]::NewGuid().ToString('N').Substring(0, 8)) + $null = New-Item -ItemType Directory -Path $work + try { + $commit = '84b13767cb9484f8f3a36a71875662edfdb3e511' + Invoke-WebRequest "https://codeload.github.com/codebeltnet/xunit/zip/$commit" -OutFile "$work/source.zip" + Expand-Archive -LiteralPath "$work/source.zip" -DestinationPath "$work/extracted" + Move-Item -LiteralPath "$work/extracted/xunit-$commit" -Destination "$work/repo" + $project = 'test/Codebelt.Extensions.Xunit.Hosting.FunctionalTests/Codebelt.Extensions.Xunit.Hosting.FunctionalTests.csproj' + $test = 'Codebelt.Extensions.Xunit.Hosting.BootstrapperMinimalWorkerApplicationTestTest.ShouldBootstrapMinimalWorkerProgram' + $dockerUser = @() + if ($IsLinux) { + # Keep bind-mounted build output removable by the host user. + $hostUid = id -u + if ($LASTEXITCODE -ne 0) { throw 'Cannot resolve host UID.' } + $hostGid = id -g + if ($LASTEXITCODE -ne 0) { throw 'Cannot resolve host GID.' } + $dockerUser = @('--user', "${hostUid}:${hostGid}") + } + docker run --rm @dockerUser --env HOME=/tmp --env DOTNET_CLI_HOME=/tmp --mount "type=bind,source=$work,target=/work" --workdir /work/repo mcr.microsoft.com/dotnet/sdk:11.0 dotnet run --project $project --framework net11.0 -p:SkipSignAssembly=true -- --filter-method $test --report-xunit-xml --report-xunit-xml-filename result.xml --results-directory /work/results 2>&1 | Tee-Object -FilePath "$work/run.log" + $code = $LASTEXITCODE + if ($code -ne 0) { throw "Repository test failed with exit code $code. See $work/run.log" } + # Require exactly the original test, executed and passing, with no runner errors. + [xml] $report = Get-Content -LiteralPath "$work/results/result.xml" -Raw + $tests = @($report.SelectNodes('/assemblies/assembly/collection/test')) + $assemblies = @($report.SelectNodes('/assemblies/assembly')) + if ($assemblies.Count -ne 1 -or $assemblies[0].total -ne '1' -or $assemblies[0].passed -ne '1' -or + $assemblies[0].errors -ne '0' -or $tests.Count -ne 1 -or $tests[0].name -cne $test -or $tests[0].result -cne 'Pass') { + throw "Expected exactly one passing $test; inspect $work/results/result.xml" + } + Write-Host "Verified: $test (1 executed, 1 passed)." + } + catch { + # Preserve diagnostics outside the repository even though downloaded source is cleaned. + $diagnostics = "$work-diagnostics" + $null = New-Item -ItemType Directory -Path $diagnostics -Force + foreach ($name in @('run.log', 'results')) { + if (Test-Path -LiteralPath "$work/$name") { Copy-Item -LiteralPath "$work/$name" -Destination $diagnostics -Recurse } + } + Write-Warning "Execution not verified. Diagnostics: $diagnostics" + throw + } + finally { + $resolved = [IO.Path]::GetFullPath($work) + $temp = [IO.Path]::GetFullPath([IO.Path]::GetTempPath()).TrimEnd('/','\') + [IO.Path]::DirectorySeparatorChar + if (-not $resolved.StartsWith($temp, [StringComparison]::OrdinalIgnoreCase)) { throw 'Unsafe cleanup path.' } + Remove-Item -LiteralPath $resolved -Recurse -Force } } ``` + +## Further exploration + +The [pinned worker entry point](https://github.com/codebeltnet/xunit/blob/84b13767cb9484f8f3a36a71875662edfdb3e511/app/Codebelt.Extensions.Xunit.Hosting.BootstrapperMinimalWorker.App/Program.cs) constructs the host, registers the marker and hosted service, and runs the application. The [functional test source](https://github.com/codebeltnet/xunit/blob/84b13767cb9484f8f3a36a71875662edfdb3e511/test/Codebelt.Extensions.Xunit.Hosting.FunctionalTests/BootstrapperMinimalWorkerApplicationTestTest.cs) shows the same fixture usage in its maintained class, while the [test project](https://github.com/codebeltnet/xunit/blob/84b13767cb9484f8f3a36a71875662edfdb3e511/test/Codebelt.Extensions.Xunit.Hosting.FunctionalTests/Codebelt.Extensions.Xunit.Hosting.FunctionalTests.csproj) records its separate application and library references and target frameworks. The [fixture implementation](https://github.com/codebeltnet/xunit/blob/84b13767cb9484f8f3a36a71875662edfdb3e511/src/Codebelt.Extensions.Xunit.Hosting/ManagedApplicationFixture.cs) shows how it selects the entry-point assembly and connects deferred host startup. + +The Native execution block was verified on Windows x64 with .NET SDK 11.0.100 and runtime 11.0.0; it reported the named test passing. The Docker block's most recent end-to-end attempt observed the test pass but the container exited with code 137, so Docker execution remains unverified. diff --git a/.docfx/api/types/Codebelt.Extensions.Xunit.Hosting.ManagedHostFixture.md b/.docfx/api/types/Codebelt.Extensions.Xunit.Hosting.ManagedHostFixture.md index 4514482..76e8910 100644 --- a/.docfx/api/types/Codebelt.Extensions.Xunit.Hosting.ManagedHostFixture.md +++ b/.docfx/api/types/Codebelt.Extensions.Xunit.Hosting.ManagedHostFixture.md @@ -46,3 +46,7 @@ public class TestWorker : BackgroundService } } ``` + + + + diff --git a/.docfx/api/types/Codebelt.Extensions.Xunit.Hosting.ManagedMinimalHostFixture.md b/.docfx/api/types/Codebelt.Extensions.Xunit.Hosting.ManagedMinimalHostFixture.md index 30d5973..9f487f6 100644 --- a/.docfx/api/types/Codebelt.Extensions.Xunit.Hosting.ManagedMinimalHostFixture.md +++ b/.docfx/api/types/Codebelt.Extensions.Xunit.Hosting.ManagedMinimalHostFixture.md @@ -35,3 +35,7 @@ public class MinimalWorkerTest : MinimalHostTest public class MetricsTracker; ``` + + + + diff --git a/.docfx/api/types/Codebelt.Extensions.Xunit.Hosting.MinimalHostFixtureExtensions.md b/.docfx/api/types/Codebelt.Extensions.Xunit.Hosting.MinimalHostFixtureExtensions.md index 08d69f2..35c967a 100644 --- a/.docfx/api/types/Codebelt.Extensions.Xunit.Hosting.MinimalHostFixtureExtensions.md +++ b/.docfx/api/types/Codebelt.Extensions.Xunit.Hosting.MinimalHostFixtureExtensions.md @@ -8,6 +8,7 @@ The following example validates that an `IMinimalHostFixture` has been fully ini ```csharp using Codebelt.Extensions.Xunit.Hosting; +using Xunit; namespace HostFixtureTests; @@ -18,4 +19,20 @@ public class HostStateGuard return fixture.HasValidState(); } } + +public sealed class RunExample +{ + [Fact] + public void ExercisesExample() + { + using var fixture = new ManagedMinimalHostFixture(); + Assert.False(new HostStateGuard().EnsureFixtureIsReady(fixture)); + using var app = MinimalHostTestFactory.Create(hostFixture: fixture); + Assert.True(new HostStateGuard().EnsureFixtureIsReady(fixture)); + } +} ``` + + + + diff --git a/.docfx/api/types/Codebelt.Extensions.Xunit.Hosting.MinimalHostTestFactory.md b/.docfx/api/types/Codebelt.Extensions.Xunit.Hosting.MinimalHostTestFactory.md index f4c5342..adef8ca 100644 --- a/.docfx/api/types/Codebelt.Extensions.Xunit.Hosting.MinimalHostTestFactory.md +++ b/.docfx/api/types/Codebelt.Extensions.Xunit.Hosting.MinimalHostTestFactory.md @@ -23,4 +23,16 @@ public class MinimalHostFactoryExample Console.WriteLine(version); } } + +internal static class RunExample +{ + static void Main() + { + new MinimalHostFactoryExample().Demonstrate(); + } +} ``` + + + + diff --git a/.docfx/api/types/Codebelt.Extensions.Xunit.Hosting.SelfManagedHostFixture.md b/.docfx/api/types/Codebelt.Extensions.Xunit.Hosting.SelfManagedHostFixture.md index 40197bf..95f3947 100644 --- a/.docfx/api/types/Codebelt.Extensions.Xunit.Hosting.SelfManagedHostFixture.md +++ b/.docfx/api/types/Codebelt.Extensions.Xunit.Hosting.SelfManagedHostFixture.md @@ -31,4 +31,17 @@ public sealed class SelfManagedHostFixtureExample Assert.True(started); } } + +public sealed class RunExample +{ + [Fact] + public async Task ExercisesExample() + { + await new SelfManagedHostFixtureExample().StartAfterAttachingObserverAsync(); + } +} ``` + + + + diff --git a/.docfx/api/types/Codebelt.Extensions.Xunit.Hosting.SelfManagedMinimalHostFixture.md b/.docfx/api/types/Codebelt.Extensions.Xunit.Hosting.SelfManagedMinimalHostFixture.md index 322d457..e61a42d 100644 --- a/.docfx/api/types/Codebelt.Extensions.Xunit.Hosting.SelfManagedMinimalHostFixture.md +++ b/.docfx/api/types/Codebelt.Extensions.Xunit.Hosting.SelfManagedMinimalHostFixture.md @@ -33,4 +33,17 @@ public sealed class SelfManagedMinimalHostFixtureExample } public sealed record StartupState(string Value); + +public sealed class RunExample +{ + [Fact] + public async Task ExercisesExample() + { + await new SelfManagedMinimalHostFixtureExample().ConfigureBeforeStartingAsync(); + } +} ``` + + + + diff --git a/.docfx/api/types/Codebelt.Extensions.Xunit.Hosting.ServiceCollectionExtensions.md b/.docfx/api/types/Codebelt.Extensions.Xunit.Hosting.ServiceCollectionExtensions.md index 1709956..85382c4 100644 --- a/.docfx/api/types/Codebelt.Extensions.Xunit.Hosting.ServiceCollectionExtensions.md +++ b/.docfx/api/types/Codebelt.Extensions.Xunit.Hosting.ServiceCollectionExtensions.md @@ -10,6 +10,7 @@ The following example registers xUnit test logging and output helper services on using Codebelt.Extensions.Xunit.Hosting; using Microsoft.Extensions.DependencyInjection; using Microsoft.Extensions.Logging; +using Xunit; namespace HostFixtureTests; @@ -22,4 +23,21 @@ public class ExampleFixture return services; } } + +public sealed class RunExample +{ + [Fact] + public void ExercisesExample() + { + using var provider = new ExampleFixture().ConfigureServices(new ServiceCollection()).BuildServiceProvider(); + Assert.IsType(provider.GetRequiredService()); + var logger = provider.GetRequiredService>(); + logger.LogInformation("storage ready"); + Assert.Contains(logger.GetTestStore().Query(), entry => entry.Severity == LogLevel.Information && entry.Message == "Information: storage ready"); + } +} ``` + + + + diff --git a/.docfx/api/types/Codebelt.Extensions.Xunit.Hosting.ServiceProviderExtensions.md b/.docfx/api/types/Codebelt.Extensions.Xunit.Hosting.ServiceProviderExtensions.md index cc71f59..f2bd847 100644 --- a/.docfx/api/types/Codebelt.Extensions.Xunit.Hosting.ServiceProviderExtensions.md +++ b/.docfx/api/types/Codebelt.Extensions.Xunit.Hosting.ServiceProviderExtensions.md @@ -10,6 +10,7 @@ The following example retrieves a scoped service of type `T` from an `IServicePr using System; using Codebelt.Extensions.Xunit.Hosting; using Microsoft.Extensions.DependencyInjection; +using Xunit; namespace HostFixtureTests; @@ -20,4 +21,23 @@ public class ServiceResolver return provider.GetRequiredScopedService(); } } + +public sealed class RunExample +{ + [Fact] + public void ExercisesExample() + { + var services = new ServiceCollection(); + services.AddScoped(_ => new object()); + using var provider = services.BuildServiceProvider(new ServiceProviderOptions + { + ValidateScopes = true + }); + Assert.NotSame(new ServiceResolver().Resolve(provider), new ServiceResolver().Resolve(provider)); + } +} ``` + + + + diff --git a/.docfx/api/types/Codebelt.Extensions.Xunit.Hosting.XunitTestLoggerEntry.md b/.docfx/api/types/Codebelt.Extensions.Xunit.Hosting.XunitTestLoggerEntry.md index c9ed9d9..9e1721b 100644 --- a/.docfx/api/types/Codebelt.Extensions.Xunit.Hosting.XunitTestLoggerEntry.md +++ b/.docfx/api/types/Codebelt.Extensions.Xunit.Hosting.XunitTestLoggerEntry.md @@ -9,6 +9,7 @@ The following example creates an `XunitTestLoggerEntry` record and formats its m ```csharp using Codebelt.Extensions.Xunit.Hosting; using Microsoft.Extensions.Logging; +using Xunit; namespace HostFixtureTests; @@ -20,4 +21,17 @@ public class LogEntryExample return entry.ToString(); } } + +public sealed class RunExample +{ + [Fact] + public void ExercisesExample() + { + Assert.Equal("Something unexpected happened.", new LogEntryExample().FormatEntry()); + } +} ``` + + + + diff --git a/.docfx/api/types/Codebelt.Extensions.Xunit.InMemoryTestStore%601.md b/.docfx/api/types/Codebelt.Extensions.Xunit.InMemoryTestStore%601.md index 0f0a81d..bb877f0 100644 --- a/.docfx/api/types/Codebelt.Extensions.Xunit.InMemoryTestStore%601.md +++ b/.docfx/api/types/Codebelt.Extensions.Xunit.InMemoryTestStore%601.md @@ -9,6 +9,7 @@ Use the store to retain test data and query the matching items without a databas ```csharp using System.Linq; using Codebelt.Extensions.Xunit; +using Xunit; namespace Example.Tests; @@ -22,6 +23,19 @@ public class StoreExample return store.Count == 2 && store.Query(value => value == "cached").Single() == "cached"; } } + +public sealed class RunExample +{ + [Fact] + public void ExercisesExample() + { + Assert.True(new StoreExample().HasMatchingItem()); + } +} ``` + + + + [!INCLUDE [availability-default](../../includes/availability-default.md)] diff --git a/.docfx/api/types/Codebelt.Extensions.Xunit.PriorityAttribute.md b/.docfx/api/types/Codebelt.Extensions.Xunit.PriorityAttribute.md index 80c30a3..11044a2 100644 --- a/.docfx/api/types/Codebelt.Extensions.Xunit.PriorityAttribute.md +++ b/.docfx/api/types/Codebelt.Extensions.Xunit.PriorityAttribute.md @@ -35,4 +35,8 @@ public class InitializationTest : Test } ``` + + + + [!INCLUDE [availability-default](../../includes/availability-default.md)] diff --git a/.docfx/api/types/Codebelt.Extensions.Xunit.PriorityTestMethodOrderer.md b/.docfx/api/types/Codebelt.Extensions.Xunit.PriorityTestMethodOrderer.md index 126ec45..bf4b088 100644 --- a/.docfx/api/types/Codebelt.Extensions.Xunit.PriorityTestMethodOrderer.md +++ b/.docfx/api/types/Codebelt.Extensions.Xunit.PriorityTestMethodOrderer.md @@ -37,4 +37,8 @@ public class CacheLifecycleTest : Test } ``` + + + + [!INCLUDE [availability-default](../../includes/availability-default.md)] diff --git a/.docfx/api/types/Codebelt.Extensions.Xunit.TestOutputHelperAccessor.md b/.docfx/api/types/Codebelt.Extensions.Xunit.TestOutputHelperAccessor.md index 9c9bd7b..41e5bc6 100644 --- a/.docfx/api/types/Codebelt.Extensions.Xunit.TestOutputHelperAccessor.md +++ b/.docfx/api/types/Codebelt.Extensions.Xunit.TestOutputHelperAccessor.md @@ -25,4 +25,8 @@ public class OutputAccessorTest : Test } ``` + + + + [!INCLUDE [availability-default](../../includes/availability-default.md)] diff --git a/.docfx/api/types/Codebelt.Extensions.Xunit.TestOutputHelperExtensions.md b/.docfx/api/types/Codebelt.Extensions.Xunit.TestOutputHelperExtensions.md index 6f51f22..345ea72 100644 --- a/.docfx/api/types/Codebelt.Extensions.Xunit.TestOutputHelperExtensions.md +++ b/.docfx/api/types/Codebelt.Extensions.Xunit.TestOutputHelperExtensions.md @@ -25,6 +25,10 @@ public class OutputLinesTest : Test } ``` + + + + [!INCLUDE [availability-default](../../includes/availability-default.md)] --- @@ -54,6 +58,10 @@ public class MixedOutputTest : Test } ``` + + + + --- uid: Codebelt.Extensions.Xunit.TestOutputHelperExtensions.WriteLines``1(Xunit.ITestOutputHelper,``0[]) example: @@ -81,6 +89,10 @@ public class ArrayOutputTest : Test } ``` + + + + --- uid: Codebelt.Extensions.Xunit.TestOutputHelperExtensions.WriteLines``1(Xunit.ITestOutputHelper,System.Collections.Generic.IEnumerable{``0}) example: @@ -109,3 +121,7 @@ public class EnumerableOutputTest : Test } } ``` + + + + diff --git a/.docfx/api/types/Codebelt.Extensions.Xunit.WildcardOptions.md b/.docfx/api/types/Codebelt.Extensions.Xunit.WildcardOptions.md index 13d15f5..fee7104 100644 --- a/.docfx/api/types/Codebelt.Extensions.Xunit.WildcardOptions.md +++ b/.docfx/api/types/Codebelt.Extensions.Xunit.WildcardOptions.md @@ -25,4 +25,8 @@ public class WildcardExampleTest : Test } ``` + + + + [!INCLUDE [availability-default](../../includes/availability-default.md)] From 21be5d80dbd33c8212566a7d866175d0613ba431 Mon Sep 17 00:00:00 2001 From: aicia-bot Date: Fri, 20 Nov 2026 03:24:32 +0100 Subject: [PATCH 03/12] =?UTF-8?q?=F0=9F=8E=A8=20remove=20stray=20blank=20l?= =?UTF-8?q?ines=20in=20agents=20docfx=20block?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Removes blank lines inside the managed DocFX guidance block and between its command fences. The block keeps the same wording, so only whitespace changes. --- AGENTS.md | 4 ---- 1 file changed, 4 deletions(-) diff --git a/AGENTS.md b/AGENTS.md index 38aa2d6..4a50ad3 100644 --- a/AGENTS.md +++ b/AGENTS.md @@ -294,7 +294,6 @@ Follow the scoped guidance in this file: - [Writing XML documentation](#writing-xml-documentation) - ## DocFX Documentation Maintenance When changing public .NET APIs, keep the DocFX documentation current in the same change set. @@ -343,9 +342,7 @@ Before completing documentation work, run the relevant verification commands, no ```bash dotnet build - dotnet test - dotnet run --file /scripts/docfx.cs -- --repo-root . --build-api-model --validate-samples --verify-docfx-build ``` @@ -354,7 +351,6 @@ Codebelt repositories are normally strong-name signed with a `.snk` file in the The final DocFX verification must run outside the working tree when possible. The `--verify-docfx-build` option copies the repository to a temp workspace, runs DocFX against the resolved `docfx.json` there, and removes the temp workspace afterward so generated API YAML, manifest files, and site output do not flood git status. Do not call the work complete until the final JSON reports `summary.fullVerificationRan: true`, `summary.canClaimCompletion: true`, `summary.remainingWorkItems: 0`, an empty `summary.remainingGates`, an empty `summary.remainingDiagnosticsByCode`, `summary.newlyIntroducedSkipMarkers: 0`, and `summary.interimArtifacts: 0`. If a command cannot be run, report the exact limitation or failure instead of claiming the documentation was verified. - ## Writing Unit Tests From e561042f836333131a72adf7e1a4341eee2793e2 Mon Sep 17 00:00:00 2001 From: aicia-bot Date: Sat, 21 Nov 2026 00:41:55 +0100 Subject: [PATCH 04/12] =?UTF-8?q?=E2=99=BB=EF=B8=8F=20generate=20run-actio?= =?UTF-8?q?n=20scripts=20from=20manifest?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Run-action scripts were hand-tracked under .docfx/run-actions. The manifest is now the single source of truth and BuildRunActions.ps1 materializes the native and docker scripts from it at docfx build time, so the generated output no longer needs to live in git. BuildDocfxImage.ps1 runs the generator before the image build and cleans the output afterwards. --- .docfx/BuildDocfxImage.ps1 | 12 +- .docfx/BuildRunActions.ps1 | 260 +++++++++ .docfx/run-actions.manifest.json | 876 +++++++++++++++++++++++++++++++ 3 files changed, 1146 insertions(+), 2 deletions(-) create mode 100644 .docfx/BuildRunActions.ps1 create mode 100644 .docfx/run-actions.manifest.json diff --git a/.docfx/BuildDocfxImage.ps1 b/.docfx/BuildDocfxImage.ps1 index 6628a96..d8beea6 100644 --- a/.docfx/BuildDocfxImage.ps1 +++ b/.docfx/BuildDocfxImage.ps1 @@ -1,4 +1,12 @@ $version = minver -i -t v -v w docfx metadata docfx.json -docker buildx build -t xunit-docfx:$version --platform linux/arm64,linux/amd64 --load -f Dockerfile.docfx . -get-childItem -recurse -path api -include *.yml, .manifest | remove-item +& (Join-Path $PSScriptRoot 'BuildRunActions.ps1') +try { + docker buildx build -t xunit-docfx:$version --platform linux/arm64,linux/amd64 --load -f Dockerfile.docfx . +} +finally { + get-childItem -recurse -path api -include *.yml, .manifest | remove-item + if (Test-Path -LiteralPath (Join-Path $PSScriptRoot 'run-actions')) { + Remove-Item -LiteralPath (Join-Path $PSScriptRoot 'run-actions') -Recurse -Force + } +} diff --git a/.docfx/BuildRunActions.ps1 b/.docfx/BuildRunActions.ps1 new file mode 100644 index 0000000..b698540 --- /dev/null +++ b/.docfx/BuildRunActions.ps1 @@ -0,0 +1,260 @@ +#requires -Version 7.0 +[CmdletBinding()] +param( + [string] $ManifestPath = (Join-Path $PSScriptRoot 'run-actions.manifest.json'), + [string] $OutputRoot = (Join-Path $PSScriptRoot 'run-actions') +) +$ErrorActionPreference = 'Stop' +$PSNativeCommandUseErrorActionPreference = $false +Set-StrictMode -Version Latest + +if (-not (Test-Path -LiteralPath $ManifestPath -PathType Leaf)) { + throw "Run-actions manifest not found: $ManifestPath" +} + +$CsrunTestVerificationTemplate = @' +function Assert-CsrunTestOutput([string] $Output) { + $lines = @($Output -split '\r?\n') + $headers = @($lines | Where-Object { $_ -match '^Test run summary: Passed! - .+\)$' }) + if ($headers.Count -ne 1) { throw 'Expected exactly one completed xUnit test summary.' } + $headerIndex = [Array]::IndexOf($lines, $headers[0]) + $summaryLines = @($lines | Select-Object -Skip ($headerIndex + 1) -First 4) + $counts = @{} + foreach ($line in $summaryLines) { + if ($line -match '^\s*(total|failed|succeeded|skipped):\s*(\d+)\s*$') { $counts[$Matches[1]] = [int]$Matches[2] } + } + if ($counts.Count -ne 4) { throw 'The xUnit test summary counts are incomplete or ambiguous.' } + $failed = $counts.failed + $passed = $counts.succeeded + $skipped = $counts.skipped + $total = $counts.total + if ($total -lt 1 -or $passed -lt 1 -or $failed -ne 0 -or $skipped -ne 0 -or $passed -ne $total) { + throw 'Tests must execute at least once, all pass, and none fail or skip.' + } +} +'@ + +function Normalize([string] $Text) { $Text.Replace("`r`n", "`n").TrimEnd("`n", "`r") } +function Quote-Literal([string] $Value) { "'" + $Value.Replace("'", "''") + "'" } + +function Sort-ManifestValue($Value) { + if ($Value -is [System.Collections.IDictionary]) { + $ordered = [ordered]@{} + [string[]] $keys = @($Value.Keys) + [Array]::Sort($keys, [StringComparer]::Ordinal) + foreach ($key in $keys) { $ordered[$key] = Sort-ManifestValue $Value[$key] } + return $ordered + } + if ($Value -is [array]) { return ,@($Value | ForEach-Object { Sort-ManifestValue $_ }) } + return $Value +} + +function New-StandalonePair { + param( + [Parameter(Mandatory)][hashtable] $Manifest, + [Parameter(Mandatory)][string] $Image + ) + $ordered = Sort-ManifestValue $Manifest + $manifestJson = ConvertTo-Json -InputObject $ordered -Depth 100 + $verifyTests = $ordered.mode -eq 'test' + $prefix = "#requires -Version 7.0`n`$ErrorActionPreference = 'Stop'`n`$PSNativeCommandUseErrorActionPreference = `$false`n`$manifest = @'`n" + $manifestJson + "`n'@`n" + $suffix = @' +if ($process.ExitCode -ne 0) { throw "csrun execution failed with exit code $($process.ExitCode). $diagnostics" } +if ($verifyTests) { Assert-CsrunTestOutput $output } +'@ + $engineSetup = @' +# Downloads and executes the latest stable csrun release with your permissions. +# Source and release history: https://github.com/codebeltnet/csrun +$engineDirectory = Join-Path ([IO.Path]::GetTempPath()) ('csrun-' + [guid]::NewGuid().ToString('N')) +$null = New-Item -ItemType Directory -Path $engineDirectory +$enginePath = Join-Path $engineDirectory 'csrun.ps1' +$process = $null +try { + $release = Invoke-RestMethod 'https://api.github.com/repos/codebeltnet/csrun/releases/latest' + $assets = @($release.assets | Where-Object name -CEQ 'csrun.ps1') + if ($assets.Count -ne 1 -or $assets[0].digest -notmatch '^sha256:[0-9a-f]{64}$') { + throw "csrun release $($release.tag_name) must publish one csrun.ps1 asset with a SHA-256 digest." + } + $asset = $assets[0] + Invoke-WebRequest $asset.browser_download_url -OutFile $enginePath + $actualHash = (Get-FileHash -LiteralPath $enginePath -Algorithm SHA256).Hash + if ("sha256:$actualHash" -ne $asset.digest) { throw "csrun asset checksum mismatch: $actualHash" } +'@ + $nativeInvoke = @' +$startInfo = [Diagnostics.ProcessStartInfo]::new('pwsh') +foreach ($argument in @('-NoProfile','-NonInteractive','-File')) { $startInfo.ArgumentList.Add($argument) } +$startInfo.ArgumentList.Add($enginePath) +$startInfo.ArgumentList.Add('-ManifestJson') +$startInfo.ArgumentList.Add($manifest) +$startInfo.RedirectStandardOutput = $true +$startInfo.RedirectStandardError = $true +$startInfo.UseShellExecute = $false +$process = [Diagnostics.Process]::new() +$process.StartInfo = $startInfo +if (-not $process.Start()) { throw 'Could not start csrun.' } +$stdoutTask = $process.StandardOutput.ReadToEndAsync() +$stderrTask = $process.StandardError.ReadToEndAsync() +$process.WaitForExit() +$output = $stdoutTask.GetAwaiter().GetResult() +$diagnostics = $stderrTask.GetAwaiter().GetResult() +Write-Output $output +if ($diagnostics) { [Console]::Error.Write($diagnostics) } +'@ + $dockerInvoke = (@' +$enginePayload = [Convert]::ToBase64String([IO.File]::ReadAllBytes($enginePath)) +$containerInput = $enginePayload + "`n" + $manifest +$command = ' +$ErrorActionPreference = "Stop" +$enginePath = Join-Path ([IO.Path]::GetTempPath()) ("csrun-release-" + [guid]::NewGuid().ToString("N") + ".ps1") +$engineBytes = [Convert]::FromBase64String([Console]::In.ReadLine()) +[IO.File]::WriteAllBytes($enginePath, $engineBytes) +$manifest = [Console]::In.ReadToEnd() +& $enginePath -ManifestJson $manifest +exit $LASTEXITCODE +' +$output = (@($containerInput | & docker run --rm -i --entrypoint pwsh __IMAGE__ -NoProfile -NonInteractive -Command $command) -join [Environment]::NewLine) +$process = [pscustomobject]@{ ExitCode = $LASTEXITCODE } +$diagnostics = '' +Write-Output $output +'@).Replace('__IMAGE__', (Quote-Literal $Image)) + $engineCleanup = @' +} catch { + [Console]::Error.WriteLine("csrun diagnostics retained in: $engineDirectory") + throw +} finally { + $resolvedTemp = [IO.Path]::TrimEndingDirectorySeparator([IO.Path]::GetFullPath([IO.Path]::GetTempPath())) + $resolvedEngineDirectory = [IO.Path]::GetFullPath($engineDirectory) + if ([IO.Path]::GetDirectoryName($resolvedEngineDirectory) -ne $resolvedTemp -or + [IO.Path]::GetFileName($resolvedEngineDirectory) -cnotmatch '^csrun-[a-f0-9]{32}$') { throw 'Unsafe cleanup path.' } + if ($process -and $process.ExitCode -eq 0) { Remove-Item -LiteralPath $resolvedEngineDirectory -Recurse -Force } +} +'@ + $encoding = '$OutputEncoding = [Text.UTF8Encoding]::new($false)' + "`n" + '[Console]::OutputEncoding = $OutputEncoding' + "`n" + $native = "& {`n" + ($prefix + $encoding + '$verifyTests = $' + $verifyTests.ToString().ToLowerInvariant() + "`n" + $CsrunTestVerificationTemplate + "`n" + $engineSetup + "`n" + $nativeInvoke + "`n" + $engineCleanup + "`n" + $suffix).TrimEnd() + "`n}`n" + $docker = "& {`n" + ($prefix + $encoding + '$verifyTests = $' + $verifyTests.ToString().ToLowerInvariant() + "`n" + $CsrunTestVerificationTemplate + "`n" + $engineSetup + "`n" + $dockerInvoke + "`n" + $engineCleanup + "`n" + $suffix).TrimEnd() + "`n}`n" + return @{ native = $native; docker = $docker } +} + +function New-RepositoryPair { + param( + [Parameter(Mandatory)][string] $Repository, + [Parameter(Mandatory)][string] $Commit, + [Parameter(Mandatory)][string] $Project, + [Parameter(Mandatory)][string] $Test, + [Parameter(Mandatory)][string] $Framework, + [Parameter(Mandatory)][string] $Image + ) + if ($Repository -notmatch '^[A-Za-z0-9_.-]+/[A-Za-z0-9_.-]+$' -or $Commit -notmatch '^[a-fA-F0-9]{40}$' -or + $Project -notmatch '^[A-Za-z0-9_./-]+\.csproj$' -or $Project.Split('/') -contains '..' -or $Project.StartsWith('/') -or + $Test -notmatch '^[A-Za-z0-9_.+]+$' -or $Framework -notmatch '^net\d+\.\d+$' -or + $Image -notmatch '^mcr\.microsoft\.com/dotnet/sdk:[A-Za-z0-9_.-]+$') { + throw 'Expected a pinned GitHub repository, relative project, exact xUnit method, TFM and official SDK image.' + } + $template = @' +& { +#requires -Version 7.0 + $ErrorActionPreference = 'Stop' + $PSNativeCommandUseErrorActionPreference = $false + # Executes trusted repository build tasks and NuGet packages with your permissions. + # Review the pinned source before running; a container is not a security sandbox. + __PREREQUISITE__ + $work = Join-Path ([IO.Path]::GetTempPath()) ('dx-' + [guid]::NewGuid().ToString('N').Substring(0, 8)) + $null = New-Item -ItemType Directory -Path $work + try { + $commit = '__COMMIT__' + Invoke-WebRequest "https://codeload.github.com/__REPOSITORY__/zip/$commit" -OutFile "$work/source.zip" + Expand-Archive -LiteralPath "$work/source.zip" -DestinationPath "$work/extracted" + Move-Item -LiteralPath "$work/extracted/__ARCHIVE__-$commit" -Destination "$work/repo" + $project = '__PROJECT__' + $test = '__TEST__' + __EXECUTE__ + $code = $LASTEXITCODE + if ($code -ne 0) { throw "Repository test failed with exit code $code. See $work/run.log" } + # Require exactly the original test, executed and passing, with no runner errors. + [xml] $report = Get-Content -LiteralPath "$work/results/result.xml" -Raw + $tests = @($report.SelectNodes('/assemblies/assembly/collection/test')) + $assemblies = @($report.SelectNodes('/assemblies/assembly')) + if ($assemblies.Count -ne 1 -or $assemblies[0].total -ne '1' -or $assemblies[0].passed -ne '1' -or + $assemblies[0].errors -ne '0' -or $tests.Count -ne 1 -or $tests[0].name -cne $test -or $tests[0].result -cne 'Pass') { + throw "Expected exactly one passing $test; inspect $work/results/result.xml" + } + Write-Host "Verified: $test (1 executed, 1 passed)." + } + catch { + # Preserve diagnostics outside the repository even though downloaded source is cleaned. + $diagnostics = "$work-diagnostics" + $null = New-Item -ItemType Directory -Path $diagnostics -Force + foreach ($name in @('run.log', 'results')) { + if (Test-Path -LiteralPath "$work/$name") { Copy-Item -LiteralPath "$work/$name" -Destination $diagnostics -Recurse } + } + Write-Warning "Execution not verified. Diagnostics: $diagnostics" + throw + } + finally { + $resolved = [IO.Path]::GetFullPath($work) + $temp = [IO.Path]::GetFullPath([IO.Path]::GetTempPath()).TrimEnd('/','\') + [IO.Path]::DirectorySeparatorChar + if (-not $resolved.StartsWith($temp, [StringComparison]::OrdinalIgnoreCase)) { throw 'Unsafe cleanup path.' } + Remove-Item -LiteralPath $resolved -Recurse -Force + } +} +'@ + $native = (@' +Push-Location "$work/repo" + try { + dotnet run --project $project --framework __FRAMEWORK__ -p:SkipSignAssembly=true -- --filter-method $test --report-xunit-xml --report-xunit-xml-filename result.xml --results-directory "$work/results" 2>&1 | Tee-Object -FilePath "$work/run.log" + } + finally { Pop-Location } +'@).Replace('__FRAMEWORK__', $Framework) + $docker = (@' +$dockerUser = @() + if ($IsLinux) { + # Keep bind-mounted build output removable by the host user. + $hostUid = id -u + if ($LASTEXITCODE -ne 0) { throw 'Cannot resolve host UID.' } + $hostGid = id -g + if ($LASTEXITCODE -ne 0) { throw 'Cannot resolve host GID.' } + $dockerUser = @('--user', "${hostUid}:${hostGid}") + } + # Let Docker's init reap orphaned build processes and keep build servers disposable. + docker run --rm --init @dockerUser --env HOME=/tmp --env DOTNET_CLI_HOME=/tmp --env MSBUILDDISABLENODEREUSE=1 --mount "type=bind,source=$work,target=/work" --workdir /work/repo __IMAGE__ dotnet run --disable-build-servers --project $project --framework __FRAMEWORK__ -p:SkipSignAssembly=true -- --filter-method $test --report-xunit-xml --report-xunit-xml-filename result.xml --results-directory /work/results 2>&1 | Tee-Object -FilePath "$work/run.log" +'@).Replace('__FRAMEWORK__', $Framework).Replace('__IMAGE__', $Image) + $template = $template.Replace('__COMMIT__', $Commit).Replace('__REPOSITORY__', $Repository).Replace('__ARCHIVE__', $Repository.Split('/')[1]).Replace('__PROJECT__', $Project).Replace('__TEST__', $Test) + return @{ + native = $template.Replace('__PREREQUISITE__', "`$null = Get-Command dotnet -ErrorAction Stop").Replace('__EXECUTE__', $native) + docker = $template.Replace('__PREREQUISITE__', "`$null = Get-Command docker -ErrorAction Stop`n docker info *> `$null`n if (`$LASTEXITCODE -ne 0) { throw 'Docker daemon unavailable.' }").Replace('__EXECUTE__', $docker) + } +} + +$doc = Get-Content -LiteralPath $ManifestPath -Raw | ConvertFrom-Json -AsHashtable +if ($doc.schemaVersion -ne 1) { throw "Unsupported run-actions manifest schemaVersion: $($doc.schemaVersion)" } +$examples = @($doc.examples) +$utf8NoBom = [Text.UTF8Encoding]::new($false) +$written = 0 + +foreach ($example in $examples) { + $id = [string] $example.id + if ($id -cnotmatch '^[a-f0-9]{24}$') { throw "Invalid run-action id: $id" } + $pair = if ($example.strategy -ceq 'repository') { + New-RepositoryPair -Repository $example.repository -Commit $example.commit -Project $example.project -Test $example.test -Framework $example.framework -Image $example.image + } elseif ($example.strategy -ceq 'standalone') { + New-StandalonePair -Manifest $example.manifest -Image $example.image + } else { + throw "Unsupported run-action strategy '$($example.strategy)' for $id" + } + $dir = Join-Path $OutputRoot $id + foreach ($transport in @($example.transports)) { + if ($transport -notin @('native', 'docker')) { throw "Unsupported transport '$transport' for $id" } + $scriptText = Normalize $pair[$transport] + $tokens = $null; $errors = $null + $null = [Management.Automation.Language.Parser]::ParseInput($scriptText, [ref]$tokens, [ref]$errors) + if ($errors.Count) { throw "Materialized $transport script for $id has syntax errors: $errors" } + $path = Join-Path $dir "$transport.ps1" + if (-not (Test-Path -LiteralPath $path) -or [IO.File]::ReadAllText($path) -cne $scriptText) { + $null = [IO.Directory]::CreateDirectory($dir) + [IO.File]::WriteAllText($path, $scriptText, $utf8NoBom) + } + $written++ + } +} + +Write-Host "Materialized $written run-action script(s) for $($examples.Count) example(s) into $OutputRoot." diff --git a/.docfx/run-actions.manifest.json b/.docfx/run-actions.manifest.json new file mode 100644 index 0000000..d92d62d --- /dev/null +++ b/.docfx/run-actions.manifest.json @@ -0,0 +1,876 @@ +{ + "schemaVersion": 1, + "examples": [ + { + "id": "00acdae546dce87b654496e1", + "strategy": "standalone", + "transports": [ + "native", + "docker" + ], + "image": "codebeltnet/csrun:10", + "manifest": { + "schemaVersion": 1, + "mode": "test", + "framework": "net10.0", + "dependsOn": [ + "Codebelt.Extensions.Xunit.Hosting.AspNetCore@13.0.0", + "Microsoft.Extensions.Hosting@10.0.15", + "xunit.v3@4.0.3" + ], + "frameworkReferences": [ + "Microsoft.AspNetCore.App" + ], + "source": "using System.Threading.Tasks;\nusing Codebelt.Extensions.Xunit.Hosting.AspNetCore;\nusing Microsoft.AspNetCore.Builder;\nusing Microsoft.AspNetCore.Http;\nusing Microsoft.Extensions.DependencyInjection;\nusing Microsoft.Extensions.Hosting;\nusing Xunit;\n\nnamespace WebFixtureTests;\n\npublic class MinimalApiTest : MinimalWebHostTest\n{\n public MinimalApiTest(ManagedWebMinimalHostFixture hostFixture, ITestOutputHelper output) : base(hostFixture, output)\n {\n }\n\n protected override void ConfigureHost(IHostApplicationBuilder hb)\n {\n hb.Services.AddFakeHttpContextAccessor();\n }\n\n public override void ConfigureApplication(IApplicationBuilder app)\n {\n app.UseMiddleware();\n }\n}\n\npublic class TestMiddleware(RequestDelegate next)\n{\n public async Task InvokeAsync(HttpContext context)\n {\n context.Response.Headers[\"X-Test\"] = \"true\";\n await next(context);\n }\n}\n\npublic sealed class RunExample(ManagedWebMinimalHostFixture fixture, ITestOutputHelper output) : MinimalApiTest(fixture, output)\n{\n [Fact]\n public async Task BuildsAndInvokesTheConfiguredPipeline()\n {\n var context = new DefaultHttpContext\n {\n RequestServices = Application.ApplicationServices\n };\n await Application.Build()(context);\n Assert.Equal(\"true\", context.Response.Headers[\"X-Test\"].ToString());\n Assert.NotNull(context.RequestServices.GetRequiredService());\n }\n}" + } + }, + { + "id": "0308118a47b5c02daa7b32be", + "strategy": "standalone", + "transports": [ + "native", + "docker" + ], + "image": "codebeltnet/csrun:10", + "manifest": { + "schemaVersion": 1, + "mode": "test", + "framework": "net10.0", + "dependsOn": [ + "Codebelt.Extensions.Xunit@13.0.0", + "xunit.v3@4.0.3" + ], + "source": "using System.Collections.Generic;\nusing Codebelt.Extensions.Xunit;\nusing Xunit;\n\nnamespace Example.Tests;\n\npublic class EnumerableOutputTest : Test\n{\n public EnumerableOutputTest(ITestOutputHelper output) : base(output) { }\n\n [Fact]\n public void ShouldWriteSequenceItems()\n {\n IEnumerable values = new List { 1, 2, 3 };\n TestOutput.WriteLines(values);\n Assert.True(HasTestOutput);\n }\n}" + } + }, + { + "id": "038a1c806225b412a6f986c1", + "strategy": "standalone", + "transports": [ + "native", + "docker" + ], + "image": "codebeltnet/csrun:10", + "manifest": { + "schemaVersion": 1, + "mode": "test", + "framework": "net10.0", + "dependsOn": [ + "Codebelt.Extensions.Xunit@13.0.0", + "xunit.v3@4.0.3" + ], + "source": "using Codebelt.Extensions.Xunit;\nusing Xunit;\n\nnamespace Example.Tests;\n\npublic class WildcardExampleTest : Test\n{\n public WildcardExampleTest(ITestOutputHelper output) : base(output) { }\n\n [Fact]\n public void ShouldMatchConfiguredPattern()\n {\n var options = new WildcardOptions { ThrowOnNoMatch = true };\n Assert.True(Match(\"cache*\", \"cached\", setup => setup.ThrowOnNoMatch = options.ThrowOnNoMatch));\n }\n}" + } + }, + { + "id": "08b911ef79f0b743282e37c9", + "strategy": "standalone", + "transports": [ + "native", + "docker" + ], + "image": "codebeltnet/csrun:10", + "manifest": { + "schemaVersion": 1, + "mode": "console", + "framework": "net10.0", + "dependsOn": [ + "Codebelt.Extensions.Xunit.Hosting.AspNetCore@13.0.0" + ], + "frameworkReferences": [ + "Microsoft.AspNetCore.App" + ], + "sdk": "Microsoft.NET.Sdk.Web", + "source": "using System;\nusing Codebelt.Extensions.Xunit.Hosting.AspNetCore.Http.Features;\n\nnamespace WebFixtureTests;\n\npublic class ResponseFeatureExample\n{\n public void Demonstrate()\n {\n var response = new FakeHttpResponseFeature();\n Console.WriteLine(response.StatusCode);\n }\n}\n\ninternal static class RunExample\n{\n static void Main()\n {\n new ResponseFeatureExample().Demonstrate();\n }\n}" + } + }, + { + "id": "10457ac34cce1cbadb26aee1", + "strategy": "standalone", + "transports": [ + "native", + "docker" + ], + "image": "codebeltnet/csrun:10", + "manifest": { + "schemaVersion": 1, + "mode": "test", + "framework": "net10.0", + "dependsOn": [ + "Codebelt.Extensions.Xunit@13.0.0", + "xunit.v3@4.0.3" + ], + "source": "using Codebelt.Extensions.Xunit;\nusing Xunit;\n\nnamespace Example.Tests;\n\npublic class ArrayOutputTest : Test\n{\n public ArrayOutputTest(ITestOutputHelper output) : base(output) { }\n\n [Fact]\n public void ShouldWriteArrayItems()\n {\n TestOutput.WriteLines(new int[] { 1, 2, 3 });\n Assert.True(HasTestOutput);\n }\n}" + } + }, + { + "id": "1130af506703020850fdadea", + "strategy": "standalone", + "transports": [ + "native", + "docker" + ], + "image": "codebeltnet/csrun:10", + "manifest": { + "schemaVersion": 1, + "mode": "test", + "framework": "net10.0", + "dependsOn": [ + "Codebelt.Extensions.Xunit.Hosting@13.0.0", + "Microsoft.Extensions.Hosting@10.0.15", + "xunit.v3@4.0.3" + ], + "source": "using Codebelt.Extensions.Xunit.Hosting;\nusing Xunit;\n\nnamespace HostFixtureTests;\n\npublic class HostStateGuard\n{\n public bool EnsureFixtureIsReady(IGenericHostFixture fixture)\n {\n return fixture.HasValidState();\n }\n}\n\npublic sealed class RunExample\n{\n [Fact]\n public void ExercisesExample()\n {\n using var fixture = new ManagedHostFixture();\n Assert.False(new HostStateGuard().EnsureFixtureIsReady(fixture));\n using var app = HostTestFactory.Create(hostFixture: fixture);\n Assert.True(new HostStateGuard().EnsureFixtureIsReady(fixture));\n }\n}" + } + }, + { + "id": "18b0746bf3da1d84f81b5274", + "strategy": "standalone", + "transports": [ + "native", + "docker" + ], + "image": "codebeltnet/csrun:10", + "manifest": { + "schemaVersion": 1, + "mode": "test", + "framework": "net10.0", + "dependsOn": [ + "Codebelt.Extensions.Xunit.Hosting@13.0.0", + "Microsoft.Extensions.Hosting@10.0.15", + "xunit.v3@4.0.3" + ], + "source": "using Codebelt.Extensions.Xunit.Hosting;\nusing Microsoft.Extensions.DependencyInjection;\nusing Microsoft.Extensions.Logging;\nusing Xunit;\n\nnamespace HostFixtureTests;\n\npublic class ExampleFixture\n{\n public IServiceCollection ConfigureServices(IServiceCollection services)\n {\n services.AddXunitTestLogging(LogLevel.Information);\n services.AddXunitTestLoggingOutputHelperAccessor();\n return services;\n }\n}\n\npublic sealed class RunExample\n{\n [Fact]\n public void ExercisesExample()\n {\n using var provider = new ExampleFixture().ConfigureServices(new ServiceCollection()).BuildServiceProvider();\n Assert.IsType(provider.GetRequiredService());\n var logger = provider.GetRequiredService>();\n logger.LogInformation(\"storage ready\");\n Assert.Contains(logger.GetTestStore().Query(), entry => entry.Severity == LogLevel.Information && entry.Message == \"Information: storage ready\");\n }\n}" + } + }, + { + "id": "1e869fe39c4833386733c21f", + "strategy": "standalone", + "transports": [ + "native", + "docker" + ], + "image": "codebeltnet/csrun:10", + "manifest": { + "schemaVersion": 1, + "mode": "test", + "framework": "net10.0", + "dependsOn": [ + "Codebelt.Extensions.Xunit.Hosting.AspNetCore@13.0.0", + "Microsoft.Extensions.Hosting@10.0.15", + "xunit.v3@4.0.3" + ], + "frameworkReferences": [ + "Microsoft.AspNetCore.App" + ], + "source": "using System.Threading.Tasks;\nusing Codebelt.Extensions.Xunit.Hosting.AspNetCore;\nusing Microsoft.AspNetCore.Builder;\nusing Microsoft.AspNetCore.Http;\nusing Microsoft.Extensions.DependencyInjection;\nusing Xunit;\n\nnamespace HealthEndpoint.Tests;\n\npublic sealed class MinimalWebHostTestFactoryExample\n{\n public async Task ReadHealthStateAsync()\n {\n using var response = await MinimalWebHostTestFactory.RunAsync(\n services => services.AddSingleton(new HealthState(\"healthy\")),\n app => app.Run(context =>\n {\n var health = context.RequestServices.GetRequiredService();\n return context.Response.WriteAsync(health.Value);\n })).ConfigureAwait(false);\n\n return await response.Content.ReadAsStringAsync().ConfigureAwait(false);\n }\n}\n\npublic sealed record HealthState(string Value);\n\npublic sealed class RunExample\n{\n [Fact]\n public async Task ExercisesExample()\n {\n Assert.Equal(\"healthy\", await new MinimalWebHostTestFactoryExample().ReadHealthStateAsync());\n }\n}" + } + }, + { + "id": "1ec9196292addaca42a7eef1", + "strategy": "repository", + "transports": [ + "native", + "docker" + ], + "repository": "codebeltnet/xunit", + "commit": "84b13767cb9484f8f3a36a71875662edfdb3e511", + "project": "test/Codebelt.Extensions.Xunit.Hosting.FunctionalTests/Codebelt.Extensions.Xunit.Hosting.FunctionalTests.csproj", + "test": "Codebelt.Extensions.Xunit.Hosting.BootstrapperMinimalWorkerApplicationTestTest.ShouldBootstrapMinimalWorkerProgram", + "framework": "net11.0", + "image": "mcr.microsoft.com/dotnet/sdk:11.0" + }, + { + "id": "21b422ce67f920d801901db0", + "strategy": "standalone", + "transports": [ + "native", + "docker" + ], + "image": "codebeltnet/csrun:10", + "manifest": { + "schemaVersion": 1, + "mode": "test", + "framework": "net10.0", + "dependsOn": [ + "Codebelt.Extensions.Xunit.Hosting.AspNetCore@13.0.0", + "Microsoft.Extensions.Hosting@10.0.15", + "xunit.v3@4.0.3" + ], + "frameworkReferences": [ + "Microsoft.AspNetCore.App" + ], + "source": "using Codebelt.Extensions.Xunit.Hosting.AspNetCore;\nusing Microsoft.Extensions.DependencyInjection;\nusing Microsoft.Extensions.Hosting;\nusing Xunit;\n\nnamespace WebFixtureTests;\n\npublic class WebHostIntegrationTest\n{\n [Fact]\n public void HostShouldBeStarted()\n {\n using var fixture = new BlockingManagedWebHostFixture();\n using var app = WebHostTestFactory.Create(hostFixture: fixture);\n\n Assert.True(fixture.HasValidState());\n var lifetime = app.Host.Services.GetRequiredService();\n Assert.True(lifetime.ApplicationStarted.IsCancellationRequested);\n }\n}" + } + }, + { + "id": "38b60f4b4c1a588bbefe92f1", + "strategy": "repository", + "transports": [ + "native", + "docker" + ], + "repository": "codebeltnet/xunit", + "commit": "84b13767cb9484f8f3a36a71875662edfdb3e511", + "project": "test/Codebelt.Extensions.Xunit.Hosting.AspNetCore.FunctionalTests/Codebelt.Extensions.Xunit.Hosting.AspNetCore.FunctionalTests.csproj", + "test": "Codebelt.Extensions.Xunit.Hosting.AspNetCore.WebApplicationTestFactoryTest.Create_ShouldApplyWebHostConfiguration_WhenWebHostSetupIsProvided", + "framework": "net11.0", + "image": "mcr.microsoft.com/dotnet/sdk:11.0" + }, + { + "id": "3a1dbfc0e010519636b7091e", + "strategy": "standalone", + "transports": [ + "native", + "docker" + ], + "image": "codebeltnet/csrun:10", + "manifest": { + "schemaVersion": 1, + "mode": "console", + "framework": "net10.0", + "dependsOn": [ + "Codebelt.Extensions.Xunit.Hosting.AspNetCore@13.0.0" + ], + "frameworkReferences": [ + "Microsoft.AspNetCore.App" + ], + "sdk": "Microsoft.NET.Sdk.Web", + "source": "using System;\nusing Codebelt.Extensions.Xunit.Hosting.AspNetCore.Http;\n\nnamespace WebFixtureTests;\n\npublic class HttpContextExample\n{\n public void Demonstrate()\n {\n var accessor = new FakeHttpContextAccessor();\n Console.WriteLine(accessor.HttpContext.Request.Method);\n }\n}\n\ninternal static class RunExample\n{\n static void Main()\n {\n new HttpContextExample().Demonstrate();\n }\n}" + } + }, + { + "id": "3c3b98167b30d6985017ec27", + "strategy": "standalone", + "transports": [ + "native", + "docker" + ], + "image": "codebeltnet/csrun:10", + "manifest": { + "schemaVersion": 1, + "mode": "test", + "framework": "net10.0", + "dependsOn": [ + "Codebelt.Extensions.Xunit.Hosting.AspNetCore@13.0.0", + "Microsoft.Extensions.Hosting@10.0.15", + "Microsoft.AspNetCore.TestHost@10.0.15", + "xunit.v3@4.0.3" + ], + "frameworkReferences": [ + "Microsoft.AspNetCore.App" + ], + "source": "using System.Threading.Tasks;\nusing Codebelt.Extensions.Xunit.Hosting.AspNetCore;\nusing Microsoft.AspNetCore.Builder;\nusing Microsoft.AspNetCore.Http;\nusing Microsoft.AspNetCore.TestHost;\nusing Microsoft.Extensions.DependencyInjection;\nusing Microsoft.Extensions.Hosting;\nusing Xunit;\n\nnamespace DeferredHealthEndpoint.Tests;\n\npublic sealed class SelfManagedWebMinimalHostFixtureExample\n{\n public async Task StartHealthEndpointWhenReadyAsync()\n {\n using var host = MinimalWebHostTestFactory.Create(\n services => services.AddSingleton(new HealthState(\"healthy\")),\n pipelineSetup: app => app.Run(context =>\n {\n var health = context.RequestServices.GetRequiredService();\n return context.Response.WriteAsync(health.Value);\n }),\n hostFixture: new SelfManagedWebMinimalHostFixture());\n\n await host.Host.StartAsync().ConfigureAwait(false);\n using var client = host.Host.GetTestClient();\n\n return await client.GetStringAsync(\"/\").ConfigureAwait(false);\n }\n}\n\npublic sealed record HealthState(string Value);\n\npublic sealed class RunExample\n{\n [Fact]\n public async Task ExercisesExample()\n {\n Assert.Equal(\"healthy\", await new SelfManagedWebMinimalHostFixtureExample().StartHealthEndpointWhenReadyAsync());\n }\n}" + } + }, + { + "id": "45fcccef5fc861315b50c55e", + "strategy": "standalone", + "transports": [ + "native", + "docker" + ], + "image": "codebeltnet/csrun:10", + "manifest": { + "schemaVersion": 1, + "mode": "test", + "framework": "net10.0", + "dependsOn": [ + "Codebelt.Extensions.Xunit@13.0.0", + "xunit.v3@4.0.3" + ], + "source": "using Codebelt.Extensions.Xunit;\nusing Xunit;\n\nnamespace Example.Tests;\n\npublic class OutputLinesTest : Test\n{\n public OutputLinesTest(ITestOutputHelper output) : base(output) { }\n\n [Fact]\n public void ShouldWriteValuesOnSeparateLines()\n {\n TestOutput.WriteLines(\"started\", 2, \"finished\");\n Assert.True(HasTestOutput);\n }\n}" + } + }, + { + "id": "4c5e94adccd20cab4da52078", + "strategy": "repository", + "transports": [ + "native", + "docker" + ], + "repository": "codebeltnet/xunit", + "commit": "84b13767cb9484f8f3a36a71875662edfdb3e511", + "project": "test/Codebelt.Extensions.Xunit.Hosting.AspNetCore.FunctionalTests/Codebelt.Extensions.Xunit.Hosting.AspNetCore.FunctionalTests.csproj", + "test": "Codebelt.Extensions.Xunit.Hosting.AspNetCore.WebApplicationTestTest.ShouldBootstrapApplication_WhenEntryPointUsesModernProgramPattern", + "framework": "net11.0", + "image": "mcr.microsoft.com/dotnet/sdk:11.0" + }, + { + "id": "513a785b0e0abbe2284270b9", + "strategy": "standalone", + "transports": [ + "native", + "docker" + ], + "image": "codebeltnet/csrun:10", + "manifest": { + "schemaVersion": 1, + "mode": "test", + "framework": "net10.0", + "dependsOn": [ + "Codebelt.Extensions.Xunit.Hosting@13.0.0", + "Microsoft.Extensions.Hosting@10.0.15", + "xunit.v3@4.0.3" + ], + "source": "using Codebelt.Extensions.Xunit;\nusing Codebelt.Extensions.Xunit.Hosting;\nusing Microsoft.Extensions.DependencyInjection;\nusing Microsoft.Extensions.Logging;\nusing Xunit;\n\nnamespace HostFixtureTests;\n\npublic class LogInspector\n{\n public ITestStore GetEntries(ILogger logger)\n {\n return logger.GetTestStore();\n }\n\n public ITestStore GetEntries(ILogger logger)\n {\n return logger.GetTestStore();\n }\n}\n\npublic sealed class RunExample\n{\n [Fact]\n public void ExercisesExample()\n {\n var services = new ServiceCollection();\n services.AddXunitTestLogging();\n using var provider = services.BuildServiceProvider();\n var logger = provider.GetRequiredService>();\n logger.LogWarning(\"queue ready\");\n var inspector = new LogInspector();\n Assert.Contains(inspector.GetEntries((ILogger)logger).Query(), entry => entry.Severity == LogLevel.Warning && entry.Message == \"Warning: queue ready\");\n Assert.Contains(inspector.GetEntries(logger).Query(), entry => entry.Severity == LogLevel.Warning && entry.Message == \"Warning: queue ready\");\n }\n}" + } + }, + { + "id": "515575be5bb7683cac9903a5", + "strategy": "standalone", + "transports": [ + "native", + "docker" + ], + "image": "codebeltnet/csrun:10", + "manifest": { + "schemaVersion": 1, + "mode": "test", + "framework": "net10.0", + "dependsOn": [ + "Codebelt.Extensions.Xunit.Hosting@13.0.0", + "Microsoft.Extensions.Hosting@10.0.15", + "xunit.v3@4.0.3" + ], + "source": "using System.Threading.Tasks;\nusing Codebelt.Extensions.Xunit.Hosting;\nusing Microsoft.Extensions.DependencyInjection;\nusing Microsoft.Extensions.Hosting;\nusing Xunit;\n\nnamespace WorkerLifecycle.Tests;\n\npublic sealed class SelfManagedHostFixtureExample\n{\n public async Task StartAfterAttachingObserverAsync()\n {\n using var host = HostTestFactory.Create(\n hostFixture: new SelfManagedHostFixture());\n\n var started = false;\n var lifetime = host.Host.Services.GetRequiredService();\n using var registration = lifetime.ApplicationStarted.Register(() => started = true);\n\n Assert.False(started);\n await host.Host.StartAsync().ConfigureAwait(false);\n Assert.True(started);\n }\n}\n\npublic sealed class RunExample\n{\n [Fact]\n public async Task ExercisesExample()\n {\n await new SelfManagedHostFixtureExample().StartAfterAttachingObserverAsync();\n }\n}" + } + }, + { + "id": "545543e49c6bf054a9e06186", + "strategy": "standalone", + "transports": [ + "native", + "docker" + ], + "image": "codebeltnet/csrun:10", + "manifest": { + "schemaVersion": 1, + "mode": "test", + "framework": "net10.0", + "dependsOn": [ + "Codebelt.Extensions.Xunit@13.0.0", + "xunit.v3@4.0.3" + ], + "source": "using Codebelt.Extensions.Xunit;\nusing Xunit;\n\nnamespace Example.Tests;\n\npublic class OutputAccessorTest : Test\n{\n public OutputAccessorTest(ITestOutputHelper output) : base(output) { }\n\n [Fact]\n public void ShouldExposeCurrentOutput()\n {\n var accessor = new TestOutputHelperAccessor(TestOutput);\n Assert.Same(TestOutput, accessor.TestOutput);\n }\n}" + } + }, + { + "id": "549c3e82bd0bcb99e9f05bfa", + "strategy": "standalone", + "transports": [ + "native", + "docker" + ], + "image": "codebeltnet/csrun:10", + "manifest": { + "schemaVersion": 1, + "mode": "test", + "framework": "net10.0", + "dependsOn": [ + "Codebelt.Extensions.Xunit.Hosting.AspNetCore@13.0.0", + "Microsoft.Extensions.Hosting@10.0.15", + "xunit.v3@4.0.3" + ], + "frameworkReferences": [ + "Microsoft.AspNetCore.App" + ], + "source": "using Codebelt.Extensions.Xunit.Hosting.AspNetCore;\nusing Xunit;\n\nnamespace WebFixtureTests;\n\npublic class WebAppStateGuard\n{\n public bool EnsureFixtureIsReady(IWebApplicationFixture fixture) where TEntryPoint : class\n {\n return fixture.HasValidState();\n }\n}\n\npublic sealed class RunExample\n{\n [Fact]\n public void ExercisesExample()\n {\n using var fixture = new ManagedWebApplicationFixture();\n Assert.False(new WebAppStateGuard().EnsureFixtureIsReady(fixture));\n }\n}" + } + }, + { + "id": "578d467fd203f66cc41b0364", + "strategy": "standalone", + "transports": [ + "native", + "docker" + ], + "image": "codebeltnet/csrun:10", + "manifest": { + "schemaVersion": 1, + "mode": "test", + "framework": "net10.0", + "dependsOn": [ + "Codebelt.Extensions.Xunit@13.0.0", + "xunit.v3@4.0.3" + ], + "source": "using Codebelt.Extensions.Xunit;\nusing Xunit;\n\nnamespace Example.Tests;\n\npublic class MixedOutputTest : Test\n{\n public MixedOutputTest(ITestOutputHelper output) : base(output) { }\n\n [Fact]\n public void ShouldWriteMixedValues()\n {\n TestOutput.WriteLines((object)\"cache\", 3);\n Assert.True(HasTestOutput);\n }\n}" + } + }, + { + "id": "5e35a33e56470f93afbedf19", + "strategy": "standalone", + "transports": [ + "native", + "docker" + ], + "image": "codebeltnet/csrun:10", + "manifest": { + "schemaVersion": 1, + "mode": "test", + "framework": "net10.0", + "dependsOn": [ + "Codebelt.Extensions.Xunit.Hosting@13.0.0", + "Microsoft.Extensions.Hosting@10.0.15", + "xunit.v3@4.0.3" + ], + "source": "using System;\nusing Codebelt.Extensions.Xunit.Hosting;\nusing Microsoft.Extensions.DependencyInjection;\nusing Xunit;\n\nnamespace HostFixtureTests;\n\npublic class ServiceResolver\n{\n public T Resolve(IServiceProvider provider) where T : notnull\n {\n return provider.GetRequiredScopedService();\n }\n}\n\npublic sealed class RunExample\n{\n [Fact]\n public void ExercisesExample()\n {\n var services = new ServiceCollection();\n services.AddScoped(_ => new object());\n using var provider = services.BuildServiceProvider(new ServiceProviderOptions\n {\n ValidateScopes = true\n });\n Assert.NotSame(new ServiceResolver().Resolve(provider), new ServiceResolver().Resolve(provider));\n }\n}" + } + }, + { + "id": "6a59b7744a7d9994ffc04782", + "strategy": "standalone", + "transports": [ + "native", + "docker" + ], + "image": "codebeltnet/csrun:10", + "manifest": { + "schemaVersion": 1, + "mode": "test", + "framework": "net10.0", + "dependsOn": [ + "Codebelt.Extensions.Xunit.Hosting@13.0.0", + "Microsoft.Extensions.Hosting@10.0.15", + "xunit.v3@4.0.3" + ], + "source": "using Codebelt.Extensions.Xunit.Hosting;\nusing Microsoft.Extensions.DependencyInjection;\nusing Microsoft.Extensions.Hosting;\nusing Xunit;\n\nnamespace HostFixtureTests;\n\npublic class MinimalWorkerTest : MinimalHostTest\n{\n public MinimalWorkerTest(ManagedMinimalHostFixture hostFixture, ITestOutputHelper output) : base(hostFixture, output)\n {\n }\n\n protected override void ConfigureHost(IHostApplicationBuilder hb)\n {\n hb.Services.AddSingleton();\n hb.Services.AddXunitTestLogging();\n }\n\n [Fact]\n public void Host_ShouldNotBeNull()\n {\n Assert.NotNull(Host);\n }\n}\n\npublic class MetricsTracker;" + } + }, + { + "id": "782f24d34260070258f6d164", + "strategy": "standalone", + "transports": [ + "native", + "docker" + ], + "image": "codebeltnet/csrun:10", + "manifest": { + "schemaVersion": 1, + "mode": "test", + "framework": "net10.0", + "dependsOn": [ + "Codebelt.Extensions.Xunit@13.0.0", + "xunit.v3@4.0.3" + ], + "source": "using System;\nusing Codebelt.Extensions.Xunit;\nusing Xunit;\nusing Xunit.Sdk;\n\nnamespace Example.Tests;\n\n[TestMethodOrderer(typeof(PriorityTestMethodOrderer))]\npublic class CacheLifecycleTest : Test\n{\n private static bool _initialized;\n\n public CacheLifecycleTest(ITestOutputHelper output) : base(output) { }\n\n [Fact, Priority(-1)]\n public void ShouldInitializeCache()\n {\n var orderer = new PriorityTestMethodOrderer();\n Assert.Empty(orderer.OrderTestMethods(Array.Empty()));\n _initialized = true;\n }\n\n [Fact, Priority(0)]\n public void ShouldUseInitializedCache()\n {\n Assert.True(_initialized);\n }\n}" + } + }, + { + "id": "812efaa205554c7bdcd80831", + "strategy": "standalone", + "transports": [ + "native", + "docker" + ], + "image": "codebeltnet/csrun:10", + "manifest": { + "schemaVersion": 1, + "mode": "test", + "framework": "net10.0", + "dependsOn": [ + "Codebelt.Extensions.Xunit@13.0.0", + "xunit.v3@4.0.3" + ], + "source": "using Codebelt.Extensions.Xunit;\nusing Xunit;\n\nnamespace Example.Tests;\n\n[TestMethodOrderer(typeof(PriorityTestMethodOrderer))]\npublic class InitializationTest : Test\n{\n private static string _value;\n\n public InitializationTest(ITestOutputHelper output) : base(output) { }\n\n [Fact, Priority(0)]\n public void ShouldInitializeFirst()\n {\n var priority = new PriorityAttribute(0);\n Assert.Equal(0, priority.Priority);\n _value = \"ready\";\n }\n\n [Fact, Priority(1)]\n public void ShouldReadInitializedValue()\n {\n Assert.Equal(\"ready\", _value);\n }\n}" + } + }, + { + "id": "90a8cd444bd08a0115613e58", + "strategy": "repository", + "transports": [ + "native", + "docker" + ], + "repository": "codebeltnet/xunit", + "commit": "84b13767cb9484f8f3a36a71875662edfdb3e511", + "project": "test/Codebelt.Extensions.Xunit.Hosting.FunctionalTests/Codebelt.Extensions.Xunit.Hosting.FunctionalTests.csproj", + "test": "Codebelt.Extensions.Xunit.Hosting.ApplicationTestFactoryTest.Create_ShouldBootstrapApplication_WhenEntryPointUsesBootstrapperMinimalWorkerProgram", + "framework": "net11.0", + "image": "mcr.microsoft.com/dotnet/sdk:11.0" + }, + { + "id": "927ca9f6a3bf893bc52887f4", + "strategy": "standalone", + "transports": [ + "native", + "docker" + ], + "image": "codebeltnet/csrun:10", + "manifest": { + "schemaVersion": 1, + "mode": "test", + "framework": "net10.0", + "dependsOn": [ + "Codebelt.Extensions.Xunit.Hosting.AspNetCore@13.0.0", + "Microsoft.Extensions.Hosting@10.0.15", + "xunit.v3@4.0.3" + ], + "frameworkReferences": [ + "Microsoft.AspNetCore.App" + ], + "source": "using System.Threading.Tasks;\nusing Codebelt.Extensions.Xunit.Hosting.AspNetCore;\nusing Microsoft.AspNetCore.Builder;\nusing Microsoft.AspNetCore.Http;\nusing Microsoft.Extensions.DependencyInjection;\nusing Xunit;\n\nnamespace WebFixtureTests;\n\npublic class MiddlewareTest : WebHostTest\n{\n public MiddlewareTest(ManagedWebHostFixture hostFixture, ITestOutputHelper output) : base(hostFixture, output)\n {\n }\n\n public override void ConfigureServices(IServiceCollection services)\n {\n services.AddFakeHttpContextAccessor();\n }\n\n public override void ConfigureApplication(IApplicationBuilder app)\n {\n app.UseMiddleware();\n }\n\n [Fact]\n public async Task Middleware_ShouldAddHeader()\n {\n var pipeline = Application.Build();\n var context = new DefaultHttpContext();\n await pipeline(context);\n Assert.True(context.Response.Headers.ContainsKey(\"X-Test\"));\n }\n}\n\npublic class TestMiddleware(RequestDelegate next)\n{\n public async Task InvokeAsync(HttpContext context)\n {\n context.Response.Headers[\"X-Test\"] = \"true\";\n await next(context);\n }\n}" + } + }, + { + "id": "947406357e3e26b26a71a538", + "strategy": "standalone", + "transports": [ + "native", + "docker" + ], + "image": "codebeltnet/csrun:10", + "manifest": { + "schemaVersion": 1, + "mode": "console", + "framework": "net10.0", + "dependsOn": [ + "Codebelt.Extensions.Xunit.Hosting.AspNetCore@13.0.0", + "Microsoft.Extensions.Hosting@10.0.15", + "Microsoft.AspNetCore.TestHost@10.0.15" + ], + "frameworkReferences": [ + "Microsoft.AspNetCore.App" + ], + "sdk": "Microsoft.NET.Sdk.Web", + "source": "using System;\nusing System.Net.Http;\nusing System.Threading.Tasks;\nusing Codebelt.Extensions.Xunit.Hosting.AspNetCore;\nusing Microsoft.AspNetCore.Builder;\nusing Microsoft.AspNetCore.TestHost;\n\nnamespace WebFixtureTests;\n\npublic class HttpClientExample\n{\n public async Task DemonstrateAsync(HttpClient client)\n {\n var response = await client.ToHttpResponseMessageAsync().ConfigureAwait(false);\n Console.WriteLine(response.StatusCode);\n }\n}\n\ninternal static class RunExample\n{\n static async Task Main()\n {\n using var app = WebHostTestFactory.Create(pipelineSetup: app => app.Run(context =>\n {\n context.Response.StatusCode = 202;\n return Task.CompletedTask;\n }));\n using var client = app.Host.GetTestClient();\n await new HttpClientExample().DemonstrateAsync(client);\n }\n}" + } + }, + { + "id": "9a558a9a581c6b11ccb28057", + "strategy": "standalone", + "transports": [ + "native", + "docker" + ], + "image": "codebeltnet/csrun:10", + "manifest": { + "schemaVersion": 1, + "mode": "test", + "framework": "net10.0", + "dependsOn": [ + "Codebelt.Extensions.Xunit.Hosting@13.0.0", + "Microsoft.Extensions.Hosting@10.0.15", + "xunit.v3@4.0.3" + ], + "source": "using Codebelt.Extensions.Xunit.Hosting;\nusing Microsoft.Extensions.Logging;\nusing Xunit;\n\nnamespace HostFixtureTests;\n\npublic class LogEntryExample\n{\n public string FormatEntry()\n {\n var entry = new XunitTestLoggerEntry(LogLevel.Warning, new EventId(1001, \"MyEvent\"), \"Something unexpected happened.\");\n return entry.ToString();\n }\n}\n\npublic sealed class RunExample\n{\n [Fact]\n public void ExercisesExample()\n {\n Assert.Equal(\"Something unexpected happened.\", new LogEntryExample().FormatEntry());\n }\n}" + } + }, + { + "id": "9cdeb08f8ba8f3b361a98c58", + "strategy": "standalone", + "transports": [ + "native", + "docker" + ], + "image": "codebeltnet/csrun:10", + "manifest": { + "schemaVersion": 1, + "mode": "test", + "framework": "net10.0", + "dependsOn": [ + "Codebelt.Extensions.Xunit.Hosting@13.0.0", + "Microsoft.Extensions.Hosting@10.0.15", + "xunit.v3@4.0.3" + ], + "source": "using Codebelt.Extensions.Xunit.Hosting;\nusing Microsoft.Extensions.DependencyInjection;\nusing Xunit;\n\nnamespace WorkerServices.Tests;\n\npublic sealed class HostTestFactoryExample\n{\n public string ResolveWorkerStatus()\n {\n using var host = HostTestFactory.Create(\n services => services.AddSingleton(new WorkerStatus(\"ready\")));\n\n var status = host.Host.Services.GetRequiredService();\n return status.Value;\n }\n}\n\npublic sealed record WorkerStatus(string Value);\n\npublic sealed class RunExample\n{\n [Fact]\n public void ExercisesExample()\n {\n Assert.Equal(\"ready\", new HostTestFactoryExample().ResolveWorkerStatus());\n }\n}" + } + }, + { + "id": "a31971b360a8c557b87f6684", + "strategy": "standalone", + "transports": [ + "native", + "docker" + ], + "image": "codebeltnet/csrun:10", + "manifest": { + "schemaVersion": 1, + "mode": "test", + "framework": "net10.0", + "dependsOn": [ + "Codebelt.Extensions.Xunit@13.0.0", + "xunit.v3@4.0.3" + ], + "source": "using System.Linq;\nusing Codebelt.Extensions.Xunit;\nusing Xunit;\n\nnamespace Example.Tests;\n\npublic class StoreExample\n{\n public bool HasMatchingItem()\n {\n var store = new InMemoryTestStore();\n store.Add(\"cached\");\n store.Add(\"other\");\n return store.Count == 2 && store.Query(value => value == \"cached\").Single() == \"cached\";\n }\n}\n\npublic sealed class RunExample\n{\n [Fact]\n public void ExercisesExample()\n {\n Assert.True(new StoreExample().HasMatchingItem());\n }\n}" + } + }, + { + "id": "b4149382f121a5ffc3c057df", + "strategy": "standalone", + "transports": [ + "native", + "docker" + ], + "image": "codebeltnet/csrun:10", + "manifest": { + "schemaVersion": 1, + "mode": "test", + "framework": "net10.0", + "dependsOn": [ + "Codebelt.Extensions.Xunit.Hosting@13.0.0", + "Microsoft.Extensions.Hosting@10.0.15", + "xunit.v3@4.0.3" + ], + "source": "using System.Threading.Tasks;\nusing Codebelt.Extensions.Xunit.Hosting;\nusing Microsoft.Extensions.DependencyInjection;\nusing Xunit;\n\nnamespace MinimalWorkerLifecycle.Tests;\n\npublic sealed class SelfManagedMinimalHostFixtureExample\n{\n public async Task ConfigureBeforeStartingAsync()\n {\n using var host = MinimalHostTestFactory.Create(\n services => services.AddSingleton(new StartupState(\"configured\")),\n hostFixture: new SelfManagedMinimalHostFixture());\n\n var beforeStart = host.Host.Services.GetRequiredService();\n Assert.Equal(\"configured\", beforeStart.Value);\n\n await host.Host.StartAsync().ConfigureAwait(false);\n\n var afterStart = host.Host.Services.GetRequiredService();\n Assert.Same(beforeStart, afterStart);\n }\n}\n\npublic sealed record StartupState(string Value);\n\npublic sealed class RunExample\n{\n [Fact]\n public async Task ExercisesExample()\n {\n await new SelfManagedMinimalHostFixtureExample().ConfigureBeforeStartingAsync();\n }\n}" + } + }, + { + "id": "becb2fe7446fc1571dc86953", + "strategy": "standalone", + "transports": [ + "native", + "docker" + ], + "image": "codebeltnet/csrun:10", + "manifest": { + "schemaVersion": 1, + "mode": "test", + "framework": "net10.0", + "dependsOn": [ + "Codebelt.Extensions.Xunit.Hosting@13.0.0", + "Microsoft.Extensions.Hosting@10.0.15", + "xunit.v3@4.0.3" + ], + "source": "using Codebelt.Extensions.Xunit.Hosting;\nusing Xunit;\n\nnamespace HostFixtureTests;\n\npublic class HostStateGuard\n{\n public bool EnsureFixtureIsReady(IMinimalHostFixture fixture)\n {\n return fixture.HasValidState();\n }\n}\n\npublic sealed class RunExample\n{\n [Fact]\n public void ExercisesExample()\n {\n using var fixture = new ManagedMinimalHostFixture();\n Assert.False(new HostStateGuard().EnsureFixtureIsReady(fixture));\n using var app = MinimalHostTestFactory.Create(hostFixture: fixture);\n Assert.True(new HostStateGuard().EnsureFixtureIsReady(fixture));\n }\n}" + } + }, + { + "id": "d565f9c40d015b247963fdee", + "strategy": "standalone", + "transports": [ + "native", + "docker" + ], + "image": "codebeltnet/csrun:10", + "manifest": { + "schemaVersion": 1, + "mode": "test", + "framework": "net10.0", + "dependsOn": [ + "Codebelt.Extensions.Xunit.Hosting.AspNetCore@13.0.0", + "Microsoft.Extensions.Hosting@10.0.15", + "xunit.v3@4.0.3" + ], + "frameworkReferences": [ + "Microsoft.AspNetCore.App" + ], + "source": "using Codebelt.Extensions.Xunit.Hosting.AspNetCore;\nusing Microsoft.AspNetCore.Builder;\nusing Microsoft.Extensions.Hosting;\nusing Xunit;\n\nnamespace WebFixtureTests;\n\npublic class BuilderConverter\n{\n public IHostBuilder Convert(IHostApplicationBuilder builder)\n {\n return builder.ToHostBuilder();\n }\n}\n\npublic sealed class RunExample\n{\n [Fact]\n public void ReturnsTheWebHostBuilder()\n {\n var builder = WebApplication.CreateBuilder();\n Assert.Same(builder.Host, new BuilderConverter().Convert(builder));\n }\n}" + } + }, + { + "id": "d71e8ed85f1221cb41308b31", + "strategy": "standalone", + "transports": [ + "native", + "docker" + ], + "image": "codebeltnet/csrun:10", + "manifest": { + "schemaVersion": 1, + "mode": "test", + "framework": "net10.0", + "dependsOn": [ + "Codebelt.Extensions.Xunit.Hosting.AspNetCore@13.0.0", + "Microsoft.Extensions.Hosting@10.0.15", + "xunit.v3@4.0.3" + ], + "frameworkReferences": [ + "Microsoft.AspNetCore.App" + ], + "source": "using System.Threading.Tasks;\nusing Codebelt.Extensions.Xunit.Hosting.AspNetCore;\nusing Microsoft.AspNetCore.Builder;\nusing Microsoft.AspNetCore.Http;\nusing Microsoft.Extensions.DependencyInjection;\nusing Xunit;\n\nnamespace RequestPipeline.Tests;\n\npublic sealed class WebHostTestFactoryExample\n{\n public async Task InvokeStatusMiddlewareAsync()\n {\n using var response = await WebHostTestFactory.RunAsync(\n services => services.AddSingleton(new PipelineStatus(\"ready\")),\n app => app.Run(context =>\n {\n var status = context.RequestServices.GetRequiredService();\n return context.Response.WriteAsync(status.Value);\n })).ConfigureAwait(false);\n\n return await response.Content.ReadAsStringAsync().ConfigureAwait(false);\n }\n}\n\npublic sealed record PipelineStatus(string Value);\n\npublic sealed class RunExample\n{\n [Fact]\n public async Task ExercisesExample()\n {\n Assert.Equal(\"ready\", await new WebHostTestFactoryExample().InvokeStatusMiddlewareAsync());\n }\n}" + } + }, + { + "id": "dd2fa1a038dbc1220b366a53", + "strategy": "standalone", + "transports": [ + "native", + "docker" + ], + "image": "codebeltnet/csrun:10", + "manifest": { + "schemaVersion": 1, + "mode": "test", + "framework": "net10.0", + "dependsOn": [ + "Codebelt.Extensions.Xunit.Hosting.AspNetCore@13.0.0", + "Microsoft.Extensions.Hosting@10.0.15", + "xunit.v3@4.0.3" + ], + "frameworkReferences": [ + "Microsoft.AspNetCore.App" + ], + "source": "using Codebelt.Extensions.Xunit.Hosting.AspNetCore;\nusing Xunit;\n\nnamespace WebFixtureTests;\n\npublic class WebMinimalHostStateGuard\n{\n public bool EnsureFixtureIsReady(IWebMinimalHostFixture fixture)\n {\n return fixture.HasValidState();\n }\n}\n\npublic sealed class RunExample\n{\n [Fact]\n public void ExercisesExample()\n {\n using var fixture = new ManagedWebMinimalHostFixture();\n Assert.False(new WebMinimalHostStateGuard().EnsureFixtureIsReady(fixture));\n using var app = MinimalWebHostTestFactory.Create(hostFixture: fixture);\n Assert.True(new WebMinimalHostStateGuard().EnsureFixtureIsReady(fixture));\n }\n}" + } + }, + { + "id": "dfdd064179bf4643e1a0b2bf", + "strategy": "standalone", + "transports": [ + "native", + "docker" + ], + "image": "codebeltnet/csrun:10", + "manifest": { + "schemaVersion": 1, + "mode": "test", + "framework": "net10.0", + "dependsOn": [ + "Codebelt.Extensions.Xunit.Hosting.AspNetCore@13.0.0", + "Microsoft.Extensions.Hosting@10.0.15", + "xunit.v3@4.0.3" + ], + "frameworkReferences": [ + "Microsoft.AspNetCore.App" + ], + "source": "using Codebelt.Extensions.Xunit.Hosting.AspNetCore;\nusing Xunit;\n\nnamespace WebFixtureTests;\n\npublic class WebHostStateGuard\n{\n public bool EnsureFixtureIsReady(IWebHostFixture fixture)\n {\n return fixture.HasValidState();\n }\n}\n\npublic sealed class RunExample\n{\n [Fact]\n public void ExercisesExample()\n {\n using var fixture = new ManagedWebHostFixture();\n Assert.False(new WebHostStateGuard().EnsureFixtureIsReady(fixture));\n using var app = WebHostTestFactory.Create(hostFixture: fixture);\n Assert.True(new WebHostStateGuard().EnsureFixtureIsReady(fixture));\n }\n}" + } + }, + { + "id": "e3f79d1c0f2fa85276cee2fb", + "strategy": "standalone", + "transports": [ + "native", + "docker" + ], + "image": "codebeltnet/csrun:10", + "manifest": { + "schemaVersion": 1, + "mode": "console", + "framework": "net10.0", + "dependsOn": [ + "Codebelt.Extensions.Xunit.Hosting@13.0.0", + "Microsoft.Extensions.Hosting@10.0.15" + ], + "source": "using System;\nusing Codebelt.Extensions.Xunit.Hosting;\nusing Microsoft.Extensions.DependencyInjection;\n\nnamespace HostFixtureTests;\n\npublic class MinimalHostFactoryExample\n{\n public void Demonstrate()\n {\n using var host = MinimalHostTestFactory.Create(\n services => services.AddSingleton(new Version(1, 0, 0)));\n var version = host.Host.Services.GetRequiredService();\n Console.WriteLine(version);\n }\n}\n\ninternal static class RunExample\n{\n static void Main()\n {\n new MinimalHostFactoryExample().Demonstrate();\n }\n}" + } + }, + { + "id": "e7dbb5ba733b205469239b03", + "strategy": "standalone", + "transports": [ + "native", + "docker" + ], + "image": "codebeltnet/csrun:10", + "manifest": { + "schemaVersion": 1, + "mode": "test", + "framework": "net10.0", + "dependsOn": [ + "Codebelt.Extensions.Xunit.Hosting@13.0.0", + "Microsoft.Extensions.Hosting@10.0.15", + "xunit.v3@4.0.3" + ], + "source": "using Codebelt.Extensions.Xunit.Hosting;\nusing Xunit;\n\nnamespace HostFixtureTests;\n\npublic class HostStateGuard\n{\n public bool EnsureFixtureIsReady(IApplicationFixture fixture) where TEntryPoint : class\n {\n return fixture.HasValidState();\n }\n}\n\npublic sealed class RunExample\n{\n [Fact]\n public void ExercisesExample()\n {\n using var fixture = new ManagedApplicationFixture();\n Assert.False(new HostStateGuard().EnsureFixtureIsReady(fixture));\n }\n}" + } + }, + { + "id": "f27f77d838407171b56f9073", + "strategy": "standalone", + "transports": [ + "native", + "docker" + ], + "image": "codebeltnet/csrun:10", + "manifest": { + "schemaVersion": 1, + "mode": "console", + "framework": "net10.0", + "dependsOn": [ + "Codebelt.Extensions.Xunit.Hosting.AspNetCore@13.0.0", + "Microsoft.AspNetCore.TestHost@10.0.15" + ], + "frameworkReferences": [ + "Microsoft.AspNetCore.App" + ], + "sdk": "Microsoft.NET.Sdk.Web", + "source": "// Program.cs\nusing System;\nusing Codebelt.Extensions.Xunit.Hosting.AspNetCore;\nusing Microsoft.AspNetCore.Builder;\nusing Microsoft.AspNetCore.Http;\nusing Microsoft.AspNetCore.TestHost;\nusing Microsoft.Extensions.Hosting;\n\nusing var host = WebHostTestFactory.Create(\n pipelineSetup: app => app.Run(context =>\n context.Response.WriteAsync(\"started on demand\")),\n hostFixture: new SelfManagedWebHostFixture());\n\nawait host.Host.StartAsync().ConfigureAwait(false);\nusing var client = host.Host.GetTestClient();\n\nConsole.WriteLine(await client.GetStringAsync(\"/\").ConfigureAwait(false));" + } + }, + { + "id": "f3c0856195727da12ff2925f", + "strategy": "standalone", + "transports": [ + "native", + "docker" + ], + "image": "codebeltnet/csrun:10", + "manifest": { + "schemaVersion": 1, + "mode": "test", + "framework": "net10.0", + "dependsOn": [ + "Codebelt.Extensions.Xunit.Hosting.AspNetCore@13.0.0", + "xunit.v3@4.0.3" + ], + "frameworkReferences": [ + "Microsoft.AspNetCore.App" + ], + "source": "using Codebelt.Extensions.Xunit.Hosting.AspNetCore;\nusing Microsoft.AspNetCore.Http;\nusing Microsoft.Extensions.DependencyInjection;\nusing Xunit;\n\nnamespace WebFixtureTests;\n\npublic class ExampleFixture\n{\n public IServiceCollection ConfigureServices(IServiceCollection services)\n {\n return services.AddFakeHttpContextAccessor(ServiceLifetime.Scoped);\n }\n}\n\npublic sealed class RunExample\n{\n [Fact]\n public void ExercisesExample()\n {\n using var provider = new ExampleFixture().ConfigureServices(new ServiceCollection()).BuildServiceProvider();\n using var scope = provider.CreateScope();\n Assert.IsType(scope.ServiceProvider.GetRequiredService());\n }\n}" + } + }, + { + "id": "f5ed7c321a52580d7ce11408", + "strategy": "standalone", + "transports": [ + "native", + "docker" + ], + "image": "codebeltnet/csrun:10", + "manifest": { + "schemaVersion": 1, + "mode": "console", + "framework": "net10.0", + "dependsOn": [ + "Codebelt.Extensions.Xunit.Hosting.AspNetCore@13.0.0" + ], + "frameworkReferences": [ + "Microsoft.AspNetCore.App" + ], + "sdk": "Microsoft.NET.Sdk.Web", + "source": "using System;\nusing Codebelt.Extensions.Xunit.Hosting.AspNetCore.Http.Features;\n\nnamespace WebFixtureTests;\n\npublic class RequestFeatureExample\n{\n public void Demonstrate()\n {\n var request = new FakeHttpRequestFeature();\n Console.WriteLine(request.Method);\n }\n}\n\ninternal static class RunExample\n{\n static void Main()\n {\n new RequestFeatureExample().Demonstrate();\n }\n}" + } + }, + { + "id": "ff2e361441bdc3028ab188a9", + "strategy": "standalone", + "transports": [ + "native", + "docker" + ], + "image": "codebeltnet/csrun:10", + "manifest": { + "schemaVersion": 1, + "mode": "console", + "framework": "net10.0", + "dependsOn": [ + "Codebelt.Extensions.Xunit.Hosting@13.0.0", + "Microsoft.Extensions.Hosting@10.0.15" + ], + "source": "using System;\nusing Codebelt.Extensions.Xunit.Hosting;\nusing Microsoft.Extensions.DependencyInjection;\nusing Microsoft.Extensions.Hosting;\n\nnamespace WorkerApp.Tests;\n\npublic sealed class ApplicationHostFactoryExample\n{\n public string GetTestIdentity()\n {\n using IHost host = ApplicationHostFactory.Create(builder =>\n {\n builder.ConfigureServices(services =>\n services.AddSingleton(new WorkerIdentity(\"Test inventory worker\")));\n });\n\n var identity = host.Services.GetRequiredService();\n return identity.Name;\n }\n}\n\npublic sealed record WorkerIdentity(string Name);\n\npublic sealed class WorkerProgram\n{\n public static IHostBuilder CreateHostBuilder(string[] args)\n {\n return Host.CreateDefaultBuilder(args);\n }\n\n public static void Main(string[] args)\n {\n var identity = new ApplicationHostFactoryExample().GetTestIdentity();\n if (identity != \"Test inventory worker\")\n {\n throw new InvalidOperationException(identity);\n }\n\n Console.WriteLine(identity);\n }\n}" + } + }, + { + "id": "aa478d74f298d8c98e6cd1bf", + "strategy": "standalone", + "transports": [ + "native", + "docker" + ], + "image": "codebeltnet/csrun:10", + "manifest": { + "schemaVersion": 1, + "mode": "test", + "framework": "net10.0", + "dependsOn": [ + "Codebelt.Extensions.Xunit.Hosting@13.0.0", + "Microsoft.Extensions.Hosting@10.0.15", + "xunit.v3@4.0.3" + ], + "source": "using System.Threading;\nusing System.Threading.Tasks;\nusing Codebelt.Extensions.Xunit.Hosting;\nusing Microsoft.Extensions.DependencyInjection;\nusing Microsoft.Extensions.Hosting;\nusing Xunit;\n\nnamespace HostFixtureTests;\n\npublic class BackgroundServiceTest : HostTest\n{\n public BackgroundServiceTest(ManagedHostFixture hostFixture, ITestOutputHelper output) : base(hostFixture, output)\n {\n }\n\n public override void ConfigureServices(IServiceCollection services)\n {\n services.AddHostedService();\n services.AddXunitTestLogging();\n }\n\n [Fact]\n public void Host_ShouldBeRunning()\n {\n Assert.NotNull(Host);\n }\n}\n\npublic class TestWorker : BackgroundService\n{\n protected override async Task ExecuteAsync(CancellationToken stoppingToken)\n {\n while (!stoppingToken.IsCancellationRequested)\n {\n await Task.Delay(100, stoppingToken);\n }\n }\n}" + } + } + ] +} From 8f63a006ff922e4b2b0d7e318ca06afc042a7c28 Mon Sep 17 00:00:00 2001 From: aicia-bot Date: Sat, 21 Nov 2026 00:42:02 +0100 Subject: [PATCH 05/12] =?UTF-8?q?=F0=9F=94=A5=20stop=20tracking=20generate?= =?UTF-8?q?d=20run-action=20scripts?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The generated docker and native scripts and index.json are now produced from the manifest during the docfx build, so keeping them in git only creates drift. Ignore the output folder so it cannot be re-added by accident. --- .../00acdae546dce87b654496e1/docker.ps1 | 86 --- .../00acdae546dce87b654496e1/native.ps1 | 89 --- .../0308118a47b5c02daa7b32be/docker.ps1 | 82 --- .../0308118a47b5c02daa7b32be/native.ps1 | 85 --- .../038a1c806225b412a6f986c1/docker.ps1 | 82 --- .../038a1c806225b412a6f986c1/native.ps1 | 85 --- .../08b911ef79f0b743282e37c9/docker.ps1 | 85 --- .../08b911ef79f0b743282e37c9/native.ps1 | 88 --- .../10457ac34cce1cbadb26aee1/docker.ps1 | 82 --- .../10457ac34cce1cbadb26aee1/native.ps1 | 85 --- .../1130af506703020850fdadea/docker.ps1 | 83 --- .../1130af506703020850fdadea/native.ps1 | 86 --- .../18b0746bf3da1d84f81b5274/docker.ps1 | 83 --- .../18b0746bf3da1d84f81b5274/native.ps1 | 86 --- .../1e869fe39c4833386733c21f/docker.ps1 | 86 --- .../1e869fe39c4833386733c21f/native.ps1 | 89 --- .../1ec9196292addaca42a7eef1/docker.ps1 | 58 -- .../1ec9196292addaca42a7eef1/native.ps1 | 50 -- .../21b422ce67f920d801901db0/docker.ps1 | 86 --- .../21b422ce67f920d801901db0/native.ps1 | 89 --- .../38b60f4b4c1a588bbefe92f1/docker.ps1 | 58 -- .../38b60f4b4c1a588bbefe92f1/native.ps1 | 50 -- .../3a1dbfc0e010519636b7091e/docker.ps1 | 85 --- .../3a1dbfc0e010519636b7091e/native.ps1 | 88 --- .../3c3b98167b30d6985017ec27/docker.ps1 | 87 --- .../3c3b98167b30d6985017ec27/native.ps1 | 90 --- .../45fcccef5fc861315b50c55e/docker.ps1 | 82 --- .../45fcccef5fc861315b50c55e/native.ps1 | 85 --- .../4c5e94adccd20cab4da52078/docker.ps1 | 58 -- .../4c5e94adccd20cab4da52078/native.ps1 | 50 -- .../513a785b0e0abbe2284270b9/docker.ps1 | 83 --- .../513a785b0e0abbe2284270b9/native.ps1 | 86 --- .../515575be5bb7683cac9903a5/docker.ps1 | 83 --- .../515575be5bb7683cac9903a5/native.ps1 | 86 --- .../545543e49c6bf054a9e06186/docker.ps1 | 82 --- .../545543e49c6bf054a9e06186/native.ps1 | 85 --- .../549c3e82bd0bcb99e9f05bfa/docker.ps1 | 86 --- .../549c3e82bd0bcb99e9f05bfa/native.ps1 | 89 --- .../578d467fd203f66cc41b0364/docker.ps1 | 82 --- .../578d467fd203f66cc41b0364/native.ps1 | 85 --- .../5e35a33e56470f93afbedf19/docker.ps1 | 83 --- .../5e35a33e56470f93afbedf19/native.ps1 | 86 --- .../6a59b7744a7d9994ffc04782/docker.ps1 | 83 --- .../6a59b7744a7d9994ffc04782/native.ps1 | 86 --- .../782f24d34260070258f6d164/docker.ps1 | 82 --- .../782f24d34260070258f6d164/native.ps1 | 85 --- .../812efaa205554c7bdcd80831/docker.ps1 | 82 --- .../812efaa205554c7bdcd80831/native.ps1 | 85 --- .../90a8cd444bd08a0115613e58/docker.ps1 | 58 -- .../90a8cd444bd08a0115613e58/native.ps1 | 50 -- .../927ca9f6a3bf893bc52887f4/docker.ps1 | 86 --- .../927ca9f6a3bf893bc52887f4/native.ps1 | 89 --- .../947406357e3e26b26a71a538/docker.ps1 | 87 --- .../947406357e3e26b26a71a538/native.ps1 | 90 --- .../9a558a9a581c6b11ccb28057/docker.ps1 | 83 --- .../9a558a9a581c6b11ccb28057/native.ps1 | 86 --- .../9cdeb08f8ba8f3b361a98c58/docker.ps1 | 83 --- .../9cdeb08f8ba8f3b361a98c58/native.ps1 | 86 --- .../a31971b360a8c557b87f6684/docker.ps1 | 82 --- .../a31971b360a8c557b87f6684/native.ps1 | 85 --- .../aa478d74f298d8c98e6cd1bf/docker.ps1 | 83 --- .../aa478d74f298d8c98e6cd1bf/native.ps1 | 86 --- .../b4149382f121a5ffc3c057df/docker.ps1 | 83 --- .../b4149382f121a5ffc3c057df/native.ps1 | 86 --- .../becb2fe7446fc1571dc86953/docker.ps1 | 83 --- .../becb2fe7446fc1571dc86953/native.ps1 | 86 --- .../d565f9c40d015b247963fdee/docker.ps1 | 86 --- .../d565f9c40d015b247963fdee/native.ps1 | 89 --- .../d71e8ed85f1221cb41308b31/docker.ps1 | 86 --- .../d71e8ed85f1221cb41308b31/native.ps1 | 89 --- .../dd2fa1a038dbc1220b366a53/docker.ps1 | 86 --- .../dd2fa1a038dbc1220b366a53/native.ps1 | 89 --- .../dfdd064179bf4643e1a0b2bf/docker.ps1 | 86 --- .../dfdd064179bf4643e1a0b2bf/native.ps1 | 89 --- .../e3f79d1c0f2fa85276cee2fb/docker.ps1 | 82 --- .../e3f79d1c0f2fa85276cee2fb/native.ps1 | 85 --- .../e7dbb5ba733b205469239b03/docker.ps1 | 83 --- .../e7dbb5ba733b205469239b03/native.ps1 | 86 --- .../f27f77d838407171b56f9073/docker.ps1 | 86 --- .../f27f77d838407171b56f9073/native.ps1 | 89 --- .../f3c0856195727da12ff2925f/docker.ps1 | 85 --- .../f3c0856195727da12ff2925f/native.ps1 | 88 --- .../f5ed7c321a52580d7ce11408/docker.ps1 | 85 --- .../f5ed7c321a52580d7ce11408/native.ps1 | 88 --- .../ff2e361441bdc3028ab188a9/docker.ps1 | 82 --- .../ff2e361441bdc3028ab188a9/native.ps1 | 85 --- .docfx/run-actions/index.json | 692 ------------------ .gitignore | 1 + 88 files changed, 1 insertion(+), 7785 deletions(-) delete mode 100644 .docfx/run-actions/00acdae546dce87b654496e1/docker.ps1 delete mode 100644 .docfx/run-actions/00acdae546dce87b654496e1/native.ps1 delete mode 100644 .docfx/run-actions/0308118a47b5c02daa7b32be/docker.ps1 delete mode 100644 .docfx/run-actions/0308118a47b5c02daa7b32be/native.ps1 delete mode 100644 .docfx/run-actions/038a1c806225b412a6f986c1/docker.ps1 delete mode 100644 .docfx/run-actions/038a1c806225b412a6f986c1/native.ps1 delete mode 100644 .docfx/run-actions/08b911ef79f0b743282e37c9/docker.ps1 delete mode 100644 .docfx/run-actions/08b911ef79f0b743282e37c9/native.ps1 delete mode 100644 .docfx/run-actions/10457ac34cce1cbadb26aee1/docker.ps1 delete mode 100644 .docfx/run-actions/10457ac34cce1cbadb26aee1/native.ps1 delete mode 100644 .docfx/run-actions/1130af506703020850fdadea/docker.ps1 delete mode 100644 .docfx/run-actions/1130af506703020850fdadea/native.ps1 delete mode 100644 .docfx/run-actions/18b0746bf3da1d84f81b5274/docker.ps1 delete mode 100644 .docfx/run-actions/18b0746bf3da1d84f81b5274/native.ps1 delete mode 100644 .docfx/run-actions/1e869fe39c4833386733c21f/docker.ps1 delete mode 100644 .docfx/run-actions/1e869fe39c4833386733c21f/native.ps1 delete mode 100644 .docfx/run-actions/1ec9196292addaca42a7eef1/docker.ps1 delete mode 100644 .docfx/run-actions/1ec9196292addaca42a7eef1/native.ps1 delete mode 100644 .docfx/run-actions/21b422ce67f920d801901db0/docker.ps1 delete mode 100644 .docfx/run-actions/21b422ce67f920d801901db0/native.ps1 delete mode 100644 .docfx/run-actions/38b60f4b4c1a588bbefe92f1/docker.ps1 delete mode 100644 .docfx/run-actions/38b60f4b4c1a588bbefe92f1/native.ps1 delete mode 100644 .docfx/run-actions/3a1dbfc0e010519636b7091e/docker.ps1 delete mode 100644 .docfx/run-actions/3a1dbfc0e010519636b7091e/native.ps1 delete mode 100644 .docfx/run-actions/3c3b98167b30d6985017ec27/docker.ps1 delete mode 100644 .docfx/run-actions/3c3b98167b30d6985017ec27/native.ps1 delete mode 100644 .docfx/run-actions/45fcccef5fc861315b50c55e/docker.ps1 delete mode 100644 .docfx/run-actions/45fcccef5fc861315b50c55e/native.ps1 delete mode 100644 .docfx/run-actions/4c5e94adccd20cab4da52078/docker.ps1 delete mode 100644 .docfx/run-actions/4c5e94adccd20cab4da52078/native.ps1 delete mode 100644 .docfx/run-actions/513a785b0e0abbe2284270b9/docker.ps1 delete mode 100644 .docfx/run-actions/513a785b0e0abbe2284270b9/native.ps1 delete mode 100644 .docfx/run-actions/515575be5bb7683cac9903a5/docker.ps1 delete mode 100644 .docfx/run-actions/515575be5bb7683cac9903a5/native.ps1 delete mode 100644 .docfx/run-actions/545543e49c6bf054a9e06186/docker.ps1 delete mode 100644 .docfx/run-actions/545543e49c6bf054a9e06186/native.ps1 delete mode 100644 .docfx/run-actions/549c3e82bd0bcb99e9f05bfa/docker.ps1 delete mode 100644 .docfx/run-actions/549c3e82bd0bcb99e9f05bfa/native.ps1 delete mode 100644 .docfx/run-actions/578d467fd203f66cc41b0364/docker.ps1 delete mode 100644 .docfx/run-actions/578d467fd203f66cc41b0364/native.ps1 delete mode 100644 .docfx/run-actions/5e35a33e56470f93afbedf19/docker.ps1 delete mode 100644 .docfx/run-actions/5e35a33e56470f93afbedf19/native.ps1 delete mode 100644 .docfx/run-actions/6a59b7744a7d9994ffc04782/docker.ps1 delete mode 100644 .docfx/run-actions/6a59b7744a7d9994ffc04782/native.ps1 delete mode 100644 .docfx/run-actions/782f24d34260070258f6d164/docker.ps1 delete mode 100644 .docfx/run-actions/782f24d34260070258f6d164/native.ps1 delete mode 100644 .docfx/run-actions/812efaa205554c7bdcd80831/docker.ps1 delete mode 100644 .docfx/run-actions/812efaa205554c7bdcd80831/native.ps1 delete mode 100644 .docfx/run-actions/90a8cd444bd08a0115613e58/docker.ps1 delete mode 100644 .docfx/run-actions/90a8cd444bd08a0115613e58/native.ps1 delete mode 100644 .docfx/run-actions/927ca9f6a3bf893bc52887f4/docker.ps1 delete mode 100644 .docfx/run-actions/927ca9f6a3bf893bc52887f4/native.ps1 delete mode 100644 .docfx/run-actions/947406357e3e26b26a71a538/docker.ps1 delete mode 100644 .docfx/run-actions/947406357e3e26b26a71a538/native.ps1 delete mode 100644 .docfx/run-actions/9a558a9a581c6b11ccb28057/docker.ps1 delete mode 100644 .docfx/run-actions/9a558a9a581c6b11ccb28057/native.ps1 delete mode 100644 .docfx/run-actions/9cdeb08f8ba8f3b361a98c58/docker.ps1 delete mode 100644 .docfx/run-actions/9cdeb08f8ba8f3b361a98c58/native.ps1 delete mode 100644 .docfx/run-actions/a31971b360a8c557b87f6684/docker.ps1 delete mode 100644 .docfx/run-actions/a31971b360a8c557b87f6684/native.ps1 delete mode 100644 .docfx/run-actions/aa478d74f298d8c98e6cd1bf/docker.ps1 delete mode 100644 .docfx/run-actions/aa478d74f298d8c98e6cd1bf/native.ps1 delete mode 100644 .docfx/run-actions/b4149382f121a5ffc3c057df/docker.ps1 delete mode 100644 .docfx/run-actions/b4149382f121a5ffc3c057df/native.ps1 delete mode 100644 .docfx/run-actions/becb2fe7446fc1571dc86953/docker.ps1 delete mode 100644 .docfx/run-actions/becb2fe7446fc1571dc86953/native.ps1 delete mode 100644 .docfx/run-actions/d565f9c40d015b247963fdee/docker.ps1 delete mode 100644 .docfx/run-actions/d565f9c40d015b247963fdee/native.ps1 delete mode 100644 .docfx/run-actions/d71e8ed85f1221cb41308b31/docker.ps1 delete mode 100644 .docfx/run-actions/d71e8ed85f1221cb41308b31/native.ps1 delete mode 100644 .docfx/run-actions/dd2fa1a038dbc1220b366a53/docker.ps1 delete mode 100644 .docfx/run-actions/dd2fa1a038dbc1220b366a53/native.ps1 delete mode 100644 .docfx/run-actions/dfdd064179bf4643e1a0b2bf/docker.ps1 delete mode 100644 .docfx/run-actions/dfdd064179bf4643e1a0b2bf/native.ps1 delete mode 100644 .docfx/run-actions/e3f79d1c0f2fa85276cee2fb/docker.ps1 delete mode 100644 .docfx/run-actions/e3f79d1c0f2fa85276cee2fb/native.ps1 delete mode 100644 .docfx/run-actions/e7dbb5ba733b205469239b03/docker.ps1 delete mode 100644 .docfx/run-actions/e7dbb5ba733b205469239b03/native.ps1 delete mode 100644 .docfx/run-actions/f27f77d838407171b56f9073/docker.ps1 delete mode 100644 .docfx/run-actions/f27f77d838407171b56f9073/native.ps1 delete mode 100644 .docfx/run-actions/f3c0856195727da12ff2925f/docker.ps1 delete mode 100644 .docfx/run-actions/f3c0856195727da12ff2925f/native.ps1 delete mode 100644 .docfx/run-actions/f5ed7c321a52580d7ce11408/docker.ps1 delete mode 100644 .docfx/run-actions/f5ed7c321a52580d7ce11408/native.ps1 delete mode 100644 .docfx/run-actions/ff2e361441bdc3028ab188a9/docker.ps1 delete mode 100644 .docfx/run-actions/ff2e361441bdc3028ab188a9/native.ps1 delete mode 100644 .docfx/run-actions/index.json diff --git a/.docfx/run-actions/00acdae546dce87b654496e1/docker.ps1 b/.docfx/run-actions/00acdae546dce87b654496e1/docker.ps1 deleted file mode 100644 index d35b2e4..0000000 --- a/.docfx/run-actions/00acdae546dce87b654496e1/docker.ps1 +++ /dev/null @@ -1,86 +0,0 @@ -& { -#requires -Version 7.0 -$ErrorActionPreference = 'Stop' -$PSNativeCommandUseErrorActionPreference = $false -$manifest = @' -{ - "dependsOn": [ - "Codebelt.Extensions.Xunit.Hosting.AspNetCore@13.0.0", - "Microsoft.Extensions.Hosting@10.0.15", - "xunit.v3@4.0.3" - ], - "framework": "net10.0", - "frameworkReferences": [ - "Microsoft.AspNetCore.App" - ], - "mode": "test", - "schemaVersion": 1, - "source": "using System.Threading.Tasks;\nusing Codebelt.Extensions.Xunit.Hosting.AspNetCore;\nusing Microsoft.AspNetCore.Builder;\nusing Microsoft.AspNetCore.Http;\nusing Microsoft.Extensions.DependencyInjection;\nusing Microsoft.Extensions.Hosting;\nusing Xunit;\n\nnamespace WebFixtureTests;\n\npublic class MinimalApiTest : MinimalWebHostTest\n{\n public MinimalApiTest(ManagedWebMinimalHostFixture hostFixture, ITestOutputHelper output) : base(hostFixture, output)\n {\n }\n\n protected override void ConfigureHost(IHostApplicationBuilder hb)\n {\n hb.Services.AddFakeHttpContextAccessor();\n }\n\n public override void ConfigureApplication(IApplicationBuilder app)\n {\n app.UseMiddleware();\n }\n}\n\npublic class TestMiddleware(RequestDelegate next)\n{\n public async Task InvokeAsync(HttpContext context)\n {\n context.Response.Headers[\"X-Test\"] = \"true\";\n await next(context);\n }\n}\n\npublic sealed class RunExample(ManagedWebMinimalHostFixture fixture, ITestOutputHelper output) : MinimalApiTest(fixture, output)\n{\n [Fact]\n public async Task BuildsAndInvokesTheConfiguredPipeline()\n {\n var context = new DefaultHttpContext\n {\n RequestServices = Application.ApplicationServices\n };\n await Application.Build()(context);\n Assert.Equal(\"true\", context.Response.Headers[\"X-Test\"].ToString());\n Assert.NotNull(context.RequestServices.GetRequiredService());\n }\n}" -} -'@ -$OutputEncoding = [Text.UTF8Encoding]::new($false) -[Console]::OutputEncoding = $OutputEncoding -$verifyTests = $true -function Assert-CsrunTestOutput([string] $Output) { - $lines = @($Output -split '\r?\n') - $headers = @($lines | Where-Object { $_ -match '^Test run summary: Passed! - .+\)$' }) - if ($headers.Count -ne 1) { throw 'Expected exactly one completed xUnit test summary.' } - $headerIndex = [Array]::IndexOf($lines, $headers[0]) - $summaryLines = @($lines | Select-Object -Skip ($headerIndex + 1) -First 4) - $counts = @{} - foreach ($line in $summaryLines) { - if ($line -match '^\s*(total|failed|succeeded|skipped):\s*(\d+)\s*$') { $counts[$Matches[1]] = [int]$Matches[2] } - } - if ($counts.Count -ne 4) { throw 'The xUnit test summary counts are incomplete or ambiguous.' } - $failed = $counts.failed - $passed = $counts.succeeded - $skipped = $counts.skipped - $total = $counts.total - if ($total -lt 1 -or $passed -lt 1 -or $failed -ne 0 -or $skipped -ne 0 -or $passed -ne $total) { - throw 'Tests must execute at least once, all pass, and none fail or skip.' - } -} -# Downloads and executes the latest stable csrun release with your permissions. -# Source and release history: https://github.com/codebeltnet/csrun -$engineDirectory = Join-Path ([IO.Path]::GetTempPath()) ('csrun-' + [guid]::NewGuid().ToString('N')) -$null = New-Item -ItemType Directory -Path $engineDirectory -$enginePath = Join-Path $engineDirectory 'csrun.ps1' -$process = $null -try { - $release = Invoke-RestMethod 'https://api.github.com/repos/codebeltnet/csrun/releases/latest' - $assets = @($release.assets | Where-Object name -CEQ 'csrun.ps1') - if ($assets.Count -ne 1 -or $assets[0].digest -notmatch '^sha256:[0-9a-f]{64}$') { - throw "csrun release $($release.tag_name) must publish one csrun.ps1 asset with a SHA-256 digest." - } - $asset = $assets[0] - Invoke-WebRequest $asset.browser_download_url -OutFile $enginePath - $actualHash = (Get-FileHash -LiteralPath $enginePath -Algorithm SHA256).Hash - if ("sha256:$actualHash" -ne $asset.digest) { throw "csrun asset checksum mismatch: $actualHash" } -$enginePayload = [Convert]::ToBase64String([IO.File]::ReadAllBytes($enginePath)) -$containerInput = $enginePayload + "`n" + $manifest -$command = ' -$ErrorActionPreference = "Stop" -$enginePath = Join-Path ([IO.Path]::GetTempPath()) ("csrun-release-" + [guid]::NewGuid().ToString("N") + ".ps1") -$engineBytes = [Convert]::FromBase64String([Console]::In.ReadLine()) -[IO.File]::WriteAllBytes($enginePath, $engineBytes) -$manifest = [Console]::In.ReadToEnd() -& $enginePath -ManifestJson $manifest -exit $LASTEXITCODE -' -$output = (@($containerInput | & docker run --rm -i --entrypoint pwsh 'codebeltnet/csrun:10' -NoProfile -NonInteractive -Command $command) -join [Environment]::NewLine) -$process = [pscustomobject]@{ ExitCode = $LASTEXITCODE } -$diagnostics = '' -Write-Output $output -} catch { - [Console]::Error.WriteLine("csrun diagnostics retained in: $engineDirectory") - throw -} finally { - $resolvedTemp = [IO.Path]::TrimEndingDirectorySeparator([IO.Path]::GetFullPath([IO.Path]::GetTempPath())) - $resolvedEngineDirectory = [IO.Path]::GetFullPath($engineDirectory) - if ([IO.Path]::GetDirectoryName($resolvedEngineDirectory) -ne $resolvedTemp -or - [IO.Path]::GetFileName($resolvedEngineDirectory) -cnotmatch '^csrun-[a-f0-9]{32}$') { throw 'Unsafe cleanup path.' } - if ($process -and $process.ExitCode -eq 0) { Remove-Item -LiteralPath $resolvedEngineDirectory -Recurse -Force } -} -if ($process.ExitCode -ne 0) { throw "csrun execution failed with exit code $($process.ExitCode). $diagnostics" } -if ($verifyTests) { Assert-CsrunTestOutput $output } -} \ No newline at end of file diff --git a/.docfx/run-actions/00acdae546dce87b654496e1/native.ps1 b/.docfx/run-actions/00acdae546dce87b654496e1/native.ps1 deleted file mode 100644 index 40d9529..0000000 --- a/.docfx/run-actions/00acdae546dce87b654496e1/native.ps1 +++ /dev/null @@ -1,89 +0,0 @@ -& { -#requires -Version 7.0 -$ErrorActionPreference = 'Stop' -$PSNativeCommandUseErrorActionPreference = $false -$manifest = @' -{ - "dependsOn": [ - "Codebelt.Extensions.Xunit.Hosting.AspNetCore@13.0.0", - "Microsoft.Extensions.Hosting@10.0.15", - "xunit.v3@4.0.3" - ], - "framework": "net10.0", - "frameworkReferences": [ - "Microsoft.AspNetCore.App" - ], - "mode": "test", - "schemaVersion": 1, - "source": "using System.Threading.Tasks;\nusing Codebelt.Extensions.Xunit.Hosting.AspNetCore;\nusing Microsoft.AspNetCore.Builder;\nusing Microsoft.AspNetCore.Http;\nusing Microsoft.Extensions.DependencyInjection;\nusing Microsoft.Extensions.Hosting;\nusing Xunit;\n\nnamespace WebFixtureTests;\n\npublic class MinimalApiTest : MinimalWebHostTest\n{\n public MinimalApiTest(ManagedWebMinimalHostFixture hostFixture, ITestOutputHelper output) : base(hostFixture, output)\n {\n }\n\n protected override void ConfigureHost(IHostApplicationBuilder hb)\n {\n hb.Services.AddFakeHttpContextAccessor();\n }\n\n public override void ConfigureApplication(IApplicationBuilder app)\n {\n app.UseMiddleware();\n }\n}\n\npublic class TestMiddleware(RequestDelegate next)\n{\n public async Task InvokeAsync(HttpContext context)\n {\n context.Response.Headers[\"X-Test\"] = \"true\";\n await next(context);\n }\n}\n\npublic sealed class RunExample(ManagedWebMinimalHostFixture fixture, ITestOutputHelper output) : MinimalApiTest(fixture, output)\n{\n [Fact]\n public async Task BuildsAndInvokesTheConfiguredPipeline()\n {\n var context = new DefaultHttpContext\n {\n RequestServices = Application.ApplicationServices\n };\n await Application.Build()(context);\n Assert.Equal(\"true\", context.Response.Headers[\"X-Test\"].ToString());\n Assert.NotNull(context.RequestServices.GetRequiredService());\n }\n}" -} -'@ -$OutputEncoding = [Text.UTF8Encoding]::new($false) -[Console]::OutputEncoding = $OutputEncoding -$verifyTests = $true -function Assert-CsrunTestOutput([string] $Output) { - $lines = @($Output -split '\r?\n') - $headers = @($lines | Where-Object { $_ -match '^Test run summary: Passed! - .+\)$' }) - if ($headers.Count -ne 1) { throw 'Expected exactly one completed xUnit test summary.' } - $headerIndex = [Array]::IndexOf($lines, $headers[0]) - $summaryLines = @($lines | Select-Object -Skip ($headerIndex + 1) -First 4) - $counts = @{} - foreach ($line in $summaryLines) { - if ($line -match '^\s*(total|failed|succeeded|skipped):\s*(\d+)\s*$') { $counts[$Matches[1]] = [int]$Matches[2] } - } - if ($counts.Count -ne 4) { throw 'The xUnit test summary counts are incomplete or ambiguous.' } - $failed = $counts.failed - $passed = $counts.succeeded - $skipped = $counts.skipped - $total = $counts.total - if ($total -lt 1 -or $passed -lt 1 -or $failed -ne 0 -or $skipped -ne 0 -or $passed -ne $total) { - throw 'Tests must execute at least once, all pass, and none fail or skip.' - } -} -# Downloads and executes the latest stable csrun release with your permissions. -# Source and release history: https://github.com/codebeltnet/csrun -$engineDirectory = Join-Path ([IO.Path]::GetTempPath()) ('csrun-' + [guid]::NewGuid().ToString('N')) -$null = New-Item -ItemType Directory -Path $engineDirectory -$enginePath = Join-Path $engineDirectory 'csrun.ps1' -$process = $null -try { - $release = Invoke-RestMethod 'https://api.github.com/repos/codebeltnet/csrun/releases/latest' - $assets = @($release.assets | Where-Object name -CEQ 'csrun.ps1') - if ($assets.Count -ne 1 -or $assets[0].digest -notmatch '^sha256:[0-9a-f]{64}$') { - throw "csrun release $($release.tag_name) must publish one csrun.ps1 asset with a SHA-256 digest." - } - $asset = $assets[0] - Invoke-WebRequest $asset.browser_download_url -OutFile $enginePath - $actualHash = (Get-FileHash -LiteralPath $enginePath -Algorithm SHA256).Hash - if ("sha256:$actualHash" -ne $asset.digest) { throw "csrun asset checksum mismatch: $actualHash" } -$startInfo = [Diagnostics.ProcessStartInfo]::new('pwsh') -foreach ($argument in @('-NoProfile','-NonInteractive','-File')) { $startInfo.ArgumentList.Add($argument) } -$startInfo.ArgumentList.Add($enginePath) -$startInfo.ArgumentList.Add('-ManifestJson') -$startInfo.ArgumentList.Add($manifest) -$startInfo.RedirectStandardOutput = $true -$startInfo.RedirectStandardError = $true -$startInfo.UseShellExecute = $false -$process = [Diagnostics.Process]::new() -$process.StartInfo = $startInfo -if (-not $process.Start()) { throw 'Could not start csrun.' } -$stdoutTask = $process.StandardOutput.ReadToEndAsync() -$stderrTask = $process.StandardError.ReadToEndAsync() -$process.WaitForExit() -$output = $stdoutTask.GetAwaiter().GetResult() -$diagnostics = $stderrTask.GetAwaiter().GetResult() -Write-Output $output -if ($diagnostics) { [Console]::Error.Write($diagnostics) } -} catch { - [Console]::Error.WriteLine("csrun diagnostics retained in: $engineDirectory") - throw -} finally { - $resolvedTemp = [IO.Path]::TrimEndingDirectorySeparator([IO.Path]::GetFullPath([IO.Path]::GetTempPath())) - $resolvedEngineDirectory = [IO.Path]::GetFullPath($engineDirectory) - if ([IO.Path]::GetDirectoryName($resolvedEngineDirectory) -ne $resolvedTemp -or - [IO.Path]::GetFileName($resolvedEngineDirectory) -cnotmatch '^csrun-[a-f0-9]{32}$') { throw 'Unsafe cleanup path.' } - if ($process -and $process.ExitCode -eq 0) { Remove-Item -LiteralPath $resolvedEngineDirectory -Recurse -Force } -} -if ($process.ExitCode -ne 0) { throw "csrun execution failed with exit code $($process.ExitCode). $diagnostics" } -if ($verifyTests) { Assert-CsrunTestOutput $output } -} \ No newline at end of file diff --git a/.docfx/run-actions/0308118a47b5c02daa7b32be/docker.ps1 b/.docfx/run-actions/0308118a47b5c02daa7b32be/docker.ps1 deleted file mode 100644 index 681fa8d..0000000 --- a/.docfx/run-actions/0308118a47b5c02daa7b32be/docker.ps1 +++ /dev/null @@ -1,82 +0,0 @@ -& { -#requires -Version 7.0 -$ErrorActionPreference = 'Stop' -$PSNativeCommandUseErrorActionPreference = $false -$manifest = @' -{ - "dependsOn": [ - "Codebelt.Extensions.Xunit@13.0.0", - "xunit.v3@4.0.3" - ], - "framework": "net10.0", - "mode": "test", - "schemaVersion": 1, - "source": "using System.Collections.Generic;\nusing Codebelt.Extensions.Xunit;\nusing Xunit;\n\nnamespace Example.Tests;\n\npublic class EnumerableOutputTest : Test\n{\n public EnumerableOutputTest(ITestOutputHelper output) : base(output) { }\n\n [Fact]\n public void ShouldWriteSequenceItems()\n {\n IEnumerable values = new List { 1, 2, 3 };\n TestOutput.WriteLines(values);\n Assert.True(HasTestOutput);\n }\n}" -} -'@ -$OutputEncoding = [Text.UTF8Encoding]::new($false) -[Console]::OutputEncoding = $OutputEncoding -$verifyTests = $true -function Assert-CsrunTestOutput([string] $Output) { - $lines = @($Output -split '\r?\n') - $headers = @($lines | Where-Object { $_ -match '^Test run summary: Passed! - .+\)$' }) - if ($headers.Count -ne 1) { throw 'Expected exactly one completed xUnit test summary.' } - $headerIndex = [Array]::IndexOf($lines, $headers[0]) - $summaryLines = @($lines | Select-Object -Skip ($headerIndex + 1) -First 4) - $counts = @{} - foreach ($line in $summaryLines) { - if ($line -match '^\s*(total|failed|succeeded|skipped):\s*(\d+)\s*$') { $counts[$Matches[1]] = [int]$Matches[2] } - } - if ($counts.Count -ne 4) { throw 'The xUnit test summary counts are incomplete or ambiguous.' } - $failed = $counts.failed - $passed = $counts.succeeded - $skipped = $counts.skipped - $total = $counts.total - if ($total -lt 1 -or $passed -lt 1 -or $failed -ne 0 -or $skipped -ne 0 -or $passed -ne $total) { - throw 'Tests must execute at least once, all pass, and none fail or skip.' - } -} -# Downloads and executes the latest stable csrun release with your permissions. -# Source and release history: https://github.com/codebeltnet/csrun -$engineDirectory = Join-Path ([IO.Path]::GetTempPath()) ('csrun-' + [guid]::NewGuid().ToString('N')) -$null = New-Item -ItemType Directory -Path $engineDirectory -$enginePath = Join-Path $engineDirectory 'csrun.ps1' -$process = $null -try { - $release = Invoke-RestMethod 'https://api.github.com/repos/codebeltnet/csrun/releases/latest' - $assets = @($release.assets | Where-Object name -CEQ 'csrun.ps1') - if ($assets.Count -ne 1 -or $assets[0].digest -notmatch '^sha256:[0-9a-f]{64}$') { - throw "csrun release $($release.tag_name) must publish one csrun.ps1 asset with a SHA-256 digest." - } - $asset = $assets[0] - Invoke-WebRequest $asset.browser_download_url -OutFile $enginePath - $actualHash = (Get-FileHash -LiteralPath $enginePath -Algorithm SHA256).Hash - if ("sha256:$actualHash" -ne $asset.digest) { throw "csrun asset checksum mismatch: $actualHash" } -$enginePayload = [Convert]::ToBase64String([IO.File]::ReadAllBytes($enginePath)) -$containerInput = $enginePayload + "`n" + $manifest -$command = ' -$ErrorActionPreference = "Stop" -$enginePath = Join-Path ([IO.Path]::GetTempPath()) ("csrun-release-" + [guid]::NewGuid().ToString("N") + ".ps1") -$engineBytes = [Convert]::FromBase64String([Console]::In.ReadLine()) -[IO.File]::WriteAllBytes($enginePath, $engineBytes) -$manifest = [Console]::In.ReadToEnd() -& $enginePath -ManifestJson $manifest -exit $LASTEXITCODE -' -$output = (@($containerInput | & docker run --rm -i --entrypoint pwsh 'codebeltnet/csrun:10' -NoProfile -NonInteractive -Command $command) -join [Environment]::NewLine) -$process = [pscustomobject]@{ ExitCode = $LASTEXITCODE } -$diagnostics = '' -Write-Output $output -} catch { - [Console]::Error.WriteLine("csrun diagnostics retained in: $engineDirectory") - throw -} finally { - $resolvedTemp = [IO.Path]::TrimEndingDirectorySeparator([IO.Path]::GetFullPath([IO.Path]::GetTempPath())) - $resolvedEngineDirectory = [IO.Path]::GetFullPath($engineDirectory) - if ([IO.Path]::GetDirectoryName($resolvedEngineDirectory) -ne $resolvedTemp -or - [IO.Path]::GetFileName($resolvedEngineDirectory) -cnotmatch '^csrun-[a-f0-9]{32}$') { throw 'Unsafe cleanup path.' } - if ($process -and $process.ExitCode -eq 0) { Remove-Item -LiteralPath $resolvedEngineDirectory -Recurse -Force } -} -if ($process.ExitCode -ne 0) { throw "csrun execution failed with exit code $($process.ExitCode). $diagnostics" } -if ($verifyTests) { Assert-CsrunTestOutput $output } -} \ No newline at end of file diff --git a/.docfx/run-actions/0308118a47b5c02daa7b32be/native.ps1 b/.docfx/run-actions/0308118a47b5c02daa7b32be/native.ps1 deleted file mode 100644 index 0ca375d..0000000 --- a/.docfx/run-actions/0308118a47b5c02daa7b32be/native.ps1 +++ /dev/null @@ -1,85 +0,0 @@ -& { -#requires -Version 7.0 -$ErrorActionPreference = 'Stop' -$PSNativeCommandUseErrorActionPreference = $false -$manifest = @' -{ - "dependsOn": [ - "Codebelt.Extensions.Xunit@13.0.0", - "xunit.v3@4.0.3" - ], - "framework": "net10.0", - "mode": "test", - "schemaVersion": 1, - "source": "using System.Collections.Generic;\nusing Codebelt.Extensions.Xunit;\nusing Xunit;\n\nnamespace Example.Tests;\n\npublic class EnumerableOutputTest : Test\n{\n public EnumerableOutputTest(ITestOutputHelper output) : base(output) { }\n\n [Fact]\n public void ShouldWriteSequenceItems()\n {\n IEnumerable values = new List { 1, 2, 3 };\n TestOutput.WriteLines(values);\n Assert.True(HasTestOutput);\n }\n}" -} -'@ -$OutputEncoding = [Text.UTF8Encoding]::new($false) -[Console]::OutputEncoding = $OutputEncoding -$verifyTests = $true -function Assert-CsrunTestOutput([string] $Output) { - $lines = @($Output -split '\r?\n') - $headers = @($lines | Where-Object { $_ -match '^Test run summary: Passed! - .+\)$' }) - if ($headers.Count -ne 1) { throw 'Expected exactly one completed xUnit test summary.' } - $headerIndex = [Array]::IndexOf($lines, $headers[0]) - $summaryLines = @($lines | Select-Object -Skip ($headerIndex + 1) -First 4) - $counts = @{} - foreach ($line in $summaryLines) { - if ($line -match '^\s*(total|failed|succeeded|skipped):\s*(\d+)\s*$') { $counts[$Matches[1]] = [int]$Matches[2] } - } - if ($counts.Count -ne 4) { throw 'The xUnit test summary counts are incomplete or ambiguous.' } - $failed = $counts.failed - $passed = $counts.succeeded - $skipped = $counts.skipped - $total = $counts.total - if ($total -lt 1 -or $passed -lt 1 -or $failed -ne 0 -or $skipped -ne 0 -or $passed -ne $total) { - throw 'Tests must execute at least once, all pass, and none fail or skip.' - } -} -# Downloads and executes the latest stable csrun release with your permissions. -# Source and release history: https://github.com/codebeltnet/csrun -$engineDirectory = Join-Path ([IO.Path]::GetTempPath()) ('csrun-' + [guid]::NewGuid().ToString('N')) -$null = New-Item -ItemType Directory -Path $engineDirectory -$enginePath = Join-Path $engineDirectory 'csrun.ps1' -$process = $null -try { - $release = Invoke-RestMethod 'https://api.github.com/repos/codebeltnet/csrun/releases/latest' - $assets = @($release.assets | Where-Object name -CEQ 'csrun.ps1') - if ($assets.Count -ne 1 -or $assets[0].digest -notmatch '^sha256:[0-9a-f]{64}$') { - throw "csrun release $($release.tag_name) must publish one csrun.ps1 asset with a SHA-256 digest." - } - $asset = $assets[0] - Invoke-WebRequest $asset.browser_download_url -OutFile $enginePath - $actualHash = (Get-FileHash -LiteralPath $enginePath -Algorithm SHA256).Hash - if ("sha256:$actualHash" -ne $asset.digest) { throw "csrun asset checksum mismatch: $actualHash" } -$startInfo = [Diagnostics.ProcessStartInfo]::new('pwsh') -foreach ($argument in @('-NoProfile','-NonInteractive','-File')) { $startInfo.ArgumentList.Add($argument) } -$startInfo.ArgumentList.Add($enginePath) -$startInfo.ArgumentList.Add('-ManifestJson') -$startInfo.ArgumentList.Add($manifest) -$startInfo.RedirectStandardOutput = $true -$startInfo.RedirectStandardError = $true -$startInfo.UseShellExecute = $false -$process = [Diagnostics.Process]::new() -$process.StartInfo = $startInfo -if (-not $process.Start()) { throw 'Could not start csrun.' } -$stdoutTask = $process.StandardOutput.ReadToEndAsync() -$stderrTask = $process.StandardError.ReadToEndAsync() -$process.WaitForExit() -$output = $stdoutTask.GetAwaiter().GetResult() -$diagnostics = $stderrTask.GetAwaiter().GetResult() -Write-Output $output -if ($diagnostics) { [Console]::Error.Write($diagnostics) } -} catch { - [Console]::Error.WriteLine("csrun diagnostics retained in: $engineDirectory") - throw -} finally { - $resolvedTemp = [IO.Path]::TrimEndingDirectorySeparator([IO.Path]::GetFullPath([IO.Path]::GetTempPath())) - $resolvedEngineDirectory = [IO.Path]::GetFullPath($engineDirectory) - if ([IO.Path]::GetDirectoryName($resolvedEngineDirectory) -ne $resolvedTemp -or - [IO.Path]::GetFileName($resolvedEngineDirectory) -cnotmatch '^csrun-[a-f0-9]{32}$') { throw 'Unsafe cleanup path.' } - if ($process -and $process.ExitCode -eq 0) { Remove-Item -LiteralPath $resolvedEngineDirectory -Recurse -Force } -} -if ($process.ExitCode -ne 0) { throw "csrun execution failed with exit code $($process.ExitCode). $diagnostics" } -if ($verifyTests) { Assert-CsrunTestOutput $output } -} \ No newline at end of file diff --git a/.docfx/run-actions/038a1c806225b412a6f986c1/docker.ps1 b/.docfx/run-actions/038a1c806225b412a6f986c1/docker.ps1 deleted file mode 100644 index caaabc5..0000000 --- a/.docfx/run-actions/038a1c806225b412a6f986c1/docker.ps1 +++ /dev/null @@ -1,82 +0,0 @@ -& { -#requires -Version 7.0 -$ErrorActionPreference = 'Stop' -$PSNativeCommandUseErrorActionPreference = $false -$manifest = @' -{ - "dependsOn": [ - "Codebelt.Extensions.Xunit@13.0.0", - "xunit.v3@4.0.3" - ], - "framework": "net10.0", - "mode": "test", - "schemaVersion": 1, - "source": "using Codebelt.Extensions.Xunit;\nusing Xunit;\n\nnamespace Example.Tests;\n\npublic class WildcardExampleTest : Test\n{\n public WildcardExampleTest(ITestOutputHelper output) : base(output) { }\n\n [Fact]\n public void ShouldMatchConfiguredPattern()\n {\n var options = new WildcardOptions { ThrowOnNoMatch = true };\n Assert.True(Match(\"cache*\", \"cached\", setup => setup.ThrowOnNoMatch = options.ThrowOnNoMatch));\n }\n}" -} -'@ -$OutputEncoding = [Text.UTF8Encoding]::new($false) -[Console]::OutputEncoding = $OutputEncoding -$verifyTests = $true -function Assert-CsrunTestOutput([string] $Output) { - $lines = @($Output -split '\r?\n') - $headers = @($lines | Where-Object { $_ -match '^Test run summary: Passed! - .+\)$' }) - if ($headers.Count -ne 1) { throw 'Expected exactly one completed xUnit test summary.' } - $headerIndex = [Array]::IndexOf($lines, $headers[0]) - $summaryLines = @($lines | Select-Object -Skip ($headerIndex + 1) -First 4) - $counts = @{} - foreach ($line in $summaryLines) { - if ($line -match '^\s*(total|failed|succeeded|skipped):\s*(\d+)\s*$') { $counts[$Matches[1]] = [int]$Matches[2] } - } - if ($counts.Count -ne 4) { throw 'The xUnit test summary counts are incomplete or ambiguous.' } - $failed = $counts.failed - $passed = $counts.succeeded - $skipped = $counts.skipped - $total = $counts.total - if ($total -lt 1 -or $passed -lt 1 -or $failed -ne 0 -or $skipped -ne 0 -or $passed -ne $total) { - throw 'Tests must execute at least once, all pass, and none fail or skip.' - } -} -# Downloads and executes the latest stable csrun release with your permissions. -# Source and release history: https://github.com/codebeltnet/csrun -$engineDirectory = Join-Path ([IO.Path]::GetTempPath()) ('csrun-' + [guid]::NewGuid().ToString('N')) -$null = New-Item -ItemType Directory -Path $engineDirectory -$enginePath = Join-Path $engineDirectory 'csrun.ps1' -$process = $null -try { - $release = Invoke-RestMethod 'https://api.github.com/repos/codebeltnet/csrun/releases/latest' - $assets = @($release.assets | Where-Object name -CEQ 'csrun.ps1') - if ($assets.Count -ne 1 -or $assets[0].digest -notmatch '^sha256:[0-9a-f]{64}$') { - throw "csrun release $($release.tag_name) must publish one csrun.ps1 asset with a SHA-256 digest." - } - $asset = $assets[0] - Invoke-WebRequest $asset.browser_download_url -OutFile $enginePath - $actualHash = (Get-FileHash -LiteralPath $enginePath -Algorithm SHA256).Hash - if ("sha256:$actualHash" -ne $asset.digest) { throw "csrun asset checksum mismatch: $actualHash" } -$enginePayload = [Convert]::ToBase64String([IO.File]::ReadAllBytes($enginePath)) -$containerInput = $enginePayload + "`n" + $manifest -$command = ' -$ErrorActionPreference = "Stop" -$enginePath = Join-Path ([IO.Path]::GetTempPath()) ("csrun-release-" + [guid]::NewGuid().ToString("N") + ".ps1") -$engineBytes = [Convert]::FromBase64String([Console]::In.ReadLine()) -[IO.File]::WriteAllBytes($enginePath, $engineBytes) -$manifest = [Console]::In.ReadToEnd() -& $enginePath -ManifestJson $manifest -exit $LASTEXITCODE -' -$output = (@($containerInput | & docker run --rm -i --entrypoint pwsh 'codebeltnet/csrun:10' -NoProfile -NonInteractive -Command $command) -join [Environment]::NewLine) -$process = [pscustomobject]@{ ExitCode = $LASTEXITCODE } -$diagnostics = '' -Write-Output $output -} catch { - [Console]::Error.WriteLine("csrun diagnostics retained in: $engineDirectory") - throw -} finally { - $resolvedTemp = [IO.Path]::TrimEndingDirectorySeparator([IO.Path]::GetFullPath([IO.Path]::GetTempPath())) - $resolvedEngineDirectory = [IO.Path]::GetFullPath($engineDirectory) - if ([IO.Path]::GetDirectoryName($resolvedEngineDirectory) -ne $resolvedTemp -or - [IO.Path]::GetFileName($resolvedEngineDirectory) -cnotmatch '^csrun-[a-f0-9]{32}$') { throw 'Unsafe cleanup path.' } - if ($process -and $process.ExitCode -eq 0) { Remove-Item -LiteralPath $resolvedEngineDirectory -Recurse -Force } -} -if ($process.ExitCode -ne 0) { throw "csrun execution failed with exit code $($process.ExitCode). $diagnostics" } -if ($verifyTests) { Assert-CsrunTestOutput $output } -} \ No newline at end of file diff --git a/.docfx/run-actions/038a1c806225b412a6f986c1/native.ps1 b/.docfx/run-actions/038a1c806225b412a6f986c1/native.ps1 deleted file mode 100644 index 6da1af7..0000000 --- a/.docfx/run-actions/038a1c806225b412a6f986c1/native.ps1 +++ /dev/null @@ -1,85 +0,0 @@ -& { -#requires -Version 7.0 -$ErrorActionPreference = 'Stop' -$PSNativeCommandUseErrorActionPreference = $false -$manifest = @' -{ - "dependsOn": [ - "Codebelt.Extensions.Xunit@13.0.0", - "xunit.v3@4.0.3" - ], - "framework": "net10.0", - "mode": "test", - "schemaVersion": 1, - "source": "using Codebelt.Extensions.Xunit;\nusing Xunit;\n\nnamespace Example.Tests;\n\npublic class WildcardExampleTest : Test\n{\n public WildcardExampleTest(ITestOutputHelper output) : base(output) { }\n\n [Fact]\n public void ShouldMatchConfiguredPattern()\n {\n var options = new WildcardOptions { ThrowOnNoMatch = true };\n Assert.True(Match(\"cache*\", \"cached\", setup => setup.ThrowOnNoMatch = options.ThrowOnNoMatch));\n }\n}" -} -'@ -$OutputEncoding = [Text.UTF8Encoding]::new($false) -[Console]::OutputEncoding = $OutputEncoding -$verifyTests = $true -function Assert-CsrunTestOutput([string] $Output) { - $lines = @($Output -split '\r?\n') - $headers = @($lines | Where-Object { $_ -match '^Test run summary: Passed! - .+\)$' }) - if ($headers.Count -ne 1) { throw 'Expected exactly one completed xUnit test summary.' } - $headerIndex = [Array]::IndexOf($lines, $headers[0]) - $summaryLines = @($lines | Select-Object -Skip ($headerIndex + 1) -First 4) - $counts = @{} - foreach ($line in $summaryLines) { - if ($line -match '^\s*(total|failed|succeeded|skipped):\s*(\d+)\s*$') { $counts[$Matches[1]] = [int]$Matches[2] } - } - if ($counts.Count -ne 4) { throw 'The xUnit test summary counts are incomplete or ambiguous.' } - $failed = $counts.failed - $passed = $counts.succeeded - $skipped = $counts.skipped - $total = $counts.total - if ($total -lt 1 -or $passed -lt 1 -or $failed -ne 0 -or $skipped -ne 0 -or $passed -ne $total) { - throw 'Tests must execute at least once, all pass, and none fail or skip.' - } -} -# Downloads and executes the latest stable csrun release with your permissions. -# Source and release history: https://github.com/codebeltnet/csrun -$engineDirectory = Join-Path ([IO.Path]::GetTempPath()) ('csrun-' + [guid]::NewGuid().ToString('N')) -$null = New-Item -ItemType Directory -Path $engineDirectory -$enginePath = Join-Path $engineDirectory 'csrun.ps1' -$process = $null -try { - $release = Invoke-RestMethod 'https://api.github.com/repos/codebeltnet/csrun/releases/latest' - $assets = @($release.assets | Where-Object name -CEQ 'csrun.ps1') - if ($assets.Count -ne 1 -or $assets[0].digest -notmatch '^sha256:[0-9a-f]{64}$') { - throw "csrun release $($release.tag_name) must publish one csrun.ps1 asset with a SHA-256 digest." - } - $asset = $assets[0] - Invoke-WebRequest $asset.browser_download_url -OutFile $enginePath - $actualHash = (Get-FileHash -LiteralPath $enginePath -Algorithm SHA256).Hash - if ("sha256:$actualHash" -ne $asset.digest) { throw "csrun asset checksum mismatch: $actualHash" } -$startInfo = [Diagnostics.ProcessStartInfo]::new('pwsh') -foreach ($argument in @('-NoProfile','-NonInteractive','-File')) { $startInfo.ArgumentList.Add($argument) } -$startInfo.ArgumentList.Add($enginePath) -$startInfo.ArgumentList.Add('-ManifestJson') -$startInfo.ArgumentList.Add($manifest) -$startInfo.RedirectStandardOutput = $true -$startInfo.RedirectStandardError = $true -$startInfo.UseShellExecute = $false -$process = [Diagnostics.Process]::new() -$process.StartInfo = $startInfo -if (-not $process.Start()) { throw 'Could not start csrun.' } -$stdoutTask = $process.StandardOutput.ReadToEndAsync() -$stderrTask = $process.StandardError.ReadToEndAsync() -$process.WaitForExit() -$output = $stdoutTask.GetAwaiter().GetResult() -$diagnostics = $stderrTask.GetAwaiter().GetResult() -Write-Output $output -if ($diagnostics) { [Console]::Error.Write($diagnostics) } -} catch { - [Console]::Error.WriteLine("csrun diagnostics retained in: $engineDirectory") - throw -} finally { - $resolvedTemp = [IO.Path]::TrimEndingDirectorySeparator([IO.Path]::GetFullPath([IO.Path]::GetTempPath())) - $resolvedEngineDirectory = [IO.Path]::GetFullPath($engineDirectory) - if ([IO.Path]::GetDirectoryName($resolvedEngineDirectory) -ne $resolvedTemp -or - [IO.Path]::GetFileName($resolvedEngineDirectory) -cnotmatch '^csrun-[a-f0-9]{32}$') { throw 'Unsafe cleanup path.' } - if ($process -and $process.ExitCode -eq 0) { Remove-Item -LiteralPath $resolvedEngineDirectory -Recurse -Force } -} -if ($process.ExitCode -ne 0) { throw "csrun execution failed with exit code $($process.ExitCode). $diagnostics" } -if ($verifyTests) { Assert-CsrunTestOutput $output } -} \ No newline at end of file diff --git a/.docfx/run-actions/08b911ef79f0b743282e37c9/docker.ps1 b/.docfx/run-actions/08b911ef79f0b743282e37c9/docker.ps1 deleted file mode 100644 index b7058b7..0000000 --- a/.docfx/run-actions/08b911ef79f0b743282e37c9/docker.ps1 +++ /dev/null @@ -1,85 +0,0 @@ -& { -#requires -Version 7.0 -$ErrorActionPreference = 'Stop' -$PSNativeCommandUseErrorActionPreference = $false -$manifest = @' -{ - "dependsOn": [ - "Codebelt.Extensions.Xunit.Hosting.AspNetCore@13.0.0" - ], - "framework": "net10.0", - "frameworkReferences": [ - "Microsoft.AspNetCore.App" - ], - "mode": "console", - "schemaVersion": 1, - "sdk": "Microsoft.NET.Sdk.Web", - "source": "using System;\nusing Codebelt.Extensions.Xunit.Hosting.AspNetCore.Http.Features;\n\nnamespace WebFixtureTests;\n\npublic class ResponseFeatureExample\n{\n public void Demonstrate()\n {\n var response = new FakeHttpResponseFeature();\n Console.WriteLine(response.StatusCode);\n }\n}\n\ninternal static class RunExample\n{\n static void Main()\n {\n new ResponseFeatureExample().Demonstrate();\n }\n}" -} -'@ -$OutputEncoding = [Text.UTF8Encoding]::new($false) -[Console]::OutputEncoding = $OutputEncoding -$verifyTests = $false -function Assert-CsrunTestOutput([string] $Output) { - $lines = @($Output -split '\r?\n') - $headers = @($lines | Where-Object { $_ -match '^Test run summary: Passed! - .+\)$' }) - if ($headers.Count -ne 1) { throw 'Expected exactly one completed xUnit test summary.' } - $headerIndex = [Array]::IndexOf($lines, $headers[0]) - $summaryLines = @($lines | Select-Object -Skip ($headerIndex + 1) -First 4) - $counts = @{} - foreach ($line in $summaryLines) { - if ($line -match '^\s*(total|failed|succeeded|skipped):\s*(\d+)\s*$') { $counts[$Matches[1]] = [int]$Matches[2] } - } - if ($counts.Count -ne 4) { throw 'The xUnit test summary counts are incomplete or ambiguous.' } - $failed = $counts.failed - $passed = $counts.succeeded - $skipped = $counts.skipped - $total = $counts.total - if ($total -lt 1 -or $passed -lt 1 -or $failed -ne 0 -or $skipped -ne 0 -or $passed -ne $total) { - throw 'Tests must execute at least once, all pass, and none fail or skip.' - } -} -# Downloads and executes the latest stable csrun release with your permissions. -# Source and release history: https://github.com/codebeltnet/csrun -$engineDirectory = Join-Path ([IO.Path]::GetTempPath()) ('csrun-' + [guid]::NewGuid().ToString('N')) -$null = New-Item -ItemType Directory -Path $engineDirectory -$enginePath = Join-Path $engineDirectory 'csrun.ps1' -$process = $null -try { - $release = Invoke-RestMethod 'https://api.github.com/repos/codebeltnet/csrun/releases/latest' - $assets = @($release.assets | Where-Object name -CEQ 'csrun.ps1') - if ($assets.Count -ne 1 -or $assets[0].digest -notmatch '^sha256:[0-9a-f]{64}$') { - throw "csrun release $($release.tag_name) must publish one csrun.ps1 asset with a SHA-256 digest." - } - $asset = $assets[0] - Invoke-WebRequest $asset.browser_download_url -OutFile $enginePath - $actualHash = (Get-FileHash -LiteralPath $enginePath -Algorithm SHA256).Hash - if ("sha256:$actualHash" -ne $asset.digest) { throw "csrun asset checksum mismatch: $actualHash" } -$enginePayload = [Convert]::ToBase64String([IO.File]::ReadAllBytes($enginePath)) -$containerInput = $enginePayload + "`n" + $manifest -$command = ' -$ErrorActionPreference = "Stop" -$enginePath = Join-Path ([IO.Path]::GetTempPath()) ("csrun-release-" + [guid]::NewGuid().ToString("N") + ".ps1") -$engineBytes = [Convert]::FromBase64String([Console]::In.ReadLine()) -[IO.File]::WriteAllBytes($enginePath, $engineBytes) -$manifest = [Console]::In.ReadToEnd() -& $enginePath -ManifestJson $manifest -exit $LASTEXITCODE -' -$output = (@($containerInput | & docker run --rm -i --entrypoint pwsh 'codebeltnet/csrun:10' -NoProfile -NonInteractive -Command $command) -join [Environment]::NewLine) -$process = [pscustomobject]@{ ExitCode = $LASTEXITCODE } -$diagnostics = '' -Write-Output $output -} catch { - [Console]::Error.WriteLine("csrun diagnostics retained in: $engineDirectory") - throw -} finally { - $resolvedTemp = [IO.Path]::TrimEndingDirectorySeparator([IO.Path]::GetFullPath([IO.Path]::GetTempPath())) - $resolvedEngineDirectory = [IO.Path]::GetFullPath($engineDirectory) - if ([IO.Path]::GetDirectoryName($resolvedEngineDirectory) -ne $resolvedTemp -or - [IO.Path]::GetFileName($resolvedEngineDirectory) -cnotmatch '^csrun-[a-f0-9]{32}$') { throw 'Unsafe cleanup path.' } - if ($process -and $process.ExitCode -eq 0) { Remove-Item -LiteralPath $resolvedEngineDirectory -Recurse -Force } -} -if ($process.ExitCode -ne 0) { throw "csrun execution failed with exit code $($process.ExitCode). $diagnostics" } -if ($verifyTests) { Assert-CsrunTestOutput $output } -} \ No newline at end of file diff --git a/.docfx/run-actions/08b911ef79f0b743282e37c9/native.ps1 b/.docfx/run-actions/08b911ef79f0b743282e37c9/native.ps1 deleted file mode 100644 index 3bbc696..0000000 --- a/.docfx/run-actions/08b911ef79f0b743282e37c9/native.ps1 +++ /dev/null @@ -1,88 +0,0 @@ -& { -#requires -Version 7.0 -$ErrorActionPreference = 'Stop' -$PSNativeCommandUseErrorActionPreference = $false -$manifest = @' -{ - "dependsOn": [ - "Codebelt.Extensions.Xunit.Hosting.AspNetCore@13.0.0" - ], - "framework": "net10.0", - "frameworkReferences": [ - "Microsoft.AspNetCore.App" - ], - "mode": "console", - "schemaVersion": 1, - "sdk": "Microsoft.NET.Sdk.Web", - "source": "using System;\nusing Codebelt.Extensions.Xunit.Hosting.AspNetCore.Http.Features;\n\nnamespace WebFixtureTests;\n\npublic class ResponseFeatureExample\n{\n public void Demonstrate()\n {\n var response = new FakeHttpResponseFeature();\n Console.WriteLine(response.StatusCode);\n }\n}\n\ninternal static class RunExample\n{\n static void Main()\n {\n new ResponseFeatureExample().Demonstrate();\n }\n}" -} -'@ -$OutputEncoding = [Text.UTF8Encoding]::new($false) -[Console]::OutputEncoding = $OutputEncoding -$verifyTests = $false -function Assert-CsrunTestOutput([string] $Output) { - $lines = @($Output -split '\r?\n') - $headers = @($lines | Where-Object { $_ -match '^Test run summary: Passed! - .+\)$' }) - if ($headers.Count -ne 1) { throw 'Expected exactly one completed xUnit test summary.' } - $headerIndex = [Array]::IndexOf($lines, $headers[0]) - $summaryLines = @($lines | Select-Object -Skip ($headerIndex + 1) -First 4) - $counts = @{} - foreach ($line in $summaryLines) { - if ($line -match '^\s*(total|failed|succeeded|skipped):\s*(\d+)\s*$') { $counts[$Matches[1]] = [int]$Matches[2] } - } - if ($counts.Count -ne 4) { throw 'The xUnit test summary counts are incomplete or ambiguous.' } - $failed = $counts.failed - $passed = $counts.succeeded - $skipped = $counts.skipped - $total = $counts.total - if ($total -lt 1 -or $passed -lt 1 -or $failed -ne 0 -or $skipped -ne 0 -or $passed -ne $total) { - throw 'Tests must execute at least once, all pass, and none fail or skip.' - } -} -# Downloads and executes the latest stable csrun release with your permissions. -# Source and release history: https://github.com/codebeltnet/csrun -$engineDirectory = Join-Path ([IO.Path]::GetTempPath()) ('csrun-' + [guid]::NewGuid().ToString('N')) -$null = New-Item -ItemType Directory -Path $engineDirectory -$enginePath = Join-Path $engineDirectory 'csrun.ps1' -$process = $null -try { - $release = Invoke-RestMethod 'https://api.github.com/repos/codebeltnet/csrun/releases/latest' - $assets = @($release.assets | Where-Object name -CEQ 'csrun.ps1') - if ($assets.Count -ne 1 -or $assets[0].digest -notmatch '^sha256:[0-9a-f]{64}$') { - throw "csrun release $($release.tag_name) must publish one csrun.ps1 asset with a SHA-256 digest." - } - $asset = $assets[0] - Invoke-WebRequest $asset.browser_download_url -OutFile $enginePath - $actualHash = (Get-FileHash -LiteralPath $enginePath -Algorithm SHA256).Hash - if ("sha256:$actualHash" -ne $asset.digest) { throw "csrun asset checksum mismatch: $actualHash" } -$startInfo = [Diagnostics.ProcessStartInfo]::new('pwsh') -foreach ($argument in @('-NoProfile','-NonInteractive','-File')) { $startInfo.ArgumentList.Add($argument) } -$startInfo.ArgumentList.Add($enginePath) -$startInfo.ArgumentList.Add('-ManifestJson') -$startInfo.ArgumentList.Add($manifest) -$startInfo.RedirectStandardOutput = $true -$startInfo.RedirectStandardError = $true -$startInfo.UseShellExecute = $false -$process = [Diagnostics.Process]::new() -$process.StartInfo = $startInfo -if (-not $process.Start()) { throw 'Could not start csrun.' } -$stdoutTask = $process.StandardOutput.ReadToEndAsync() -$stderrTask = $process.StandardError.ReadToEndAsync() -$process.WaitForExit() -$output = $stdoutTask.GetAwaiter().GetResult() -$diagnostics = $stderrTask.GetAwaiter().GetResult() -Write-Output $output -if ($diagnostics) { [Console]::Error.Write($diagnostics) } -} catch { - [Console]::Error.WriteLine("csrun diagnostics retained in: $engineDirectory") - throw -} finally { - $resolvedTemp = [IO.Path]::TrimEndingDirectorySeparator([IO.Path]::GetFullPath([IO.Path]::GetTempPath())) - $resolvedEngineDirectory = [IO.Path]::GetFullPath($engineDirectory) - if ([IO.Path]::GetDirectoryName($resolvedEngineDirectory) -ne $resolvedTemp -or - [IO.Path]::GetFileName($resolvedEngineDirectory) -cnotmatch '^csrun-[a-f0-9]{32}$') { throw 'Unsafe cleanup path.' } - if ($process -and $process.ExitCode -eq 0) { Remove-Item -LiteralPath $resolvedEngineDirectory -Recurse -Force } -} -if ($process.ExitCode -ne 0) { throw "csrun execution failed with exit code $($process.ExitCode). $diagnostics" } -if ($verifyTests) { Assert-CsrunTestOutput $output } -} \ No newline at end of file diff --git a/.docfx/run-actions/10457ac34cce1cbadb26aee1/docker.ps1 b/.docfx/run-actions/10457ac34cce1cbadb26aee1/docker.ps1 deleted file mode 100644 index 44986ad..0000000 --- a/.docfx/run-actions/10457ac34cce1cbadb26aee1/docker.ps1 +++ /dev/null @@ -1,82 +0,0 @@ -& { -#requires -Version 7.0 -$ErrorActionPreference = 'Stop' -$PSNativeCommandUseErrorActionPreference = $false -$manifest = @' -{ - "dependsOn": [ - "Codebelt.Extensions.Xunit@13.0.0", - "xunit.v3@4.0.3" - ], - "framework": "net10.0", - "mode": "test", - "schemaVersion": 1, - "source": "using Codebelt.Extensions.Xunit;\nusing Xunit;\n\nnamespace Example.Tests;\n\npublic class ArrayOutputTest : Test\n{\n public ArrayOutputTest(ITestOutputHelper output) : base(output) { }\n\n [Fact]\n public void ShouldWriteArrayItems()\n {\n TestOutput.WriteLines(new int[] { 1, 2, 3 });\n Assert.True(HasTestOutput);\n }\n}" -} -'@ -$OutputEncoding = [Text.UTF8Encoding]::new($false) -[Console]::OutputEncoding = $OutputEncoding -$verifyTests = $true -function Assert-CsrunTestOutput([string] $Output) { - $lines = @($Output -split '\r?\n') - $headers = @($lines | Where-Object { $_ -match '^Test run summary: Passed! - .+\)$' }) - if ($headers.Count -ne 1) { throw 'Expected exactly one completed xUnit test summary.' } - $headerIndex = [Array]::IndexOf($lines, $headers[0]) - $summaryLines = @($lines | Select-Object -Skip ($headerIndex + 1) -First 4) - $counts = @{} - foreach ($line in $summaryLines) { - if ($line -match '^\s*(total|failed|succeeded|skipped):\s*(\d+)\s*$') { $counts[$Matches[1]] = [int]$Matches[2] } - } - if ($counts.Count -ne 4) { throw 'The xUnit test summary counts are incomplete or ambiguous.' } - $failed = $counts.failed - $passed = $counts.succeeded - $skipped = $counts.skipped - $total = $counts.total - if ($total -lt 1 -or $passed -lt 1 -or $failed -ne 0 -or $skipped -ne 0 -or $passed -ne $total) { - throw 'Tests must execute at least once, all pass, and none fail or skip.' - } -} -# Downloads and executes the latest stable csrun release with your permissions. -# Source and release history: https://github.com/codebeltnet/csrun -$engineDirectory = Join-Path ([IO.Path]::GetTempPath()) ('csrun-' + [guid]::NewGuid().ToString('N')) -$null = New-Item -ItemType Directory -Path $engineDirectory -$enginePath = Join-Path $engineDirectory 'csrun.ps1' -$process = $null -try { - $release = Invoke-RestMethod 'https://api.github.com/repos/codebeltnet/csrun/releases/latest' - $assets = @($release.assets | Where-Object name -CEQ 'csrun.ps1') - if ($assets.Count -ne 1 -or $assets[0].digest -notmatch '^sha256:[0-9a-f]{64}$') { - throw "csrun release $($release.tag_name) must publish one csrun.ps1 asset with a SHA-256 digest." - } - $asset = $assets[0] - Invoke-WebRequest $asset.browser_download_url -OutFile $enginePath - $actualHash = (Get-FileHash -LiteralPath $enginePath -Algorithm SHA256).Hash - if ("sha256:$actualHash" -ne $asset.digest) { throw "csrun asset checksum mismatch: $actualHash" } -$enginePayload = [Convert]::ToBase64String([IO.File]::ReadAllBytes($enginePath)) -$containerInput = $enginePayload + "`n" + $manifest -$command = ' -$ErrorActionPreference = "Stop" -$enginePath = Join-Path ([IO.Path]::GetTempPath()) ("csrun-release-" + [guid]::NewGuid().ToString("N") + ".ps1") -$engineBytes = [Convert]::FromBase64String([Console]::In.ReadLine()) -[IO.File]::WriteAllBytes($enginePath, $engineBytes) -$manifest = [Console]::In.ReadToEnd() -& $enginePath -ManifestJson $manifest -exit $LASTEXITCODE -' -$output = (@($containerInput | & docker run --rm -i --entrypoint pwsh 'codebeltnet/csrun:10' -NoProfile -NonInteractive -Command $command) -join [Environment]::NewLine) -$process = [pscustomobject]@{ ExitCode = $LASTEXITCODE } -$diagnostics = '' -Write-Output $output -} catch { - [Console]::Error.WriteLine("csrun diagnostics retained in: $engineDirectory") - throw -} finally { - $resolvedTemp = [IO.Path]::TrimEndingDirectorySeparator([IO.Path]::GetFullPath([IO.Path]::GetTempPath())) - $resolvedEngineDirectory = [IO.Path]::GetFullPath($engineDirectory) - if ([IO.Path]::GetDirectoryName($resolvedEngineDirectory) -ne $resolvedTemp -or - [IO.Path]::GetFileName($resolvedEngineDirectory) -cnotmatch '^csrun-[a-f0-9]{32}$') { throw 'Unsafe cleanup path.' } - if ($process -and $process.ExitCode -eq 0) { Remove-Item -LiteralPath $resolvedEngineDirectory -Recurse -Force } -} -if ($process.ExitCode -ne 0) { throw "csrun execution failed with exit code $($process.ExitCode). $diagnostics" } -if ($verifyTests) { Assert-CsrunTestOutput $output } -} \ No newline at end of file diff --git a/.docfx/run-actions/10457ac34cce1cbadb26aee1/native.ps1 b/.docfx/run-actions/10457ac34cce1cbadb26aee1/native.ps1 deleted file mode 100644 index 79e8752..0000000 --- a/.docfx/run-actions/10457ac34cce1cbadb26aee1/native.ps1 +++ /dev/null @@ -1,85 +0,0 @@ -& { -#requires -Version 7.0 -$ErrorActionPreference = 'Stop' -$PSNativeCommandUseErrorActionPreference = $false -$manifest = @' -{ - "dependsOn": [ - "Codebelt.Extensions.Xunit@13.0.0", - "xunit.v3@4.0.3" - ], - "framework": "net10.0", - "mode": "test", - "schemaVersion": 1, - "source": "using Codebelt.Extensions.Xunit;\nusing Xunit;\n\nnamespace Example.Tests;\n\npublic class ArrayOutputTest : Test\n{\n public ArrayOutputTest(ITestOutputHelper output) : base(output) { }\n\n [Fact]\n public void ShouldWriteArrayItems()\n {\n TestOutput.WriteLines(new int[] { 1, 2, 3 });\n Assert.True(HasTestOutput);\n }\n}" -} -'@ -$OutputEncoding = [Text.UTF8Encoding]::new($false) -[Console]::OutputEncoding = $OutputEncoding -$verifyTests = $true -function Assert-CsrunTestOutput([string] $Output) { - $lines = @($Output -split '\r?\n') - $headers = @($lines | Where-Object { $_ -match '^Test run summary: Passed! - .+\)$' }) - if ($headers.Count -ne 1) { throw 'Expected exactly one completed xUnit test summary.' } - $headerIndex = [Array]::IndexOf($lines, $headers[0]) - $summaryLines = @($lines | Select-Object -Skip ($headerIndex + 1) -First 4) - $counts = @{} - foreach ($line in $summaryLines) { - if ($line -match '^\s*(total|failed|succeeded|skipped):\s*(\d+)\s*$') { $counts[$Matches[1]] = [int]$Matches[2] } - } - if ($counts.Count -ne 4) { throw 'The xUnit test summary counts are incomplete or ambiguous.' } - $failed = $counts.failed - $passed = $counts.succeeded - $skipped = $counts.skipped - $total = $counts.total - if ($total -lt 1 -or $passed -lt 1 -or $failed -ne 0 -or $skipped -ne 0 -or $passed -ne $total) { - throw 'Tests must execute at least once, all pass, and none fail or skip.' - } -} -# Downloads and executes the latest stable csrun release with your permissions. -# Source and release history: https://github.com/codebeltnet/csrun -$engineDirectory = Join-Path ([IO.Path]::GetTempPath()) ('csrun-' + [guid]::NewGuid().ToString('N')) -$null = New-Item -ItemType Directory -Path $engineDirectory -$enginePath = Join-Path $engineDirectory 'csrun.ps1' -$process = $null -try { - $release = Invoke-RestMethod 'https://api.github.com/repos/codebeltnet/csrun/releases/latest' - $assets = @($release.assets | Where-Object name -CEQ 'csrun.ps1') - if ($assets.Count -ne 1 -or $assets[0].digest -notmatch '^sha256:[0-9a-f]{64}$') { - throw "csrun release $($release.tag_name) must publish one csrun.ps1 asset with a SHA-256 digest." - } - $asset = $assets[0] - Invoke-WebRequest $asset.browser_download_url -OutFile $enginePath - $actualHash = (Get-FileHash -LiteralPath $enginePath -Algorithm SHA256).Hash - if ("sha256:$actualHash" -ne $asset.digest) { throw "csrun asset checksum mismatch: $actualHash" } -$startInfo = [Diagnostics.ProcessStartInfo]::new('pwsh') -foreach ($argument in @('-NoProfile','-NonInteractive','-File')) { $startInfo.ArgumentList.Add($argument) } -$startInfo.ArgumentList.Add($enginePath) -$startInfo.ArgumentList.Add('-ManifestJson') -$startInfo.ArgumentList.Add($manifest) -$startInfo.RedirectStandardOutput = $true -$startInfo.RedirectStandardError = $true -$startInfo.UseShellExecute = $false -$process = [Diagnostics.Process]::new() -$process.StartInfo = $startInfo -if (-not $process.Start()) { throw 'Could not start csrun.' } -$stdoutTask = $process.StandardOutput.ReadToEndAsync() -$stderrTask = $process.StandardError.ReadToEndAsync() -$process.WaitForExit() -$output = $stdoutTask.GetAwaiter().GetResult() -$diagnostics = $stderrTask.GetAwaiter().GetResult() -Write-Output $output -if ($diagnostics) { [Console]::Error.Write($diagnostics) } -} catch { - [Console]::Error.WriteLine("csrun diagnostics retained in: $engineDirectory") - throw -} finally { - $resolvedTemp = [IO.Path]::TrimEndingDirectorySeparator([IO.Path]::GetFullPath([IO.Path]::GetTempPath())) - $resolvedEngineDirectory = [IO.Path]::GetFullPath($engineDirectory) - if ([IO.Path]::GetDirectoryName($resolvedEngineDirectory) -ne $resolvedTemp -or - [IO.Path]::GetFileName($resolvedEngineDirectory) -cnotmatch '^csrun-[a-f0-9]{32}$') { throw 'Unsafe cleanup path.' } - if ($process -and $process.ExitCode -eq 0) { Remove-Item -LiteralPath $resolvedEngineDirectory -Recurse -Force } -} -if ($process.ExitCode -ne 0) { throw "csrun execution failed with exit code $($process.ExitCode). $diagnostics" } -if ($verifyTests) { Assert-CsrunTestOutput $output } -} \ No newline at end of file diff --git a/.docfx/run-actions/1130af506703020850fdadea/docker.ps1 b/.docfx/run-actions/1130af506703020850fdadea/docker.ps1 deleted file mode 100644 index 1c8d571..0000000 --- a/.docfx/run-actions/1130af506703020850fdadea/docker.ps1 +++ /dev/null @@ -1,83 +0,0 @@ -& { -#requires -Version 7.0 -$ErrorActionPreference = 'Stop' -$PSNativeCommandUseErrorActionPreference = $false -$manifest = @' -{ - "dependsOn": [ - "Codebelt.Extensions.Xunit.Hosting@13.0.0", - "Microsoft.Extensions.Hosting@10.0.15", - "xunit.v3@4.0.3" - ], - "framework": "net10.0", - "mode": "test", - "schemaVersion": 1, - "source": "using Codebelt.Extensions.Xunit.Hosting;\nusing Xunit;\n\nnamespace HostFixtureTests;\n\npublic class HostStateGuard\n{\n public bool EnsureFixtureIsReady(IGenericHostFixture fixture)\n {\n return fixture.HasValidState();\n }\n}\n\npublic sealed class RunExample\n{\n [Fact]\n public void ExercisesExample()\n {\n using var fixture = new ManagedHostFixture();\n Assert.False(new HostStateGuard().EnsureFixtureIsReady(fixture));\n using var app = HostTestFactory.Create(hostFixture: fixture);\n Assert.True(new HostStateGuard().EnsureFixtureIsReady(fixture));\n }\n}" -} -'@ -$OutputEncoding = [Text.UTF8Encoding]::new($false) -[Console]::OutputEncoding = $OutputEncoding -$verifyTests = $true -function Assert-CsrunTestOutput([string] $Output) { - $lines = @($Output -split '\r?\n') - $headers = @($lines | Where-Object { $_ -match '^Test run summary: Passed! - .+\)$' }) - if ($headers.Count -ne 1) { throw 'Expected exactly one completed xUnit test summary.' } - $headerIndex = [Array]::IndexOf($lines, $headers[0]) - $summaryLines = @($lines | Select-Object -Skip ($headerIndex + 1) -First 4) - $counts = @{} - foreach ($line in $summaryLines) { - if ($line -match '^\s*(total|failed|succeeded|skipped):\s*(\d+)\s*$') { $counts[$Matches[1]] = [int]$Matches[2] } - } - if ($counts.Count -ne 4) { throw 'The xUnit test summary counts are incomplete or ambiguous.' } - $failed = $counts.failed - $passed = $counts.succeeded - $skipped = $counts.skipped - $total = $counts.total - if ($total -lt 1 -or $passed -lt 1 -or $failed -ne 0 -or $skipped -ne 0 -or $passed -ne $total) { - throw 'Tests must execute at least once, all pass, and none fail or skip.' - } -} -# Downloads and executes the latest stable csrun release with your permissions. -# Source and release history: https://github.com/codebeltnet/csrun -$engineDirectory = Join-Path ([IO.Path]::GetTempPath()) ('csrun-' + [guid]::NewGuid().ToString('N')) -$null = New-Item -ItemType Directory -Path $engineDirectory -$enginePath = Join-Path $engineDirectory 'csrun.ps1' -$process = $null -try { - $release = Invoke-RestMethod 'https://api.github.com/repos/codebeltnet/csrun/releases/latest' - $assets = @($release.assets | Where-Object name -CEQ 'csrun.ps1') - if ($assets.Count -ne 1 -or $assets[0].digest -notmatch '^sha256:[0-9a-f]{64}$') { - throw "csrun release $($release.tag_name) must publish one csrun.ps1 asset with a SHA-256 digest." - } - $asset = $assets[0] - Invoke-WebRequest $asset.browser_download_url -OutFile $enginePath - $actualHash = (Get-FileHash -LiteralPath $enginePath -Algorithm SHA256).Hash - if ("sha256:$actualHash" -ne $asset.digest) { throw "csrun asset checksum mismatch: $actualHash" } -$enginePayload = [Convert]::ToBase64String([IO.File]::ReadAllBytes($enginePath)) -$containerInput = $enginePayload + "`n" + $manifest -$command = ' -$ErrorActionPreference = "Stop" -$enginePath = Join-Path ([IO.Path]::GetTempPath()) ("csrun-release-" + [guid]::NewGuid().ToString("N") + ".ps1") -$engineBytes = [Convert]::FromBase64String([Console]::In.ReadLine()) -[IO.File]::WriteAllBytes($enginePath, $engineBytes) -$manifest = [Console]::In.ReadToEnd() -& $enginePath -ManifestJson $manifest -exit $LASTEXITCODE -' -$output = (@($containerInput | & docker run --rm -i --entrypoint pwsh 'codebeltnet/csrun:10' -NoProfile -NonInteractive -Command $command) -join [Environment]::NewLine) -$process = [pscustomobject]@{ ExitCode = $LASTEXITCODE } -$diagnostics = '' -Write-Output $output -} catch { - [Console]::Error.WriteLine("csrun diagnostics retained in: $engineDirectory") - throw -} finally { - $resolvedTemp = [IO.Path]::TrimEndingDirectorySeparator([IO.Path]::GetFullPath([IO.Path]::GetTempPath())) - $resolvedEngineDirectory = [IO.Path]::GetFullPath($engineDirectory) - if ([IO.Path]::GetDirectoryName($resolvedEngineDirectory) -ne $resolvedTemp -or - [IO.Path]::GetFileName($resolvedEngineDirectory) -cnotmatch '^csrun-[a-f0-9]{32}$') { throw 'Unsafe cleanup path.' } - if ($process -and $process.ExitCode -eq 0) { Remove-Item -LiteralPath $resolvedEngineDirectory -Recurse -Force } -} -if ($process.ExitCode -ne 0) { throw "csrun execution failed with exit code $($process.ExitCode). $diagnostics" } -if ($verifyTests) { Assert-CsrunTestOutput $output } -} \ No newline at end of file diff --git a/.docfx/run-actions/1130af506703020850fdadea/native.ps1 b/.docfx/run-actions/1130af506703020850fdadea/native.ps1 deleted file mode 100644 index 5c7c566..0000000 --- a/.docfx/run-actions/1130af506703020850fdadea/native.ps1 +++ /dev/null @@ -1,86 +0,0 @@ -& { -#requires -Version 7.0 -$ErrorActionPreference = 'Stop' -$PSNativeCommandUseErrorActionPreference = $false -$manifest = @' -{ - "dependsOn": [ - "Codebelt.Extensions.Xunit.Hosting@13.0.0", - "Microsoft.Extensions.Hosting@10.0.15", - "xunit.v3@4.0.3" - ], - "framework": "net10.0", - "mode": "test", - "schemaVersion": 1, - "source": "using Codebelt.Extensions.Xunit.Hosting;\nusing Xunit;\n\nnamespace HostFixtureTests;\n\npublic class HostStateGuard\n{\n public bool EnsureFixtureIsReady(IGenericHostFixture fixture)\n {\n return fixture.HasValidState();\n }\n}\n\npublic sealed class RunExample\n{\n [Fact]\n public void ExercisesExample()\n {\n using var fixture = new ManagedHostFixture();\n Assert.False(new HostStateGuard().EnsureFixtureIsReady(fixture));\n using var app = HostTestFactory.Create(hostFixture: fixture);\n Assert.True(new HostStateGuard().EnsureFixtureIsReady(fixture));\n }\n}" -} -'@ -$OutputEncoding = [Text.UTF8Encoding]::new($false) -[Console]::OutputEncoding = $OutputEncoding -$verifyTests = $true -function Assert-CsrunTestOutput([string] $Output) { - $lines = @($Output -split '\r?\n') - $headers = @($lines | Where-Object { $_ -match '^Test run summary: Passed! - .+\)$' }) - if ($headers.Count -ne 1) { throw 'Expected exactly one completed xUnit test summary.' } - $headerIndex = [Array]::IndexOf($lines, $headers[0]) - $summaryLines = @($lines | Select-Object -Skip ($headerIndex + 1) -First 4) - $counts = @{} - foreach ($line in $summaryLines) { - if ($line -match '^\s*(total|failed|succeeded|skipped):\s*(\d+)\s*$') { $counts[$Matches[1]] = [int]$Matches[2] } - } - if ($counts.Count -ne 4) { throw 'The xUnit test summary counts are incomplete or ambiguous.' } - $failed = $counts.failed - $passed = $counts.succeeded - $skipped = $counts.skipped - $total = $counts.total - if ($total -lt 1 -or $passed -lt 1 -or $failed -ne 0 -or $skipped -ne 0 -or $passed -ne $total) { - throw 'Tests must execute at least once, all pass, and none fail or skip.' - } -} -# Downloads and executes the latest stable csrun release with your permissions. -# Source and release history: https://github.com/codebeltnet/csrun -$engineDirectory = Join-Path ([IO.Path]::GetTempPath()) ('csrun-' + [guid]::NewGuid().ToString('N')) -$null = New-Item -ItemType Directory -Path $engineDirectory -$enginePath = Join-Path $engineDirectory 'csrun.ps1' -$process = $null -try { - $release = Invoke-RestMethod 'https://api.github.com/repos/codebeltnet/csrun/releases/latest' - $assets = @($release.assets | Where-Object name -CEQ 'csrun.ps1') - if ($assets.Count -ne 1 -or $assets[0].digest -notmatch '^sha256:[0-9a-f]{64}$') { - throw "csrun release $($release.tag_name) must publish one csrun.ps1 asset with a SHA-256 digest." - } - $asset = $assets[0] - Invoke-WebRequest $asset.browser_download_url -OutFile $enginePath - $actualHash = (Get-FileHash -LiteralPath $enginePath -Algorithm SHA256).Hash - if ("sha256:$actualHash" -ne $asset.digest) { throw "csrun asset checksum mismatch: $actualHash" } -$startInfo = [Diagnostics.ProcessStartInfo]::new('pwsh') -foreach ($argument in @('-NoProfile','-NonInteractive','-File')) { $startInfo.ArgumentList.Add($argument) } -$startInfo.ArgumentList.Add($enginePath) -$startInfo.ArgumentList.Add('-ManifestJson') -$startInfo.ArgumentList.Add($manifest) -$startInfo.RedirectStandardOutput = $true -$startInfo.RedirectStandardError = $true -$startInfo.UseShellExecute = $false -$process = [Diagnostics.Process]::new() -$process.StartInfo = $startInfo -if (-not $process.Start()) { throw 'Could not start csrun.' } -$stdoutTask = $process.StandardOutput.ReadToEndAsync() -$stderrTask = $process.StandardError.ReadToEndAsync() -$process.WaitForExit() -$output = $stdoutTask.GetAwaiter().GetResult() -$diagnostics = $stderrTask.GetAwaiter().GetResult() -Write-Output $output -if ($diagnostics) { [Console]::Error.Write($diagnostics) } -} catch { - [Console]::Error.WriteLine("csrun diagnostics retained in: $engineDirectory") - throw -} finally { - $resolvedTemp = [IO.Path]::TrimEndingDirectorySeparator([IO.Path]::GetFullPath([IO.Path]::GetTempPath())) - $resolvedEngineDirectory = [IO.Path]::GetFullPath($engineDirectory) - if ([IO.Path]::GetDirectoryName($resolvedEngineDirectory) -ne $resolvedTemp -or - [IO.Path]::GetFileName($resolvedEngineDirectory) -cnotmatch '^csrun-[a-f0-9]{32}$') { throw 'Unsafe cleanup path.' } - if ($process -and $process.ExitCode -eq 0) { Remove-Item -LiteralPath $resolvedEngineDirectory -Recurse -Force } -} -if ($process.ExitCode -ne 0) { throw "csrun execution failed with exit code $($process.ExitCode). $diagnostics" } -if ($verifyTests) { Assert-CsrunTestOutput $output } -} \ No newline at end of file diff --git a/.docfx/run-actions/18b0746bf3da1d84f81b5274/docker.ps1 b/.docfx/run-actions/18b0746bf3da1d84f81b5274/docker.ps1 deleted file mode 100644 index e7d1d37..0000000 --- a/.docfx/run-actions/18b0746bf3da1d84f81b5274/docker.ps1 +++ /dev/null @@ -1,83 +0,0 @@ -& { -#requires -Version 7.0 -$ErrorActionPreference = 'Stop' -$PSNativeCommandUseErrorActionPreference = $false -$manifest = @' -{ - "dependsOn": [ - "Codebelt.Extensions.Xunit.Hosting@13.0.0", - "Microsoft.Extensions.Hosting@10.0.15", - "xunit.v3@4.0.3" - ], - "framework": "net10.0", - "mode": "test", - "schemaVersion": 1, - "source": "using Codebelt.Extensions.Xunit.Hosting;\nusing Microsoft.Extensions.DependencyInjection;\nusing Microsoft.Extensions.Logging;\nusing Xunit;\n\nnamespace HostFixtureTests;\n\npublic class ExampleFixture\n{\n public IServiceCollection ConfigureServices(IServiceCollection services)\n {\n services.AddXunitTestLogging(LogLevel.Information);\n services.AddXunitTestLoggingOutputHelperAccessor();\n return services;\n }\n}\n\npublic sealed class RunExample\n{\n [Fact]\n public void ExercisesExample()\n {\n using var provider = new ExampleFixture().ConfigureServices(new ServiceCollection()).BuildServiceProvider();\n Assert.IsType(provider.GetRequiredService());\n var logger = provider.GetRequiredService>();\n logger.LogInformation(\"storage ready\");\n Assert.Contains(logger.GetTestStore().Query(), entry => entry.Severity == LogLevel.Information && entry.Message == \"Information: storage ready\");\n }\n}" -} -'@ -$OutputEncoding = [Text.UTF8Encoding]::new($false) -[Console]::OutputEncoding = $OutputEncoding -$verifyTests = $true -function Assert-CsrunTestOutput([string] $Output) { - $lines = @($Output -split '\r?\n') - $headers = @($lines | Where-Object { $_ -match '^Test run summary: Passed! - .+\)$' }) - if ($headers.Count -ne 1) { throw 'Expected exactly one completed xUnit test summary.' } - $headerIndex = [Array]::IndexOf($lines, $headers[0]) - $summaryLines = @($lines | Select-Object -Skip ($headerIndex + 1) -First 4) - $counts = @{} - foreach ($line in $summaryLines) { - if ($line -match '^\s*(total|failed|succeeded|skipped):\s*(\d+)\s*$') { $counts[$Matches[1]] = [int]$Matches[2] } - } - if ($counts.Count -ne 4) { throw 'The xUnit test summary counts are incomplete or ambiguous.' } - $failed = $counts.failed - $passed = $counts.succeeded - $skipped = $counts.skipped - $total = $counts.total - if ($total -lt 1 -or $passed -lt 1 -or $failed -ne 0 -or $skipped -ne 0 -or $passed -ne $total) { - throw 'Tests must execute at least once, all pass, and none fail or skip.' - } -} -# Downloads and executes the latest stable csrun release with your permissions. -# Source and release history: https://github.com/codebeltnet/csrun -$engineDirectory = Join-Path ([IO.Path]::GetTempPath()) ('csrun-' + [guid]::NewGuid().ToString('N')) -$null = New-Item -ItemType Directory -Path $engineDirectory -$enginePath = Join-Path $engineDirectory 'csrun.ps1' -$process = $null -try { - $release = Invoke-RestMethod 'https://api.github.com/repos/codebeltnet/csrun/releases/latest' - $assets = @($release.assets | Where-Object name -CEQ 'csrun.ps1') - if ($assets.Count -ne 1 -or $assets[0].digest -notmatch '^sha256:[0-9a-f]{64}$') { - throw "csrun release $($release.tag_name) must publish one csrun.ps1 asset with a SHA-256 digest." - } - $asset = $assets[0] - Invoke-WebRequest $asset.browser_download_url -OutFile $enginePath - $actualHash = (Get-FileHash -LiteralPath $enginePath -Algorithm SHA256).Hash - if ("sha256:$actualHash" -ne $asset.digest) { throw "csrun asset checksum mismatch: $actualHash" } -$enginePayload = [Convert]::ToBase64String([IO.File]::ReadAllBytes($enginePath)) -$containerInput = $enginePayload + "`n" + $manifest -$command = ' -$ErrorActionPreference = "Stop" -$enginePath = Join-Path ([IO.Path]::GetTempPath()) ("csrun-release-" + [guid]::NewGuid().ToString("N") + ".ps1") -$engineBytes = [Convert]::FromBase64String([Console]::In.ReadLine()) -[IO.File]::WriteAllBytes($enginePath, $engineBytes) -$manifest = [Console]::In.ReadToEnd() -& $enginePath -ManifestJson $manifest -exit $LASTEXITCODE -' -$output = (@($containerInput | & docker run --rm -i --entrypoint pwsh 'codebeltnet/csrun:10' -NoProfile -NonInteractive -Command $command) -join [Environment]::NewLine) -$process = [pscustomobject]@{ ExitCode = $LASTEXITCODE } -$diagnostics = '' -Write-Output $output -} catch { - [Console]::Error.WriteLine("csrun diagnostics retained in: $engineDirectory") - throw -} finally { - $resolvedTemp = [IO.Path]::TrimEndingDirectorySeparator([IO.Path]::GetFullPath([IO.Path]::GetTempPath())) - $resolvedEngineDirectory = [IO.Path]::GetFullPath($engineDirectory) - if ([IO.Path]::GetDirectoryName($resolvedEngineDirectory) -ne $resolvedTemp -or - [IO.Path]::GetFileName($resolvedEngineDirectory) -cnotmatch '^csrun-[a-f0-9]{32}$') { throw 'Unsafe cleanup path.' } - if ($process -and $process.ExitCode -eq 0) { Remove-Item -LiteralPath $resolvedEngineDirectory -Recurse -Force } -} -if ($process.ExitCode -ne 0) { throw "csrun execution failed with exit code $($process.ExitCode). $diagnostics" } -if ($verifyTests) { Assert-CsrunTestOutput $output } -} \ No newline at end of file diff --git a/.docfx/run-actions/18b0746bf3da1d84f81b5274/native.ps1 b/.docfx/run-actions/18b0746bf3da1d84f81b5274/native.ps1 deleted file mode 100644 index 6a762c4..0000000 --- a/.docfx/run-actions/18b0746bf3da1d84f81b5274/native.ps1 +++ /dev/null @@ -1,86 +0,0 @@ -& { -#requires -Version 7.0 -$ErrorActionPreference = 'Stop' -$PSNativeCommandUseErrorActionPreference = $false -$manifest = @' -{ - "dependsOn": [ - "Codebelt.Extensions.Xunit.Hosting@13.0.0", - "Microsoft.Extensions.Hosting@10.0.15", - "xunit.v3@4.0.3" - ], - "framework": "net10.0", - "mode": "test", - "schemaVersion": 1, - "source": "using Codebelt.Extensions.Xunit.Hosting;\nusing Microsoft.Extensions.DependencyInjection;\nusing Microsoft.Extensions.Logging;\nusing Xunit;\n\nnamespace HostFixtureTests;\n\npublic class ExampleFixture\n{\n public IServiceCollection ConfigureServices(IServiceCollection services)\n {\n services.AddXunitTestLogging(LogLevel.Information);\n services.AddXunitTestLoggingOutputHelperAccessor();\n return services;\n }\n}\n\npublic sealed class RunExample\n{\n [Fact]\n public void ExercisesExample()\n {\n using var provider = new ExampleFixture().ConfigureServices(new ServiceCollection()).BuildServiceProvider();\n Assert.IsType(provider.GetRequiredService());\n var logger = provider.GetRequiredService>();\n logger.LogInformation(\"storage ready\");\n Assert.Contains(logger.GetTestStore().Query(), entry => entry.Severity == LogLevel.Information && entry.Message == \"Information: storage ready\");\n }\n}" -} -'@ -$OutputEncoding = [Text.UTF8Encoding]::new($false) -[Console]::OutputEncoding = $OutputEncoding -$verifyTests = $true -function Assert-CsrunTestOutput([string] $Output) { - $lines = @($Output -split '\r?\n') - $headers = @($lines | Where-Object { $_ -match '^Test run summary: Passed! - .+\)$' }) - if ($headers.Count -ne 1) { throw 'Expected exactly one completed xUnit test summary.' } - $headerIndex = [Array]::IndexOf($lines, $headers[0]) - $summaryLines = @($lines | Select-Object -Skip ($headerIndex + 1) -First 4) - $counts = @{} - foreach ($line in $summaryLines) { - if ($line -match '^\s*(total|failed|succeeded|skipped):\s*(\d+)\s*$') { $counts[$Matches[1]] = [int]$Matches[2] } - } - if ($counts.Count -ne 4) { throw 'The xUnit test summary counts are incomplete or ambiguous.' } - $failed = $counts.failed - $passed = $counts.succeeded - $skipped = $counts.skipped - $total = $counts.total - if ($total -lt 1 -or $passed -lt 1 -or $failed -ne 0 -or $skipped -ne 0 -or $passed -ne $total) { - throw 'Tests must execute at least once, all pass, and none fail or skip.' - } -} -# Downloads and executes the latest stable csrun release with your permissions. -# Source and release history: https://github.com/codebeltnet/csrun -$engineDirectory = Join-Path ([IO.Path]::GetTempPath()) ('csrun-' + [guid]::NewGuid().ToString('N')) -$null = New-Item -ItemType Directory -Path $engineDirectory -$enginePath = Join-Path $engineDirectory 'csrun.ps1' -$process = $null -try { - $release = Invoke-RestMethod 'https://api.github.com/repos/codebeltnet/csrun/releases/latest' - $assets = @($release.assets | Where-Object name -CEQ 'csrun.ps1') - if ($assets.Count -ne 1 -or $assets[0].digest -notmatch '^sha256:[0-9a-f]{64}$') { - throw "csrun release $($release.tag_name) must publish one csrun.ps1 asset with a SHA-256 digest." - } - $asset = $assets[0] - Invoke-WebRequest $asset.browser_download_url -OutFile $enginePath - $actualHash = (Get-FileHash -LiteralPath $enginePath -Algorithm SHA256).Hash - if ("sha256:$actualHash" -ne $asset.digest) { throw "csrun asset checksum mismatch: $actualHash" } -$startInfo = [Diagnostics.ProcessStartInfo]::new('pwsh') -foreach ($argument in @('-NoProfile','-NonInteractive','-File')) { $startInfo.ArgumentList.Add($argument) } -$startInfo.ArgumentList.Add($enginePath) -$startInfo.ArgumentList.Add('-ManifestJson') -$startInfo.ArgumentList.Add($manifest) -$startInfo.RedirectStandardOutput = $true -$startInfo.RedirectStandardError = $true -$startInfo.UseShellExecute = $false -$process = [Diagnostics.Process]::new() -$process.StartInfo = $startInfo -if (-not $process.Start()) { throw 'Could not start csrun.' } -$stdoutTask = $process.StandardOutput.ReadToEndAsync() -$stderrTask = $process.StandardError.ReadToEndAsync() -$process.WaitForExit() -$output = $stdoutTask.GetAwaiter().GetResult() -$diagnostics = $stderrTask.GetAwaiter().GetResult() -Write-Output $output -if ($diagnostics) { [Console]::Error.Write($diagnostics) } -} catch { - [Console]::Error.WriteLine("csrun diagnostics retained in: $engineDirectory") - throw -} finally { - $resolvedTemp = [IO.Path]::TrimEndingDirectorySeparator([IO.Path]::GetFullPath([IO.Path]::GetTempPath())) - $resolvedEngineDirectory = [IO.Path]::GetFullPath($engineDirectory) - if ([IO.Path]::GetDirectoryName($resolvedEngineDirectory) -ne $resolvedTemp -or - [IO.Path]::GetFileName($resolvedEngineDirectory) -cnotmatch '^csrun-[a-f0-9]{32}$') { throw 'Unsafe cleanup path.' } - if ($process -and $process.ExitCode -eq 0) { Remove-Item -LiteralPath $resolvedEngineDirectory -Recurse -Force } -} -if ($process.ExitCode -ne 0) { throw "csrun execution failed with exit code $($process.ExitCode). $diagnostics" } -if ($verifyTests) { Assert-CsrunTestOutput $output } -} \ No newline at end of file diff --git a/.docfx/run-actions/1e869fe39c4833386733c21f/docker.ps1 b/.docfx/run-actions/1e869fe39c4833386733c21f/docker.ps1 deleted file mode 100644 index fe6d588..0000000 --- a/.docfx/run-actions/1e869fe39c4833386733c21f/docker.ps1 +++ /dev/null @@ -1,86 +0,0 @@ -& { -#requires -Version 7.0 -$ErrorActionPreference = 'Stop' -$PSNativeCommandUseErrorActionPreference = $false -$manifest = @' -{ - "dependsOn": [ - "Codebelt.Extensions.Xunit.Hosting.AspNetCore@13.0.0", - "Microsoft.Extensions.Hosting@10.0.15", - "xunit.v3@4.0.3" - ], - "framework": "net10.0", - "frameworkReferences": [ - "Microsoft.AspNetCore.App" - ], - "mode": "test", - "schemaVersion": 1, - "source": "using System.Threading.Tasks;\nusing Codebelt.Extensions.Xunit.Hosting.AspNetCore;\nusing Microsoft.AspNetCore.Builder;\nusing Microsoft.AspNetCore.Http;\nusing Microsoft.Extensions.DependencyInjection;\nusing Xunit;\n\nnamespace HealthEndpoint.Tests;\n\npublic sealed class MinimalWebHostTestFactoryExample\n{\n public async Task ReadHealthStateAsync()\n {\n using var response = await MinimalWebHostTestFactory.RunAsync(\n services => services.AddSingleton(new HealthState(\"healthy\")),\n app => app.Run(context =>\n {\n var health = context.RequestServices.GetRequiredService();\n return context.Response.WriteAsync(health.Value);\n })).ConfigureAwait(false);\n\n return await response.Content.ReadAsStringAsync().ConfigureAwait(false);\n }\n}\n\npublic sealed record HealthState(string Value);\n\npublic sealed class RunExample\n{\n [Fact]\n public async Task ExercisesExample()\n {\n Assert.Equal(\"healthy\", await new MinimalWebHostTestFactoryExample().ReadHealthStateAsync());\n }\n}" -} -'@ -$OutputEncoding = [Text.UTF8Encoding]::new($false) -[Console]::OutputEncoding = $OutputEncoding -$verifyTests = $true -function Assert-CsrunTestOutput([string] $Output) { - $lines = @($Output -split '\r?\n') - $headers = @($lines | Where-Object { $_ -match '^Test run summary: Passed! - .+\)$' }) - if ($headers.Count -ne 1) { throw 'Expected exactly one completed xUnit test summary.' } - $headerIndex = [Array]::IndexOf($lines, $headers[0]) - $summaryLines = @($lines | Select-Object -Skip ($headerIndex + 1) -First 4) - $counts = @{} - foreach ($line in $summaryLines) { - if ($line -match '^\s*(total|failed|succeeded|skipped):\s*(\d+)\s*$') { $counts[$Matches[1]] = [int]$Matches[2] } - } - if ($counts.Count -ne 4) { throw 'The xUnit test summary counts are incomplete or ambiguous.' } - $failed = $counts.failed - $passed = $counts.succeeded - $skipped = $counts.skipped - $total = $counts.total - if ($total -lt 1 -or $passed -lt 1 -or $failed -ne 0 -or $skipped -ne 0 -or $passed -ne $total) { - throw 'Tests must execute at least once, all pass, and none fail or skip.' - } -} -# Downloads and executes the latest stable csrun release with your permissions. -# Source and release history: https://github.com/codebeltnet/csrun -$engineDirectory = Join-Path ([IO.Path]::GetTempPath()) ('csrun-' + [guid]::NewGuid().ToString('N')) -$null = New-Item -ItemType Directory -Path $engineDirectory -$enginePath = Join-Path $engineDirectory 'csrun.ps1' -$process = $null -try { - $release = Invoke-RestMethod 'https://api.github.com/repos/codebeltnet/csrun/releases/latest' - $assets = @($release.assets | Where-Object name -CEQ 'csrun.ps1') - if ($assets.Count -ne 1 -or $assets[0].digest -notmatch '^sha256:[0-9a-f]{64}$') { - throw "csrun release $($release.tag_name) must publish one csrun.ps1 asset with a SHA-256 digest." - } - $asset = $assets[0] - Invoke-WebRequest $asset.browser_download_url -OutFile $enginePath - $actualHash = (Get-FileHash -LiteralPath $enginePath -Algorithm SHA256).Hash - if ("sha256:$actualHash" -ne $asset.digest) { throw "csrun asset checksum mismatch: $actualHash" } -$enginePayload = [Convert]::ToBase64String([IO.File]::ReadAllBytes($enginePath)) -$containerInput = $enginePayload + "`n" + $manifest -$command = ' -$ErrorActionPreference = "Stop" -$enginePath = Join-Path ([IO.Path]::GetTempPath()) ("csrun-release-" + [guid]::NewGuid().ToString("N") + ".ps1") -$engineBytes = [Convert]::FromBase64String([Console]::In.ReadLine()) -[IO.File]::WriteAllBytes($enginePath, $engineBytes) -$manifest = [Console]::In.ReadToEnd() -& $enginePath -ManifestJson $manifest -exit $LASTEXITCODE -' -$output = (@($containerInput | & docker run --rm -i --entrypoint pwsh 'codebeltnet/csrun:10' -NoProfile -NonInteractive -Command $command) -join [Environment]::NewLine) -$process = [pscustomobject]@{ ExitCode = $LASTEXITCODE } -$diagnostics = '' -Write-Output $output -} catch { - [Console]::Error.WriteLine("csrun diagnostics retained in: $engineDirectory") - throw -} finally { - $resolvedTemp = [IO.Path]::TrimEndingDirectorySeparator([IO.Path]::GetFullPath([IO.Path]::GetTempPath())) - $resolvedEngineDirectory = [IO.Path]::GetFullPath($engineDirectory) - if ([IO.Path]::GetDirectoryName($resolvedEngineDirectory) -ne $resolvedTemp -or - [IO.Path]::GetFileName($resolvedEngineDirectory) -cnotmatch '^csrun-[a-f0-9]{32}$') { throw 'Unsafe cleanup path.' } - if ($process -and $process.ExitCode -eq 0) { Remove-Item -LiteralPath $resolvedEngineDirectory -Recurse -Force } -} -if ($process.ExitCode -ne 0) { throw "csrun execution failed with exit code $($process.ExitCode). $diagnostics" } -if ($verifyTests) { Assert-CsrunTestOutput $output } -} \ No newline at end of file diff --git a/.docfx/run-actions/1e869fe39c4833386733c21f/native.ps1 b/.docfx/run-actions/1e869fe39c4833386733c21f/native.ps1 deleted file mode 100644 index 8e89972..0000000 --- a/.docfx/run-actions/1e869fe39c4833386733c21f/native.ps1 +++ /dev/null @@ -1,89 +0,0 @@ -& { -#requires -Version 7.0 -$ErrorActionPreference = 'Stop' -$PSNativeCommandUseErrorActionPreference = $false -$manifest = @' -{ - "dependsOn": [ - "Codebelt.Extensions.Xunit.Hosting.AspNetCore@13.0.0", - "Microsoft.Extensions.Hosting@10.0.15", - "xunit.v3@4.0.3" - ], - "framework": "net10.0", - "frameworkReferences": [ - "Microsoft.AspNetCore.App" - ], - "mode": "test", - "schemaVersion": 1, - "source": "using System.Threading.Tasks;\nusing Codebelt.Extensions.Xunit.Hosting.AspNetCore;\nusing Microsoft.AspNetCore.Builder;\nusing Microsoft.AspNetCore.Http;\nusing Microsoft.Extensions.DependencyInjection;\nusing Xunit;\n\nnamespace HealthEndpoint.Tests;\n\npublic sealed class MinimalWebHostTestFactoryExample\n{\n public async Task ReadHealthStateAsync()\n {\n using var response = await MinimalWebHostTestFactory.RunAsync(\n services => services.AddSingleton(new HealthState(\"healthy\")),\n app => app.Run(context =>\n {\n var health = context.RequestServices.GetRequiredService();\n return context.Response.WriteAsync(health.Value);\n })).ConfigureAwait(false);\n\n return await response.Content.ReadAsStringAsync().ConfigureAwait(false);\n }\n}\n\npublic sealed record HealthState(string Value);\n\npublic sealed class RunExample\n{\n [Fact]\n public async Task ExercisesExample()\n {\n Assert.Equal(\"healthy\", await new MinimalWebHostTestFactoryExample().ReadHealthStateAsync());\n }\n}" -} -'@ -$OutputEncoding = [Text.UTF8Encoding]::new($false) -[Console]::OutputEncoding = $OutputEncoding -$verifyTests = $true -function Assert-CsrunTestOutput([string] $Output) { - $lines = @($Output -split '\r?\n') - $headers = @($lines | Where-Object { $_ -match '^Test run summary: Passed! - .+\)$' }) - if ($headers.Count -ne 1) { throw 'Expected exactly one completed xUnit test summary.' } - $headerIndex = [Array]::IndexOf($lines, $headers[0]) - $summaryLines = @($lines | Select-Object -Skip ($headerIndex + 1) -First 4) - $counts = @{} - foreach ($line in $summaryLines) { - if ($line -match '^\s*(total|failed|succeeded|skipped):\s*(\d+)\s*$') { $counts[$Matches[1]] = [int]$Matches[2] } - } - if ($counts.Count -ne 4) { throw 'The xUnit test summary counts are incomplete or ambiguous.' } - $failed = $counts.failed - $passed = $counts.succeeded - $skipped = $counts.skipped - $total = $counts.total - if ($total -lt 1 -or $passed -lt 1 -or $failed -ne 0 -or $skipped -ne 0 -or $passed -ne $total) { - throw 'Tests must execute at least once, all pass, and none fail or skip.' - } -} -# Downloads and executes the latest stable csrun release with your permissions. -# Source and release history: https://github.com/codebeltnet/csrun -$engineDirectory = Join-Path ([IO.Path]::GetTempPath()) ('csrun-' + [guid]::NewGuid().ToString('N')) -$null = New-Item -ItemType Directory -Path $engineDirectory -$enginePath = Join-Path $engineDirectory 'csrun.ps1' -$process = $null -try { - $release = Invoke-RestMethod 'https://api.github.com/repos/codebeltnet/csrun/releases/latest' - $assets = @($release.assets | Where-Object name -CEQ 'csrun.ps1') - if ($assets.Count -ne 1 -or $assets[0].digest -notmatch '^sha256:[0-9a-f]{64}$') { - throw "csrun release $($release.tag_name) must publish one csrun.ps1 asset with a SHA-256 digest." - } - $asset = $assets[0] - Invoke-WebRequest $asset.browser_download_url -OutFile $enginePath - $actualHash = (Get-FileHash -LiteralPath $enginePath -Algorithm SHA256).Hash - if ("sha256:$actualHash" -ne $asset.digest) { throw "csrun asset checksum mismatch: $actualHash" } -$startInfo = [Diagnostics.ProcessStartInfo]::new('pwsh') -foreach ($argument in @('-NoProfile','-NonInteractive','-File')) { $startInfo.ArgumentList.Add($argument) } -$startInfo.ArgumentList.Add($enginePath) -$startInfo.ArgumentList.Add('-ManifestJson') -$startInfo.ArgumentList.Add($manifest) -$startInfo.RedirectStandardOutput = $true -$startInfo.RedirectStandardError = $true -$startInfo.UseShellExecute = $false -$process = [Diagnostics.Process]::new() -$process.StartInfo = $startInfo -if (-not $process.Start()) { throw 'Could not start csrun.' } -$stdoutTask = $process.StandardOutput.ReadToEndAsync() -$stderrTask = $process.StandardError.ReadToEndAsync() -$process.WaitForExit() -$output = $stdoutTask.GetAwaiter().GetResult() -$diagnostics = $stderrTask.GetAwaiter().GetResult() -Write-Output $output -if ($diagnostics) { [Console]::Error.Write($diagnostics) } -} catch { - [Console]::Error.WriteLine("csrun diagnostics retained in: $engineDirectory") - throw -} finally { - $resolvedTemp = [IO.Path]::TrimEndingDirectorySeparator([IO.Path]::GetFullPath([IO.Path]::GetTempPath())) - $resolvedEngineDirectory = [IO.Path]::GetFullPath($engineDirectory) - if ([IO.Path]::GetDirectoryName($resolvedEngineDirectory) -ne $resolvedTemp -or - [IO.Path]::GetFileName($resolvedEngineDirectory) -cnotmatch '^csrun-[a-f0-9]{32}$') { throw 'Unsafe cleanup path.' } - if ($process -and $process.ExitCode -eq 0) { Remove-Item -LiteralPath $resolvedEngineDirectory -Recurse -Force } -} -if ($process.ExitCode -ne 0) { throw "csrun execution failed with exit code $($process.ExitCode). $diagnostics" } -if ($verifyTests) { Assert-CsrunTestOutput $output } -} \ No newline at end of file diff --git a/.docfx/run-actions/1ec9196292addaca42a7eef1/docker.ps1 b/.docfx/run-actions/1ec9196292addaca42a7eef1/docker.ps1 deleted file mode 100644 index d968ec5..0000000 --- a/.docfx/run-actions/1ec9196292addaca42a7eef1/docker.ps1 +++ /dev/null @@ -1,58 +0,0 @@ -& { -#requires -Version 7.0 - $ErrorActionPreference = 'Stop' - $PSNativeCommandUseErrorActionPreference = $false - # Executes trusted repository build tasks and NuGet packages with your permissions. - # Review the pinned source before running; a container is not a security sandbox. - $null = Get-Command docker -ErrorAction Stop - docker info *> $null - if ($LASTEXITCODE -ne 0) { throw 'Docker daemon unavailable.' } - $work = Join-Path ([IO.Path]::GetTempPath()) ('dx-' + [guid]::NewGuid().ToString('N').Substring(0, 8)) - $null = New-Item -ItemType Directory -Path $work - try { - $commit = '84b13767cb9484f8f3a36a71875662edfdb3e511' - Invoke-WebRequest "https://codeload.github.com/codebeltnet/xunit/zip/$commit" -OutFile "$work/source.zip" - Expand-Archive -LiteralPath "$work/source.zip" -DestinationPath "$work/extracted" - Move-Item -LiteralPath "$work/extracted/xunit-$commit" -Destination "$work/repo" - $project = 'test/Codebelt.Extensions.Xunit.Hosting.FunctionalTests/Codebelt.Extensions.Xunit.Hosting.FunctionalTests.csproj' - $test = 'Codebelt.Extensions.Xunit.Hosting.BootstrapperMinimalWorkerApplicationTestTest.ShouldBootstrapMinimalWorkerProgram' - $dockerUser = @() - if ($IsLinux) { - # Keep bind-mounted build output removable by the host user. - $hostUid = id -u - if ($LASTEXITCODE -ne 0) { throw 'Cannot resolve host UID.' } - $hostGid = id -g - if ($LASTEXITCODE -ne 0) { throw 'Cannot resolve host GID.' } - $dockerUser = @('--user', "${hostUid}:${hostGid}") - } - # Let Docker's init reap orphaned build processes and keep build servers disposable. - docker run --rm --init @dockerUser --env HOME=/tmp --env DOTNET_CLI_HOME=/tmp --env MSBUILDDISABLENODEREUSE=1 --mount "type=bind,source=$work,target=/work" --workdir /work/repo mcr.microsoft.com/dotnet/sdk:11.0 dotnet run --disable-build-servers --project $project --framework net11.0 -p:SkipSignAssembly=true -- --filter-method $test --report-xunit-xml --report-xunit-xml-filename result.xml --results-directory /work/results 2>&1 | Tee-Object -FilePath "$work/run.log" - $code = $LASTEXITCODE - if ($code -ne 0) { throw "Repository test failed with exit code $code. See $work/run.log" } - # Require exactly the original test, executed and passing, with no runner errors. - [xml] $report = Get-Content -LiteralPath "$work/results/result.xml" -Raw - $tests = @($report.SelectNodes('/assemblies/assembly/collection/test')) - $assemblies = @($report.SelectNodes('/assemblies/assembly')) - if ($assemblies.Count -ne 1 -or $assemblies[0].total -ne '1' -or $assemblies[0].passed -ne '1' -or - $assemblies[0].errors -ne '0' -or $tests.Count -ne 1 -or $tests[0].name -cne $test -or $tests[0].result -cne 'Pass') { - throw "Expected exactly one passing $test; inspect $work/results/result.xml" - } - Write-Host "Verified: $test (1 executed, 1 passed)." - } - catch { - # Preserve diagnostics outside the repository even though downloaded source is cleaned. - $diagnostics = "$work-diagnostics" - $null = New-Item -ItemType Directory -Path $diagnostics -Force - foreach ($name in @('run.log', 'results')) { - if (Test-Path -LiteralPath "$work/$name") { Copy-Item -LiteralPath "$work/$name" -Destination $diagnostics -Recurse } - } - Write-Warning "Execution not verified. Diagnostics: $diagnostics" - throw - } - finally { - $resolved = [IO.Path]::GetFullPath($work) - $temp = [IO.Path]::GetFullPath([IO.Path]::GetTempPath()).TrimEnd('/','\') + [IO.Path]::DirectorySeparatorChar - if (-not $resolved.StartsWith($temp, [StringComparison]::OrdinalIgnoreCase)) { throw 'Unsafe cleanup path.' } - Remove-Item -LiteralPath $resolved -Recurse -Force - } -} \ No newline at end of file diff --git a/.docfx/run-actions/1ec9196292addaca42a7eef1/native.ps1 b/.docfx/run-actions/1ec9196292addaca42a7eef1/native.ps1 deleted file mode 100644 index 39f3020..0000000 --- a/.docfx/run-actions/1ec9196292addaca42a7eef1/native.ps1 +++ /dev/null @@ -1,50 +0,0 @@ -& { -#requires -Version 7.0 - $ErrorActionPreference = 'Stop' - $PSNativeCommandUseErrorActionPreference = $false - # Executes trusted repository build tasks and NuGet packages with your permissions. - # Review the pinned source before running; a container is not a security sandbox. - $null = Get-Command dotnet -ErrorAction Stop - $work = Join-Path ([IO.Path]::GetTempPath()) ('dx-' + [guid]::NewGuid().ToString('N').Substring(0, 8)) - $null = New-Item -ItemType Directory -Path $work - try { - $commit = '84b13767cb9484f8f3a36a71875662edfdb3e511' - Invoke-WebRequest "https://codeload.github.com/codebeltnet/xunit/zip/$commit" -OutFile "$work/source.zip" - Expand-Archive -LiteralPath "$work/source.zip" -DestinationPath "$work/extracted" - Move-Item -LiteralPath "$work/extracted/xunit-$commit" -Destination "$work/repo" - $project = 'test/Codebelt.Extensions.Xunit.Hosting.FunctionalTests/Codebelt.Extensions.Xunit.Hosting.FunctionalTests.csproj' - $test = 'Codebelt.Extensions.Xunit.Hosting.BootstrapperMinimalWorkerApplicationTestTest.ShouldBootstrapMinimalWorkerProgram' - Push-Location "$work/repo" - try { - dotnet run --project $project --framework net11.0 -p:SkipSignAssembly=true -- --filter-method $test --report-xunit-xml --report-xunit-xml-filename result.xml --results-directory "$work/results" 2>&1 | Tee-Object -FilePath "$work/run.log" - } - finally { Pop-Location } - $code = $LASTEXITCODE - if ($code -ne 0) { throw "Repository test failed with exit code $code. See $work/run.log" } - # Require exactly the original test, executed and passing, with no runner errors. - [xml] $report = Get-Content -LiteralPath "$work/results/result.xml" -Raw - $tests = @($report.SelectNodes('/assemblies/assembly/collection/test')) - $assemblies = @($report.SelectNodes('/assemblies/assembly')) - if ($assemblies.Count -ne 1 -or $assemblies[0].total -ne '1' -or $assemblies[0].passed -ne '1' -or - $assemblies[0].errors -ne '0' -or $tests.Count -ne 1 -or $tests[0].name -cne $test -or $tests[0].result -cne 'Pass') { - throw "Expected exactly one passing $test; inspect $work/results/result.xml" - } - Write-Host "Verified: $test (1 executed, 1 passed)." - } - catch { - # Preserve diagnostics outside the repository even though downloaded source is cleaned. - $diagnostics = "$work-diagnostics" - $null = New-Item -ItemType Directory -Path $diagnostics -Force - foreach ($name in @('run.log', 'results')) { - if (Test-Path -LiteralPath "$work/$name") { Copy-Item -LiteralPath "$work/$name" -Destination $diagnostics -Recurse } - } - Write-Warning "Execution not verified. Diagnostics: $diagnostics" - throw - } - finally { - $resolved = [IO.Path]::GetFullPath($work) - $temp = [IO.Path]::GetFullPath([IO.Path]::GetTempPath()).TrimEnd('/','\') + [IO.Path]::DirectorySeparatorChar - if (-not $resolved.StartsWith($temp, [StringComparison]::OrdinalIgnoreCase)) { throw 'Unsafe cleanup path.' } - Remove-Item -LiteralPath $resolved -Recurse -Force - } -} \ No newline at end of file diff --git a/.docfx/run-actions/21b422ce67f920d801901db0/docker.ps1 b/.docfx/run-actions/21b422ce67f920d801901db0/docker.ps1 deleted file mode 100644 index 29b67e4..0000000 --- a/.docfx/run-actions/21b422ce67f920d801901db0/docker.ps1 +++ /dev/null @@ -1,86 +0,0 @@ -& { -#requires -Version 7.0 -$ErrorActionPreference = 'Stop' -$PSNativeCommandUseErrorActionPreference = $false -$manifest = @' -{ - "dependsOn": [ - "Codebelt.Extensions.Xunit.Hosting.AspNetCore@13.0.0", - "Microsoft.Extensions.Hosting@10.0.15", - "xunit.v3@4.0.3" - ], - "framework": "net10.0", - "frameworkReferences": [ - "Microsoft.AspNetCore.App" - ], - "mode": "test", - "schemaVersion": 1, - "source": "using Codebelt.Extensions.Xunit.Hosting.AspNetCore;\nusing Microsoft.Extensions.DependencyInjection;\nusing Microsoft.Extensions.Hosting;\nusing Xunit;\n\nnamespace WebFixtureTests;\n\npublic class WebHostIntegrationTest\n{\n [Fact]\n public void HostShouldBeStarted()\n {\n using var fixture = new BlockingManagedWebHostFixture();\n using var app = WebHostTestFactory.Create(hostFixture: fixture);\n\n Assert.True(fixture.HasValidState());\n var lifetime = app.Host.Services.GetRequiredService();\n Assert.True(lifetime.ApplicationStarted.IsCancellationRequested);\n }\n}" -} -'@ -$OutputEncoding = [Text.UTF8Encoding]::new($false) -[Console]::OutputEncoding = $OutputEncoding -$verifyTests = $true -function Assert-CsrunTestOutput([string] $Output) { - $lines = @($Output -split '\r?\n') - $headers = @($lines | Where-Object { $_ -match '^Test run summary: Passed! - .+\)$' }) - if ($headers.Count -ne 1) { throw 'Expected exactly one completed xUnit test summary.' } - $headerIndex = [Array]::IndexOf($lines, $headers[0]) - $summaryLines = @($lines | Select-Object -Skip ($headerIndex + 1) -First 4) - $counts = @{} - foreach ($line in $summaryLines) { - if ($line -match '^\s*(total|failed|succeeded|skipped):\s*(\d+)\s*$') { $counts[$Matches[1]] = [int]$Matches[2] } - } - if ($counts.Count -ne 4) { throw 'The xUnit test summary counts are incomplete or ambiguous.' } - $failed = $counts.failed - $passed = $counts.succeeded - $skipped = $counts.skipped - $total = $counts.total - if ($total -lt 1 -or $passed -lt 1 -or $failed -ne 0 -or $skipped -ne 0 -or $passed -ne $total) { - throw 'Tests must execute at least once, all pass, and none fail or skip.' - } -} -# Downloads and executes the latest stable csrun release with your permissions. -# Source and release history: https://github.com/codebeltnet/csrun -$engineDirectory = Join-Path ([IO.Path]::GetTempPath()) ('csrun-' + [guid]::NewGuid().ToString('N')) -$null = New-Item -ItemType Directory -Path $engineDirectory -$enginePath = Join-Path $engineDirectory 'csrun.ps1' -$process = $null -try { - $release = Invoke-RestMethod 'https://api.github.com/repos/codebeltnet/csrun/releases/latest' - $assets = @($release.assets | Where-Object name -CEQ 'csrun.ps1') - if ($assets.Count -ne 1 -or $assets[0].digest -notmatch '^sha256:[0-9a-f]{64}$') { - throw "csrun release $($release.tag_name) must publish one csrun.ps1 asset with a SHA-256 digest." - } - $asset = $assets[0] - Invoke-WebRequest $asset.browser_download_url -OutFile $enginePath - $actualHash = (Get-FileHash -LiteralPath $enginePath -Algorithm SHA256).Hash - if ("sha256:$actualHash" -ne $asset.digest) { throw "csrun asset checksum mismatch: $actualHash" } -$enginePayload = [Convert]::ToBase64String([IO.File]::ReadAllBytes($enginePath)) -$containerInput = $enginePayload + "`n" + $manifest -$command = ' -$ErrorActionPreference = "Stop" -$enginePath = Join-Path ([IO.Path]::GetTempPath()) ("csrun-release-" + [guid]::NewGuid().ToString("N") + ".ps1") -$engineBytes = [Convert]::FromBase64String([Console]::In.ReadLine()) -[IO.File]::WriteAllBytes($enginePath, $engineBytes) -$manifest = [Console]::In.ReadToEnd() -& $enginePath -ManifestJson $manifest -exit $LASTEXITCODE -' -$output = (@($containerInput | & docker run --rm -i --entrypoint pwsh 'codebeltnet/csrun:10' -NoProfile -NonInteractive -Command $command) -join [Environment]::NewLine) -$process = [pscustomobject]@{ ExitCode = $LASTEXITCODE } -$diagnostics = '' -Write-Output $output -} catch { - [Console]::Error.WriteLine("csrun diagnostics retained in: $engineDirectory") - throw -} finally { - $resolvedTemp = [IO.Path]::TrimEndingDirectorySeparator([IO.Path]::GetFullPath([IO.Path]::GetTempPath())) - $resolvedEngineDirectory = [IO.Path]::GetFullPath($engineDirectory) - if ([IO.Path]::GetDirectoryName($resolvedEngineDirectory) -ne $resolvedTemp -or - [IO.Path]::GetFileName($resolvedEngineDirectory) -cnotmatch '^csrun-[a-f0-9]{32}$') { throw 'Unsafe cleanup path.' } - if ($process -and $process.ExitCode -eq 0) { Remove-Item -LiteralPath $resolvedEngineDirectory -Recurse -Force } -} -if ($process.ExitCode -ne 0) { throw "csrun execution failed with exit code $($process.ExitCode). $diagnostics" } -if ($verifyTests) { Assert-CsrunTestOutput $output } -} \ No newline at end of file diff --git a/.docfx/run-actions/21b422ce67f920d801901db0/native.ps1 b/.docfx/run-actions/21b422ce67f920d801901db0/native.ps1 deleted file mode 100644 index a01584e..0000000 --- a/.docfx/run-actions/21b422ce67f920d801901db0/native.ps1 +++ /dev/null @@ -1,89 +0,0 @@ -& { -#requires -Version 7.0 -$ErrorActionPreference = 'Stop' -$PSNativeCommandUseErrorActionPreference = $false -$manifest = @' -{ - "dependsOn": [ - "Codebelt.Extensions.Xunit.Hosting.AspNetCore@13.0.0", - "Microsoft.Extensions.Hosting@10.0.15", - "xunit.v3@4.0.3" - ], - "framework": "net10.0", - "frameworkReferences": [ - "Microsoft.AspNetCore.App" - ], - "mode": "test", - "schemaVersion": 1, - "source": "using Codebelt.Extensions.Xunit.Hosting.AspNetCore;\nusing Microsoft.Extensions.DependencyInjection;\nusing Microsoft.Extensions.Hosting;\nusing Xunit;\n\nnamespace WebFixtureTests;\n\npublic class WebHostIntegrationTest\n{\n [Fact]\n public void HostShouldBeStarted()\n {\n using var fixture = new BlockingManagedWebHostFixture();\n using var app = WebHostTestFactory.Create(hostFixture: fixture);\n\n Assert.True(fixture.HasValidState());\n var lifetime = app.Host.Services.GetRequiredService();\n Assert.True(lifetime.ApplicationStarted.IsCancellationRequested);\n }\n}" -} -'@ -$OutputEncoding = [Text.UTF8Encoding]::new($false) -[Console]::OutputEncoding = $OutputEncoding -$verifyTests = $true -function Assert-CsrunTestOutput([string] $Output) { - $lines = @($Output -split '\r?\n') - $headers = @($lines | Where-Object { $_ -match '^Test run summary: Passed! - .+\)$' }) - if ($headers.Count -ne 1) { throw 'Expected exactly one completed xUnit test summary.' } - $headerIndex = [Array]::IndexOf($lines, $headers[0]) - $summaryLines = @($lines | Select-Object -Skip ($headerIndex + 1) -First 4) - $counts = @{} - foreach ($line in $summaryLines) { - if ($line -match '^\s*(total|failed|succeeded|skipped):\s*(\d+)\s*$') { $counts[$Matches[1]] = [int]$Matches[2] } - } - if ($counts.Count -ne 4) { throw 'The xUnit test summary counts are incomplete or ambiguous.' } - $failed = $counts.failed - $passed = $counts.succeeded - $skipped = $counts.skipped - $total = $counts.total - if ($total -lt 1 -or $passed -lt 1 -or $failed -ne 0 -or $skipped -ne 0 -or $passed -ne $total) { - throw 'Tests must execute at least once, all pass, and none fail or skip.' - } -} -# Downloads and executes the latest stable csrun release with your permissions. -# Source and release history: https://github.com/codebeltnet/csrun -$engineDirectory = Join-Path ([IO.Path]::GetTempPath()) ('csrun-' + [guid]::NewGuid().ToString('N')) -$null = New-Item -ItemType Directory -Path $engineDirectory -$enginePath = Join-Path $engineDirectory 'csrun.ps1' -$process = $null -try { - $release = Invoke-RestMethod 'https://api.github.com/repos/codebeltnet/csrun/releases/latest' - $assets = @($release.assets | Where-Object name -CEQ 'csrun.ps1') - if ($assets.Count -ne 1 -or $assets[0].digest -notmatch '^sha256:[0-9a-f]{64}$') { - throw "csrun release $($release.tag_name) must publish one csrun.ps1 asset with a SHA-256 digest." - } - $asset = $assets[0] - Invoke-WebRequest $asset.browser_download_url -OutFile $enginePath - $actualHash = (Get-FileHash -LiteralPath $enginePath -Algorithm SHA256).Hash - if ("sha256:$actualHash" -ne $asset.digest) { throw "csrun asset checksum mismatch: $actualHash" } -$startInfo = [Diagnostics.ProcessStartInfo]::new('pwsh') -foreach ($argument in @('-NoProfile','-NonInteractive','-File')) { $startInfo.ArgumentList.Add($argument) } -$startInfo.ArgumentList.Add($enginePath) -$startInfo.ArgumentList.Add('-ManifestJson') -$startInfo.ArgumentList.Add($manifest) -$startInfo.RedirectStandardOutput = $true -$startInfo.RedirectStandardError = $true -$startInfo.UseShellExecute = $false -$process = [Diagnostics.Process]::new() -$process.StartInfo = $startInfo -if (-not $process.Start()) { throw 'Could not start csrun.' } -$stdoutTask = $process.StandardOutput.ReadToEndAsync() -$stderrTask = $process.StandardError.ReadToEndAsync() -$process.WaitForExit() -$output = $stdoutTask.GetAwaiter().GetResult() -$diagnostics = $stderrTask.GetAwaiter().GetResult() -Write-Output $output -if ($diagnostics) { [Console]::Error.Write($diagnostics) } -} catch { - [Console]::Error.WriteLine("csrun diagnostics retained in: $engineDirectory") - throw -} finally { - $resolvedTemp = [IO.Path]::TrimEndingDirectorySeparator([IO.Path]::GetFullPath([IO.Path]::GetTempPath())) - $resolvedEngineDirectory = [IO.Path]::GetFullPath($engineDirectory) - if ([IO.Path]::GetDirectoryName($resolvedEngineDirectory) -ne $resolvedTemp -or - [IO.Path]::GetFileName($resolvedEngineDirectory) -cnotmatch '^csrun-[a-f0-9]{32}$') { throw 'Unsafe cleanup path.' } - if ($process -and $process.ExitCode -eq 0) { Remove-Item -LiteralPath $resolvedEngineDirectory -Recurse -Force } -} -if ($process.ExitCode -ne 0) { throw "csrun execution failed with exit code $($process.ExitCode). $diagnostics" } -if ($verifyTests) { Assert-CsrunTestOutput $output } -} \ No newline at end of file diff --git a/.docfx/run-actions/38b60f4b4c1a588bbefe92f1/docker.ps1 b/.docfx/run-actions/38b60f4b4c1a588bbefe92f1/docker.ps1 deleted file mode 100644 index c68fd3b..0000000 --- a/.docfx/run-actions/38b60f4b4c1a588bbefe92f1/docker.ps1 +++ /dev/null @@ -1,58 +0,0 @@ -& { -#requires -Version 7.0 - $ErrorActionPreference = 'Stop' - $PSNativeCommandUseErrorActionPreference = $false - # Executes trusted repository build tasks and NuGet packages with your permissions. - # Review the pinned source before running; a container is not a security sandbox. - $null = Get-Command docker -ErrorAction Stop - docker info *> $null - if ($LASTEXITCODE -ne 0) { throw 'Docker daemon unavailable.' } - $work = Join-Path ([IO.Path]::GetTempPath()) ('dx-' + [guid]::NewGuid().ToString('N').Substring(0, 8)) - $null = New-Item -ItemType Directory -Path $work - try { - $commit = '84b13767cb9484f8f3a36a71875662edfdb3e511' - Invoke-WebRequest "https://codeload.github.com/codebeltnet/xunit/zip/$commit" -OutFile "$work/source.zip" - Expand-Archive -LiteralPath "$work/source.zip" -DestinationPath "$work/extracted" - Move-Item -LiteralPath "$work/extracted/xunit-$commit" -Destination "$work/repo" - $project = 'test/Codebelt.Extensions.Xunit.Hosting.AspNetCore.FunctionalTests/Codebelt.Extensions.Xunit.Hosting.AspNetCore.FunctionalTests.csproj' - $test = 'Codebelt.Extensions.Xunit.Hosting.AspNetCore.WebApplicationTestFactoryTest.Create_ShouldApplyWebHostConfiguration_WhenWebHostSetupIsProvided' - $dockerUser = @() - if ($IsLinux) { - # Keep bind-mounted build output removable by the host user. - $hostUid = id -u - if ($LASTEXITCODE -ne 0) { throw 'Cannot resolve host UID.' } - $hostGid = id -g - if ($LASTEXITCODE -ne 0) { throw 'Cannot resolve host GID.' } - $dockerUser = @('--user', "${hostUid}:${hostGid}") - } - # Let Docker's init reap orphaned build processes and keep build servers disposable. - docker run --rm --init @dockerUser --env HOME=/tmp --env DOTNET_CLI_HOME=/tmp --env MSBUILDDISABLENODEREUSE=1 --mount "type=bind,source=$work,target=/work" --workdir /work/repo mcr.microsoft.com/dotnet/sdk:11.0 dotnet run --disable-build-servers --project $project --framework net11.0 -p:SkipSignAssembly=true -- --filter-method $test --report-xunit-xml --report-xunit-xml-filename result.xml --results-directory /work/results 2>&1 | Tee-Object -FilePath "$work/run.log" - $code = $LASTEXITCODE - if ($code -ne 0) { throw "Repository test failed with exit code $code. See $work/run.log" } - # Require exactly the original test, executed and passing, with no runner errors. - [xml] $report = Get-Content -LiteralPath "$work/results/result.xml" -Raw - $tests = @($report.SelectNodes('/assemblies/assembly/collection/test')) - $assemblies = @($report.SelectNodes('/assemblies/assembly')) - if ($assemblies.Count -ne 1 -or $assemblies[0].total -ne '1' -or $assemblies[0].passed -ne '1' -or - $assemblies[0].errors -ne '0' -or $tests.Count -ne 1 -or $tests[0].name -cne $test -or $tests[0].result -cne 'Pass') { - throw "Expected exactly one passing $test; inspect $work/results/result.xml" - } - Write-Host "Verified: $test (1 executed, 1 passed)." - } - catch { - # Preserve diagnostics outside the repository even though downloaded source is cleaned. - $diagnostics = "$work-diagnostics" - $null = New-Item -ItemType Directory -Path $diagnostics -Force - foreach ($name in @('run.log', 'results')) { - if (Test-Path -LiteralPath "$work/$name") { Copy-Item -LiteralPath "$work/$name" -Destination $diagnostics -Recurse } - } - Write-Warning "Execution not verified. Diagnostics: $diagnostics" - throw - } - finally { - $resolved = [IO.Path]::GetFullPath($work) - $temp = [IO.Path]::GetFullPath([IO.Path]::GetTempPath()).TrimEnd('/','\') + [IO.Path]::DirectorySeparatorChar - if (-not $resolved.StartsWith($temp, [StringComparison]::OrdinalIgnoreCase)) { throw 'Unsafe cleanup path.' } - Remove-Item -LiteralPath $resolved -Recurse -Force - } -} \ No newline at end of file diff --git a/.docfx/run-actions/38b60f4b4c1a588bbefe92f1/native.ps1 b/.docfx/run-actions/38b60f4b4c1a588bbefe92f1/native.ps1 deleted file mode 100644 index 7de020a..0000000 --- a/.docfx/run-actions/38b60f4b4c1a588bbefe92f1/native.ps1 +++ /dev/null @@ -1,50 +0,0 @@ -& { -#requires -Version 7.0 - $ErrorActionPreference = 'Stop' - $PSNativeCommandUseErrorActionPreference = $false - # Executes trusted repository build tasks and NuGet packages with your permissions. - # Review the pinned source before running; a container is not a security sandbox. - $null = Get-Command dotnet -ErrorAction Stop - $work = Join-Path ([IO.Path]::GetTempPath()) ('dx-' + [guid]::NewGuid().ToString('N').Substring(0, 8)) - $null = New-Item -ItemType Directory -Path $work - try { - $commit = '84b13767cb9484f8f3a36a71875662edfdb3e511' - Invoke-WebRequest "https://codeload.github.com/codebeltnet/xunit/zip/$commit" -OutFile "$work/source.zip" - Expand-Archive -LiteralPath "$work/source.zip" -DestinationPath "$work/extracted" - Move-Item -LiteralPath "$work/extracted/xunit-$commit" -Destination "$work/repo" - $project = 'test/Codebelt.Extensions.Xunit.Hosting.AspNetCore.FunctionalTests/Codebelt.Extensions.Xunit.Hosting.AspNetCore.FunctionalTests.csproj' - $test = 'Codebelt.Extensions.Xunit.Hosting.AspNetCore.WebApplicationTestFactoryTest.Create_ShouldApplyWebHostConfiguration_WhenWebHostSetupIsProvided' - Push-Location "$work/repo" - try { - dotnet run --project $project --framework net11.0 -p:SkipSignAssembly=true -- --filter-method $test --report-xunit-xml --report-xunit-xml-filename result.xml --results-directory "$work/results" 2>&1 | Tee-Object -FilePath "$work/run.log" - } - finally { Pop-Location } - $code = $LASTEXITCODE - if ($code -ne 0) { throw "Repository test failed with exit code $code. See $work/run.log" } - # Require exactly the original test, executed and passing, with no runner errors. - [xml] $report = Get-Content -LiteralPath "$work/results/result.xml" -Raw - $tests = @($report.SelectNodes('/assemblies/assembly/collection/test')) - $assemblies = @($report.SelectNodes('/assemblies/assembly')) - if ($assemblies.Count -ne 1 -or $assemblies[0].total -ne '1' -or $assemblies[0].passed -ne '1' -or - $assemblies[0].errors -ne '0' -or $tests.Count -ne 1 -or $tests[0].name -cne $test -or $tests[0].result -cne 'Pass') { - throw "Expected exactly one passing $test; inspect $work/results/result.xml" - } - Write-Host "Verified: $test (1 executed, 1 passed)." - } - catch { - # Preserve diagnostics outside the repository even though downloaded source is cleaned. - $diagnostics = "$work-diagnostics" - $null = New-Item -ItemType Directory -Path $diagnostics -Force - foreach ($name in @('run.log', 'results')) { - if (Test-Path -LiteralPath "$work/$name") { Copy-Item -LiteralPath "$work/$name" -Destination $diagnostics -Recurse } - } - Write-Warning "Execution not verified. Diagnostics: $diagnostics" - throw - } - finally { - $resolved = [IO.Path]::GetFullPath($work) - $temp = [IO.Path]::GetFullPath([IO.Path]::GetTempPath()).TrimEnd('/','\') + [IO.Path]::DirectorySeparatorChar - if (-not $resolved.StartsWith($temp, [StringComparison]::OrdinalIgnoreCase)) { throw 'Unsafe cleanup path.' } - Remove-Item -LiteralPath $resolved -Recurse -Force - } -} \ No newline at end of file diff --git a/.docfx/run-actions/3a1dbfc0e010519636b7091e/docker.ps1 b/.docfx/run-actions/3a1dbfc0e010519636b7091e/docker.ps1 deleted file mode 100644 index 031a28f..0000000 --- a/.docfx/run-actions/3a1dbfc0e010519636b7091e/docker.ps1 +++ /dev/null @@ -1,85 +0,0 @@ -& { -#requires -Version 7.0 -$ErrorActionPreference = 'Stop' -$PSNativeCommandUseErrorActionPreference = $false -$manifest = @' -{ - "dependsOn": [ - "Codebelt.Extensions.Xunit.Hosting.AspNetCore@13.0.0" - ], - "framework": "net10.0", - "frameworkReferences": [ - "Microsoft.AspNetCore.App" - ], - "mode": "console", - "schemaVersion": 1, - "sdk": "Microsoft.NET.Sdk.Web", - "source": "using System;\nusing Codebelt.Extensions.Xunit.Hosting.AspNetCore.Http;\n\nnamespace WebFixtureTests;\n\npublic class HttpContextExample\n{\n public void Demonstrate()\n {\n var accessor = new FakeHttpContextAccessor();\n Console.WriteLine(accessor.HttpContext.Request.Method);\n }\n}\n\ninternal static class RunExample\n{\n static void Main()\n {\n new HttpContextExample().Demonstrate();\n }\n}" -} -'@ -$OutputEncoding = [Text.UTF8Encoding]::new($false) -[Console]::OutputEncoding = $OutputEncoding -$verifyTests = $false -function Assert-CsrunTestOutput([string] $Output) { - $lines = @($Output -split '\r?\n') - $headers = @($lines | Where-Object { $_ -match '^Test run summary: Passed! - .+\)$' }) - if ($headers.Count -ne 1) { throw 'Expected exactly one completed xUnit test summary.' } - $headerIndex = [Array]::IndexOf($lines, $headers[0]) - $summaryLines = @($lines | Select-Object -Skip ($headerIndex + 1) -First 4) - $counts = @{} - foreach ($line in $summaryLines) { - if ($line -match '^\s*(total|failed|succeeded|skipped):\s*(\d+)\s*$') { $counts[$Matches[1]] = [int]$Matches[2] } - } - if ($counts.Count -ne 4) { throw 'The xUnit test summary counts are incomplete or ambiguous.' } - $failed = $counts.failed - $passed = $counts.succeeded - $skipped = $counts.skipped - $total = $counts.total - if ($total -lt 1 -or $passed -lt 1 -or $failed -ne 0 -or $skipped -ne 0 -or $passed -ne $total) { - throw 'Tests must execute at least once, all pass, and none fail or skip.' - } -} -# Downloads and executes the latest stable csrun release with your permissions. -# Source and release history: https://github.com/codebeltnet/csrun -$engineDirectory = Join-Path ([IO.Path]::GetTempPath()) ('csrun-' + [guid]::NewGuid().ToString('N')) -$null = New-Item -ItemType Directory -Path $engineDirectory -$enginePath = Join-Path $engineDirectory 'csrun.ps1' -$process = $null -try { - $release = Invoke-RestMethod 'https://api.github.com/repos/codebeltnet/csrun/releases/latest' - $assets = @($release.assets | Where-Object name -CEQ 'csrun.ps1') - if ($assets.Count -ne 1 -or $assets[0].digest -notmatch '^sha256:[0-9a-f]{64}$') { - throw "csrun release $($release.tag_name) must publish one csrun.ps1 asset with a SHA-256 digest." - } - $asset = $assets[0] - Invoke-WebRequest $asset.browser_download_url -OutFile $enginePath - $actualHash = (Get-FileHash -LiteralPath $enginePath -Algorithm SHA256).Hash - if ("sha256:$actualHash" -ne $asset.digest) { throw "csrun asset checksum mismatch: $actualHash" } -$enginePayload = [Convert]::ToBase64String([IO.File]::ReadAllBytes($enginePath)) -$containerInput = $enginePayload + "`n" + $manifest -$command = ' -$ErrorActionPreference = "Stop" -$enginePath = Join-Path ([IO.Path]::GetTempPath()) ("csrun-release-" + [guid]::NewGuid().ToString("N") + ".ps1") -$engineBytes = [Convert]::FromBase64String([Console]::In.ReadLine()) -[IO.File]::WriteAllBytes($enginePath, $engineBytes) -$manifest = [Console]::In.ReadToEnd() -& $enginePath -ManifestJson $manifest -exit $LASTEXITCODE -' -$output = (@($containerInput | & docker run --rm -i --entrypoint pwsh 'codebeltnet/csrun:10' -NoProfile -NonInteractive -Command $command) -join [Environment]::NewLine) -$process = [pscustomobject]@{ ExitCode = $LASTEXITCODE } -$diagnostics = '' -Write-Output $output -} catch { - [Console]::Error.WriteLine("csrun diagnostics retained in: $engineDirectory") - throw -} finally { - $resolvedTemp = [IO.Path]::TrimEndingDirectorySeparator([IO.Path]::GetFullPath([IO.Path]::GetTempPath())) - $resolvedEngineDirectory = [IO.Path]::GetFullPath($engineDirectory) - if ([IO.Path]::GetDirectoryName($resolvedEngineDirectory) -ne $resolvedTemp -or - [IO.Path]::GetFileName($resolvedEngineDirectory) -cnotmatch '^csrun-[a-f0-9]{32}$') { throw 'Unsafe cleanup path.' } - if ($process -and $process.ExitCode -eq 0) { Remove-Item -LiteralPath $resolvedEngineDirectory -Recurse -Force } -} -if ($process.ExitCode -ne 0) { throw "csrun execution failed with exit code $($process.ExitCode). $diagnostics" } -if ($verifyTests) { Assert-CsrunTestOutput $output } -} \ No newline at end of file diff --git a/.docfx/run-actions/3a1dbfc0e010519636b7091e/native.ps1 b/.docfx/run-actions/3a1dbfc0e010519636b7091e/native.ps1 deleted file mode 100644 index 0c24017..0000000 --- a/.docfx/run-actions/3a1dbfc0e010519636b7091e/native.ps1 +++ /dev/null @@ -1,88 +0,0 @@ -& { -#requires -Version 7.0 -$ErrorActionPreference = 'Stop' -$PSNativeCommandUseErrorActionPreference = $false -$manifest = @' -{ - "dependsOn": [ - "Codebelt.Extensions.Xunit.Hosting.AspNetCore@13.0.0" - ], - "framework": "net10.0", - "frameworkReferences": [ - "Microsoft.AspNetCore.App" - ], - "mode": "console", - "schemaVersion": 1, - "sdk": "Microsoft.NET.Sdk.Web", - "source": "using System;\nusing Codebelt.Extensions.Xunit.Hosting.AspNetCore.Http;\n\nnamespace WebFixtureTests;\n\npublic class HttpContextExample\n{\n public void Demonstrate()\n {\n var accessor = new FakeHttpContextAccessor();\n Console.WriteLine(accessor.HttpContext.Request.Method);\n }\n}\n\ninternal static class RunExample\n{\n static void Main()\n {\n new HttpContextExample().Demonstrate();\n }\n}" -} -'@ -$OutputEncoding = [Text.UTF8Encoding]::new($false) -[Console]::OutputEncoding = $OutputEncoding -$verifyTests = $false -function Assert-CsrunTestOutput([string] $Output) { - $lines = @($Output -split '\r?\n') - $headers = @($lines | Where-Object { $_ -match '^Test run summary: Passed! - .+\)$' }) - if ($headers.Count -ne 1) { throw 'Expected exactly one completed xUnit test summary.' } - $headerIndex = [Array]::IndexOf($lines, $headers[0]) - $summaryLines = @($lines | Select-Object -Skip ($headerIndex + 1) -First 4) - $counts = @{} - foreach ($line in $summaryLines) { - if ($line -match '^\s*(total|failed|succeeded|skipped):\s*(\d+)\s*$') { $counts[$Matches[1]] = [int]$Matches[2] } - } - if ($counts.Count -ne 4) { throw 'The xUnit test summary counts are incomplete or ambiguous.' } - $failed = $counts.failed - $passed = $counts.succeeded - $skipped = $counts.skipped - $total = $counts.total - if ($total -lt 1 -or $passed -lt 1 -or $failed -ne 0 -or $skipped -ne 0 -or $passed -ne $total) { - throw 'Tests must execute at least once, all pass, and none fail or skip.' - } -} -# Downloads and executes the latest stable csrun release with your permissions. -# Source and release history: https://github.com/codebeltnet/csrun -$engineDirectory = Join-Path ([IO.Path]::GetTempPath()) ('csrun-' + [guid]::NewGuid().ToString('N')) -$null = New-Item -ItemType Directory -Path $engineDirectory -$enginePath = Join-Path $engineDirectory 'csrun.ps1' -$process = $null -try { - $release = Invoke-RestMethod 'https://api.github.com/repos/codebeltnet/csrun/releases/latest' - $assets = @($release.assets | Where-Object name -CEQ 'csrun.ps1') - if ($assets.Count -ne 1 -or $assets[0].digest -notmatch '^sha256:[0-9a-f]{64}$') { - throw "csrun release $($release.tag_name) must publish one csrun.ps1 asset with a SHA-256 digest." - } - $asset = $assets[0] - Invoke-WebRequest $asset.browser_download_url -OutFile $enginePath - $actualHash = (Get-FileHash -LiteralPath $enginePath -Algorithm SHA256).Hash - if ("sha256:$actualHash" -ne $asset.digest) { throw "csrun asset checksum mismatch: $actualHash" } -$startInfo = [Diagnostics.ProcessStartInfo]::new('pwsh') -foreach ($argument in @('-NoProfile','-NonInteractive','-File')) { $startInfo.ArgumentList.Add($argument) } -$startInfo.ArgumentList.Add($enginePath) -$startInfo.ArgumentList.Add('-ManifestJson') -$startInfo.ArgumentList.Add($manifest) -$startInfo.RedirectStandardOutput = $true -$startInfo.RedirectStandardError = $true -$startInfo.UseShellExecute = $false -$process = [Diagnostics.Process]::new() -$process.StartInfo = $startInfo -if (-not $process.Start()) { throw 'Could not start csrun.' } -$stdoutTask = $process.StandardOutput.ReadToEndAsync() -$stderrTask = $process.StandardError.ReadToEndAsync() -$process.WaitForExit() -$output = $stdoutTask.GetAwaiter().GetResult() -$diagnostics = $stderrTask.GetAwaiter().GetResult() -Write-Output $output -if ($diagnostics) { [Console]::Error.Write($diagnostics) } -} catch { - [Console]::Error.WriteLine("csrun diagnostics retained in: $engineDirectory") - throw -} finally { - $resolvedTemp = [IO.Path]::TrimEndingDirectorySeparator([IO.Path]::GetFullPath([IO.Path]::GetTempPath())) - $resolvedEngineDirectory = [IO.Path]::GetFullPath($engineDirectory) - if ([IO.Path]::GetDirectoryName($resolvedEngineDirectory) -ne $resolvedTemp -or - [IO.Path]::GetFileName($resolvedEngineDirectory) -cnotmatch '^csrun-[a-f0-9]{32}$') { throw 'Unsafe cleanup path.' } - if ($process -and $process.ExitCode -eq 0) { Remove-Item -LiteralPath $resolvedEngineDirectory -Recurse -Force } -} -if ($process.ExitCode -ne 0) { throw "csrun execution failed with exit code $($process.ExitCode). $diagnostics" } -if ($verifyTests) { Assert-CsrunTestOutput $output } -} \ No newline at end of file diff --git a/.docfx/run-actions/3c3b98167b30d6985017ec27/docker.ps1 b/.docfx/run-actions/3c3b98167b30d6985017ec27/docker.ps1 deleted file mode 100644 index ce7eda5..0000000 --- a/.docfx/run-actions/3c3b98167b30d6985017ec27/docker.ps1 +++ /dev/null @@ -1,87 +0,0 @@ -& { -#requires -Version 7.0 -$ErrorActionPreference = 'Stop' -$PSNativeCommandUseErrorActionPreference = $false -$manifest = @' -{ - "dependsOn": [ - "Codebelt.Extensions.Xunit.Hosting.AspNetCore@13.0.0", - "Microsoft.Extensions.Hosting@10.0.15", - "Microsoft.AspNetCore.TestHost@10.0.15", - "xunit.v3@4.0.3" - ], - "framework": "net10.0", - "frameworkReferences": [ - "Microsoft.AspNetCore.App" - ], - "mode": "test", - "schemaVersion": 1, - "source": "using System.Threading.Tasks;\nusing Codebelt.Extensions.Xunit.Hosting.AspNetCore;\nusing Microsoft.AspNetCore.Builder;\nusing Microsoft.AspNetCore.Http;\nusing Microsoft.AspNetCore.TestHost;\nusing Microsoft.Extensions.DependencyInjection;\nusing Microsoft.Extensions.Hosting;\nusing Xunit;\n\nnamespace DeferredHealthEndpoint.Tests;\n\npublic sealed class SelfManagedWebMinimalHostFixtureExample\n{\n public async Task StartHealthEndpointWhenReadyAsync()\n {\n using var host = MinimalWebHostTestFactory.Create(\n services => services.AddSingleton(new HealthState(\"healthy\")),\n pipelineSetup: app => app.Run(context =>\n {\n var health = context.RequestServices.GetRequiredService();\n return context.Response.WriteAsync(health.Value);\n }),\n hostFixture: new SelfManagedWebMinimalHostFixture());\n\n await host.Host.StartAsync().ConfigureAwait(false);\n using var client = host.Host.GetTestClient();\n\n return await client.GetStringAsync(\"/\").ConfigureAwait(false);\n }\n}\n\npublic sealed record HealthState(string Value);\n\npublic sealed class RunExample\n{\n [Fact]\n public async Task ExercisesExample()\n {\n Assert.Equal(\"healthy\", await new SelfManagedWebMinimalHostFixtureExample().StartHealthEndpointWhenReadyAsync());\n }\n}" -} -'@ -$OutputEncoding = [Text.UTF8Encoding]::new($false) -[Console]::OutputEncoding = $OutputEncoding -$verifyTests = $true -function Assert-CsrunTestOutput([string] $Output) { - $lines = @($Output -split '\r?\n') - $headers = @($lines | Where-Object { $_ -match '^Test run summary: Passed! - .+\)$' }) - if ($headers.Count -ne 1) { throw 'Expected exactly one completed xUnit test summary.' } - $headerIndex = [Array]::IndexOf($lines, $headers[0]) - $summaryLines = @($lines | Select-Object -Skip ($headerIndex + 1) -First 4) - $counts = @{} - foreach ($line in $summaryLines) { - if ($line -match '^\s*(total|failed|succeeded|skipped):\s*(\d+)\s*$') { $counts[$Matches[1]] = [int]$Matches[2] } - } - if ($counts.Count -ne 4) { throw 'The xUnit test summary counts are incomplete or ambiguous.' } - $failed = $counts.failed - $passed = $counts.succeeded - $skipped = $counts.skipped - $total = $counts.total - if ($total -lt 1 -or $passed -lt 1 -or $failed -ne 0 -or $skipped -ne 0 -or $passed -ne $total) { - throw 'Tests must execute at least once, all pass, and none fail or skip.' - } -} -# Downloads and executes the latest stable csrun release with your permissions. -# Source and release history: https://github.com/codebeltnet/csrun -$engineDirectory = Join-Path ([IO.Path]::GetTempPath()) ('csrun-' + [guid]::NewGuid().ToString('N')) -$null = New-Item -ItemType Directory -Path $engineDirectory -$enginePath = Join-Path $engineDirectory 'csrun.ps1' -$process = $null -try { - $release = Invoke-RestMethod 'https://api.github.com/repos/codebeltnet/csrun/releases/latest' - $assets = @($release.assets | Where-Object name -CEQ 'csrun.ps1') - if ($assets.Count -ne 1 -or $assets[0].digest -notmatch '^sha256:[0-9a-f]{64}$') { - throw "csrun release $($release.tag_name) must publish one csrun.ps1 asset with a SHA-256 digest." - } - $asset = $assets[0] - Invoke-WebRequest $asset.browser_download_url -OutFile $enginePath - $actualHash = (Get-FileHash -LiteralPath $enginePath -Algorithm SHA256).Hash - if ("sha256:$actualHash" -ne $asset.digest) { throw "csrun asset checksum mismatch: $actualHash" } -$enginePayload = [Convert]::ToBase64String([IO.File]::ReadAllBytes($enginePath)) -$containerInput = $enginePayload + "`n" + $manifest -$command = ' -$ErrorActionPreference = "Stop" -$enginePath = Join-Path ([IO.Path]::GetTempPath()) ("csrun-release-" + [guid]::NewGuid().ToString("N") + ".ps1") -$engineBytes = [Convert]::FromBase64String([Console]::In.ReadLine()) -[IO.File]::WriteAllBytes($enginePath, $engineBytes) -$manifest = [Console]::In.ReadToEnd() -& $enginePath -ManifestJson $manifest -exit $LASTEXITCODE -' -$output = (@($containerInput | & docker run --rm -i --entrypoint pwsh 'codebeltnet/csrun:10' -NoProfile -NonInteractive -Command $command) -join [Environment]::NewLine) -$process = [pscustomobject]@{ ExitCode = $LASTEXITCODE } -$diagnostics = '' -Write-Output $output -} catch { - [Console]::Error.WriteLine("csrun diagnostics retained in: $engineDirectory") - throw -} finally { - $resolvedTemp = [IO.Path]::TrimEndingDirectorySeparator([IO.Path]::GetFullPath([IO.Path]::GetTempPath())) - $resolvedEngineDirectory = [IO.Path]::GetFullPath($engineDirectory) - if ([IO.Path]::GetDirectoryName($resolvedEngineDirectory) -ne $resolvedTemp -or - [IO.Path]::GetFileName($resolvedEngineDirectory) -cnotmatch '^csrun-[a-f0-9]{32}$') { throw 'Unsafe cleanup path.' } - if ($process -and $process.ExitCode -eq 0) { Remove-Item -LiteralPath $resolvedEngineDirectory -Recurse -Force } -} -if ($process.ExitCode -ne 0) { throw "csrun execution failed with exit code $($process.ExitCode). $diagnostics" } -if ($verifyTests) { Assert-CsrunTestOutput $output } -} \ No newline at end of file diff --git a/.docfx/run-actions/3c3b98167b30d6985017ec27/native.ps1 b/.docfx/run-actions/3c3b98167b30d6985017ec27/native.ps1 deleted file mode 100644 index 800c9e0..0000000 --- a/.docfx/run-actions/3c3b98167b30d6985017ec27/native.ps1 +++ /dev/null @@ -1,90 +0,0 @@ -& { -#requires -Version 7.0 -$ErrorActionPreference = 'Stop' -$PSNativeCommandUseErrorActionPreference = $false -$manifest = @' -{ - "dependsOn": [ - "Codebelt.Extensions.Xunit.Hosting.AspNetCore@13.0.0", - "Microsoft.Extensions.Hosting@10.0.15", - "Microsoft.AspNetCore.TestHost@10.0.15", - "xunit.v3@4.0.3" - ], - "framework": "net10.0", - "frameworkReferences": [ - "Microsoft.AspNetCore.App" - ], - "mode": "test", - "schemaVersion": 1, - "source": "using System.Threading.Tasks;\nusing Codebelt.Extensions.Xunit.Hosting.AspNetCore;\nusing Microsoft.AspNetCore.Builder;\nusing Microsoft.AspNetCore.Http;\nusing Microsoft.AspNetCore.TestHost;\nusing Microsoft.Extensions.DependencyInjection;\nusing Microsoft.Extensions.Hosting;\nusing Xunit;\n\nnamespace DeferredHealthEndpoint.Tests;\n\npublic sealed class SelfManagedWebMinimalHostFixtureExample\n{\n public async Task StartHealthEndpointWhenReadyAsync()\n {\n using var host = MinimalWebHostTestFactory.Create(\n services => services.AddSingleton(new HealthState(\"healthy\")),\n pipelineSetup: app => app.Run(context =>\n {\n var health = context.RequestServices.GetRequiredService();\n return context.Response.WriteAsync(health.Value);\n }),\n hostFixture: new SelfManagedWebMinimalHostFixture());\n\n await host.Host.StartAsync().ConfigureAwait(false);\n using var client = host.Host.GetTestClient();\n\n return await client.GetStringAsync(\"/\").ConfigureAwait(false);\n }\n}\n\npublic sealed record HealthState(string Value);\n\npublic sealed class RunExample\n{\n [Fact]\n public async Task ExercisesExample()\n {\n Assert.Equal(\"healthy\", await new SelfManagedWebMinimalHostFixtureExample().StartHealthEndpointWhenReadyAsync());\n }\n}" -} -'@ -$OutputEncoding = [Text.UTF8Encoding]::new($false) -[Console]::OutputEncoding = $OutputEncoding -$verifyTests = $true -function Assert-CsrunTestOutput([string] $Output) { - $lines = @($Output -split '\r?\n') - $headers = @($lines | Where-Object { $_ -match '^Test run summary: Passed! - .+\)$' }) - if ($headers.Count -ne 1) { throw 'Expected exactly one completed xUnit test summary.' } - $headerIndex = [Array]::IndexOf($lines, $headers[0]) - $summaryLines = @($lines | Select-Object -Skip ($headerIndex + 1) -First 4) - $counts = @{} - foreach ($line in $summaryLines) { - if ($line -match '^\s*(total|failed|succeeded|skipped):\s*(\d+)\s*$') { $counts[$Matches[1]] = [int]$Matches[2] } - } - if ($counts.Count -ne 4) { throw 'The xUnit test summary counts are incomplete or ambiguous.' } - $failed = $counts.failed - $passed = $counts.succeeded - $skipped = $counts.skipped - $total = $counts.total - if ($total -lt 1 -or $passed -lt 1 -or $failed -ne 0 -or $skipped -ne 0 -or $passed -ne $total) { - throw 'Tests must execute at least once, all pass, and none fail or skip.' - } -} -# Downloads and executes the latest stable csrun release with your permissions. -# Source and release history: https://github.com/codebeltnet/csrun -$engineDirectory = Join-Path ([IO.Path]::GetTempPath()) ('csrun-' + [guid]::NewGuid().ToString('N')) -$null = New-Item -ItemType Directory -Path $engineDirectory -$enginePath = Join-Path $engineDirectory 'csrun.ps1' -$process = $null -try { - $release = Invoke-RestMethod 'https://api.github.com/repos/codebeltnet/csrun/releases/latest' - $assets = @($release.assets | Where-Object name -CEQ 'csrun.ps1') - if ($assets.Count -ne 1 -or $assets[0].digest -notmatch '^sha256:[0-9a-f]{64}$') { - throw "csrun release $($release.tag_name) must publish one csrun.ps1 asset with a SHA-256 digest." - } - $asset = $assets[0] - Invoke-WebRequest $asset.browser_download_url -OutFile $enginePath - $actualHash = (Get-FileHash -LiteralPath $enginePath -Algorithm SHA256).Hash - if ("sha256:$actualHash" -ne $asset.digest) { throw "csrun asset checksum mismatch: $actualHash" } -$startInfo = [Diagnostics.ProcessStartInfo]::new('pwsh') -foreach ($argument in @('-NoProfile','-NonInteractive','-File')) { $startInfo.ArgumentList.Add($argument) } -$startInfo.ArgumentList.Add($enginePath) -$startInfo.ArgumentList.Add('-ManifestJson') -$startInfo.ArgumentList.Add($manifest) -$startInfo.RedirectStandardOutput = $true -$startInfo.RedirectStandardError = $true -$startInfo.UseShellExecute = $false -$process = [Diagnostics.Process]::new() -$process.StartInfo = $startInfo -if (-not $process.Start()) { throw 'Could not start csrun.' } -$stdoutTask = $process.StandardOutput.ReadToEndAsync() -$stderrTask = $process.StandardError.ReadToEndAsync() -$process.WaitForExit() -$output = $stdoutTask.GetAwaiter().GetResult() -$diagnostics = $stderrTask.GetAwaiter().GetResult() -Write-Output $output -if ($diagnostics) { [Console]::Error.Write($diagnostics) } -} catch { - [Console]::Error.WriteLine("csrun diagnostics retained in: $engineDirectory") - throw -} finally { - $resolvedTemp = [IO.Path]::TrimEndingDirectorySeparator([IO.Path]::GetFullPath([IO.Path]::GetTempPath())) - $resolvedEngineDirectory = [IO.Path]::GetFullPath($engineDirectory) - if ([IO.Path]::GetDirectoryName($resolvedEngineDirectory) -ne $resolvedTemp -or - [IO.Path]::GetFileName($resolvedEngineDirectory) -cnotmatch '^csrun-[a-f0-9]{32}$') { throw 'Unsafe cleanup path.' } - if ($process -and $process.ExitCode -eq 0) { Remove-Item -LiteralPath $resolvedEngineDirectory -Recurse -Force } -} -if ($process.ExitCode -ne 0) { throw "csrun execution failed with exit code $($process.ExitCode). $diagnostics" } -if ($verifyTests) { Assert-CsrunTestOutput $output } -} \ No newline at end of file diff --git a/.docfx/run-actions/45fcccef5fc861315b50c55e/docker.ps1 b/.docfx/run-actions/45fcccef5fc861315b50c55e/docker.ps1 deleted file mode 100644 index ddc09ef..0000000 --- a/.docfx/run-actions/45fcccef5fc861315b50c55e/docker.ps1 +++ /dev/null @@ -1,82 +0,0 @@ -& { -#requires -Version 7.0 -$ErrorActionPreference = 'Stop' -$PSNativeCommandUseErrorActionPreference = $false -$manifest = @' -{ - "dependsOn": [ - "Codebelt.Extensions.Xunit@13.0.0", - "xunit.v3@4.0.3" - ], - "framework": "net10.0", - "mode": "test", - "schemaVersion": 1, - "source": "using Codebelt.Extensions.Xunit;\nusing Xunit;\n\nnamespace Example.Tests;\n\npublic class OutputLinesTest : Test\n{\n public OutputLinesTest(ITestOutputHelper output) : base(output) { }\n\n [Fact]\n public void ShouldWriteValuesOnSeparateLines()\n {\n TestOutput.WriteLines(\"started\", 2, \"finished\");\n Assert.True(HasTestOutput);\n }\n}" -} -'@ -$OutputEncoding = [Text.UTF8Encoding]::new($false) -[Console]::OutputEncoding = $OutputEncoding -$verifyTests = $true -function Assert-CsrunTestOutput([string] $Output) { - $lines = @($Output -split '\r?\n') - $headers = @($lines | Where-Object { $_ -match '^Test run summary: Passed! - .+\)$' }) - if ($headers.Count -ne 1) { throw 'Expected exactly one completed xUnit test summary.' } - $headerIndex = [Array]::IndexOf($lines, $headers[0]) - $summaryLines = @($lines | Select-Object -Skip ($headerIndex + 1) -First 4) - $counts = @{} - foreach ($line in $summaryLines) { - if ($line -match '^\s*(total|failed|succeeded|skipped):\s*(\d+)\s*$') { $counts[$Matches[1]] = [int]$Matches[2] } - } - if ($counts.Count -ne 4) { throw 'The xUnit test summary counts are incomplete or ambiguous.' } - $failed = $counts.failed - $passed = $counts.succeeded - $skipped = $counts.skipped - $total = $counts.total - if ($total -lt 1 -or $passed -lt 1 -or $failed -ne 0 -or $skipped -ne 0 -or $passed -ne $total) { - throw 'Tests must execute at least once, all pass, and none fail or skip.' - } -} -# Downloads and executes the latest stable csrun release with your permissions. -# Source and release history: https://github.com/codebeltnet/csrun -$engineDirectory = Join-Path ([IO.Path]::GetTempPath()) ('csrun-' + [guid]::NewGuid().ToString('N')) -$null = New-Item -ItemType Directory -Path $engineDirectory -$enginePath = Join-Path $engineDirectory 'csrun.ps1' -$process = $null -try { - $release = Invoke-RestMethod 'https://api.github.com/repos/codebeltnet/csrun/releases/latest' - $assets = @($release.assets | Where-Object name -CEQ 'csrun.ps1') - if ($assets.Count -ne 1 -or $assets[0].digest -notmatch '^sha256:[0-9a-f]{64}$') { - throw "csrun release $($release.tag_name) must publish one csrun.ps1 asset with a SHA-256 digest." - } - $asset = $assets[0] - Invoke-WebRequest $asset.browser_download_url -OutFile $enginePath - $actualHash = (Get-FileHash -LiteralPath $enginePath -Algorithm SHA256).Hash - if ("sha256:$actualHash" -ne $asset.digest) { throw "csrun asset checksum mismatch: $actualHash" } -$enginePayload = [Convert]::ToBase64String([IO.File]::ReadAllBytes($enginePath)) -$containerInput = $enginePayload + "`n" + $manifest -$command = ' -$ErrorActionPreference = "Stop" -$enginePath = Join-Path ([IO.Path]::GetTempPath()) ("csrun-release-" + [guid]::NewGuid().ToString("N") + ".ps1") -$engineBytes = [Convert]::FromBase64String([Console]::In.ReadLine()) -[IO.File]::WriteAllBytes($enginePath, $engineBytes) -$manifest = [Console]::In.ReadToEnd() -& $enginePath -ManifestJson $manifest -exit $LASTEXITCODE -' -$output = (@($containerInput | & docker run --rm -i --entrypoint pwsh 'codebeltnet/csrun:10' -NoProfile -NonInteractive -Command $command) -join [Environment]::NewLine) -$process = [pscustomobject]@{ ExitCode = $LASTEXITCODE } -$diagnostics = '' -Write-Output $output -} catch { - [Console]::Error.WriteLine("csrun diagnostics retained in: $engineDirectory") - throw -} finally { - $resolvedTemp = [IO.Path]::TrimEndingDirectorySeparator([IO.Path]::GetFullPath([IO.Path]::GetTempPath())) - $resolvedEngineDirectory = [IO.Path]::GetFullPath($engineDirectory) - if ([IO.Path]::GetDirectoryName($resolvedEngineDirectory) -ne $resolvedTemp -or - [IO.Path]::GetFileName($resolvedEngineDirectory) -cnotmatch '^csrun-[a-f0-9]{32}$') { throw 'Unsafe cleanup path.' } - if ($process -and $process.ExitCode -eq 0) { Remove-Item -LiteralPath $resolvedEngineDirectory -Recurse -Force } -} -if ($process.ExitCode -ne 0) { throw "csrun execution failed with exit code $($process.ExitCode). $diagnostics" } -if ($verifyTests) { Assert-CsrunTestOutput $output } -} \ No newline at end of file diff --git a/.docfx/run-actions/45fcccef5fc861315b50c55e/native.ps1 b/.docfx/run-actions/45fcccef5fc861315b50c55e/native.ps1 deleted file mode 100644 index 06b50f4..0000000 --- a/.docfx/run-actions/45fcccef5fc861315b50c55e/native.ps1 +++ /dev/null @@ -1,85 +0,0 @@ -& { -#requires -Version 7.0 -$ErrorActionPreference = 'Stop' -$PSNativeCommandUseErrorActionPreference = $false -$manifest = @' -{ - "dependsOn": [ - "Codebelt.Extensions.Xunit@13.0.0", - "xunit.v3@4.0.3" - ], - "framework": "net10.0", - "mode": "test", - "schemaVersion": 1, - "source": "using Codebelt.Extensions.Xunit;\nusing Xunit;\n\nnamespace Example.Tests;\n\npublic class OutputLinesTest : Test\n{\n public OutputLinesTest(ITestOutputHelper output) : base(output) { }\n\n [Fact]\n public void ShouldWriteValuesOnSeparateLines()\n {\n TestOutput.WriteLines(\"started\", 2, \"finished\");\n Assert.True(HasTestOutput);\n }\n}" -} -'@ -$OutputEncoding = [Text.UTF8Encoding]::new($false) -[Console]::OutputEncoding = $OutputEncoding -$verifyTests = $true -function Assert-CsrunTestOutput([string] $Output) { - $lines = @($Output -split '\r?\n') - $headers = @($lines | Where-Object { $_ -match '^Test run summary: Passed! - .+\)$' }) - if ($headers.Count -ne 1) { throw 'Expected exactly one completed xUnit test summary.' } - $headerIndex = [Array]::IndexOf($lines, $headers[0]) - $summaryLines = @($lines | Select-Object -Skip ($headerIndex + 1) -First 4) - $counts = @{} - foreach ($line in $summaryLines) { - if ($line -match '^\s*(total|failed|succeeded|skipped):\s*(\d+)\s*$') { $counts[$Matches[1]] = [int]$Matches[2] } - } - if ($counts.Count -ne 4) { throw 'The xUnit test summary counts are incomplete or ambiguous.' } - $failed = $counts.failed - $passed = $counts.succeeded - $skipped = $counts.skipped - $total = $counts.total - if ($total -lt 1 -or $passed -lt 1 -or $failed -ne 0 -or $skipped -ne 0 -or $passed -ne $total) { - throw 'Tests must execute at least once, all pass, and none fail or skip.' - } -} -# Downloads and executes the latest stable csrun release with your permissions. -# Source and release history: https://github.com/codebeltnet/csrun -$engineDirectory = Join-Path ([IO.Path]::GetTempPath()) ('csrun-' + [guid]::NewGuid().ToString('N')) -$null = New-Item -ItemType Directory -Path $engineDirectory -$enginePath = Join-Path $engineDirectory 'csrun.ps1' -$process = $null -try { - $release = Invoke-RestMethod 'https://api.github.com/repos/codebeltnet/csrun/releases/latest' - $assets = @($release.assets | Where-Object name -CEQ 'csrun.ps1') - if ($assets.Count -ne 1 -or $assets[0].digest -notmatch '^sha256:[0-9a-f]{64}$') { - throw "csrun release $($release.tag_name) must publish one csrun.ps1 asset with a SHA-256 digest." - } - $asset = $assets[0] - Invoke-WebRequest $asset.browser_download_url -OutFile $enginePath - $actualHash = (Get-FileHash -LiteralPath $enginePath -Algorithm SHA256).Hash - if ("sha256:$actualHash" -ne $asset.digest) { throw "csrun asset checksum mismatch: $actualHash" } -$startInfo = [Diagnostics.ProcessStartInfo]::new('pwsh') -foreach ($argument in @('-NoProfile','-NonInteractive','-File')) { $startInfo.ArgumentList.Add($argument) } -$startInfo.ArgumentList.Add($enginePath) -$startInfo.ArgumentList.Add('-ManifestJson') -$startInfo.ArgumentList.Add($manifest) -$startInfo.RedirectStandardOutput = $true -$startInfo.RedirectStandardError = $true -$startInfo.UseShellExecute = $false -$process = [Diagnostics.Process]::new() -$process.StartInfo = $startInfo -if (-not $process.Start()) { throw 'Could not start csrun.' } -$stdoutTask = $process.StandardOutput.ReadToEndAsync() -$stderrTask = $process.StandardError.ReadToEndAsync() -$process.WaitForExit() -$output = $stdoutTask.GetAwaiter().GetResult() -$diagnostics = $stderrTask.GetAwaiter().GetResult() -Write-Output $output -if ($diagnostics) { [Console]::Error.Write($diagnostics) } -} catch { - [Console]::Error.WriteLine("csrun diagnostics retained in: $engineDirectory") - throw -} finally { - $resolvedTemp = [IO.Path]::TrimEndingDirectorySeparator([IO.Path]::GetFullPath([IO.Path]::GetTempPath())) - $resolvedEngineDirectory = [IO.Path]::GetFullPath($engineDirectory) - if ([IO.Path]::GetDirectoryName($resolvedEngineDirectory) -ne $resolvedTemp -or - [IO.Path]::GetFileName($resolvedEngineDirectory) -cnotmatch '^csrun-[a-f0-9]{32}$') { throw 'Unsafe cleanup path.' } - if ($process -and $process.ExitCode -eq 0) { Remove-Item -LiteralPath $resolvedEngineDirectory -Recurse -Force } -} -if ($process.ExitCode -ne 0) { throw "csrun execution failed with exit code $($process.ExitCode). $diagnostics" } -if ($verifyTests) { Assert-CsrunTestOutput $output } -} \ No newline at end of file diff --git a/.docfx/run-actions/4c5e94adccd20cab4da52078/docker.ps1 b/.docfx/run-actions/4c5e94adccd20cab4da52078/docker.ps1 deleted file mode 100644 index 7a80062..0000000 --- a/.docfx/run-actions/4c5e94adccd20cab4da52078/docker.ps1 +++ /dev/null @@ -1,58 +0,0 @@ -& { -#requires -Version 7.0 - $ErrorActionPreference = 'Stop' - $PSNativeCommandUseErrorActionPreference = $false - # Executes trusted repository build tasks and NuGet packages with your permissions. - # Review the pinned source before running; a container is not a security sandbox. - $null = Get-Command docker -ErrorAction Stop - docker info *> $null - if ($LASTEXITCODE -ne 0) { throw 'Docker daemon unavailable.' } - $work = Join-Path ([IO.Path]::GetTempPath()) ('dx-' + [guid]::NewGuid().ToString('N').Substring(0, 8)) - $null = New-Item -ItemType Directory -Path $work - try { - $commit = '84b13767cb9484f8f3a36a71875662edfdb3e511' - Invoke-WebRequest "https://codeload.github.com/codebeltnet/xunit/zip/$commit" -OutFile "$work/source.zip" - Expand-Archive -LiteralPath "$work/source.zip" -DestinationPath "$work/extracted" - Move-Item -LiteralPath "$work/extracted/xunit-$commit" -Destination "$work/repo" - $project = 'test/Codebelt.Extensions.Xunit.Hosting.AspNetCore.FunctionalTests/Codebelt.Extensions.Xunit.Hosting.AspNetCore.FunctionalTests.csproj' - $test = 'Codebelt.Extensions.Xunit.Hosting.AspNetCore.WebApplicationTestTest.ShouldBootstrapApplication_WhenEntryPointUsesModernProgramPattern' - $dockerUser = @() - if ($IsLinux) { - # Keep bind-mounted build output removable by the host user. - $hostUid = id -u - if ($LASTEXITCODE -ne 0) { throw 'Cannot resolve host UID.' } - $hostGid = id -g - if ($LASTEXITCODE -ne 0) { throw 'Cannot resolve host GID.' } - $dockerUser = @('--user', "${hostUid}:${hostGid}") - } - # Let Docker's init reap orphaned build processes and keep build servers disposable. - docker run --rm --init @dockerUser --env HOME=/tmp --env DOTNET_CLI_HOME=/tmp --env MSBUILDDISABLENODEREUSE=1 --mount "type=bind,source=$work,target=/work" --workdir /work/repo mcr.microsoft.com/dotnet/sdk:11.0 dotnet run --disable-build-servers --project $project --framework net11.0 -p:SkipSignAssembly=true -- --filter-method $test --report-xunit-xml --report-xunit-xml-filename result.xml --results-directory /work/results 2>&1 | Tee-Object -FilePath "$work/run.log" - $code = $LASTEXITCODE - if ($code -ne 0) { throw "Repository test failed with exit code $code. See $work/run.log" } - # Require exactly the original test, executed and passing, with no runner errors. - [xml] $report = Get-Content -LiteralPath "$work/results/result.xml" -Raw - $tests = @($report.SelectNodes('/assemblies/assembly/collection/test')) - $assemblies = @($report.SelectNodes('/assemblies/assembly')) - if ($assemblies.Count -ne 1 -or $assemblies[0].total -ne '1' -or $assemblies[0].passed -ne '1' -or - $assemblies[0].errors -ne '0' -or $tests.Count -ne 1 -or $tests[0].name -cne $test -or $tests[0].result -cne 'Pass') { - throw "Expected exactly one passing $test; inspect $work/results/result.xml" - } - Write-Host "Verified: $test (1 executed, 1 passed)." - } - catch { - # Preserve diagnostics outside the repository even though downloaded source is cleaned. - $diagnostics = "$work-diagnostics" - $null = New-Item -ItemType Directory -Path $diagnostics -Force - foreach ($name in @('run.log', 'results')) { - if (Test-Path -LiteralPath "$work/$name") { Copy-Item -LiteralPath "$work/$name" -Destination $diagnostics -Recurse } - } - Write-Warning "Execution not verified. Diagnostics: $diagnostics" - throw - } - finally { - $resolved = [IO.Path]::GetFullPath($work) - $temp = [IO.Path]::GetFullPath([IO.Path]::GetTempPath()).TrimEnd('/','\') + [IO.Path]::DirectorySeparatorChar - if (-not $resolved.StartsWith($temp, [StringComparison]::OrdinalIgnoreCase)) { throw 'Unsafe cleanup path.' } - Remove-Item -LiteralPath $resolved -Recurse -Force - } -} \ No newline at end of file diff --git a/.docfx/run-actions/4c5e94adccd20cab4da52078/native.ps1 b/.docfx/run-actions/4c5e94adccd20cab4da52078/native.ps1 deleted file mode 100644 index 44884f2..0000000 --- a/.docfx/run-actions/4c5e94adccd20cab4da52078/native.ps1 +++ /dev/null @@ -1,50 +0,0 @@ -& { -#requires -Version 7.0 - $ErrorActionPreference = 'Stop' - $PSNativeCommandUseErrorActionPreference = $false - # Executes trusted repository build tasks and NuGet packages with your permissions. - # Review the pinned source before running; a container is not a security sandbox. - $null = Get-Command dotnet -ErrorAction Stop - $work = Join-Path ([IO.Path]::GetTempPath()) ('dx-' + [guid]::NewGuid().ToString('N').Substring(0, 8)) - $null = New-Item -ItemType Directory -Path $work - try { - $commit = '84b13767cb9484f8f3a36a71875662edfdb3e511' - Invoke-WebRequest "https://codeload.github.com/codebeltnet/xunit/zip/$commit" -OutFile "$work/source.zip" - Expand-Archive -LiteralPath "$work/source.zip" -DestinationPath "$work/extracted" - Move-Item -LiteralPath "$work/extracted/xunit-$commit" -Destination "$work/repo" - $project = 'test/Codebelt.Extensions.Xunit.Hosting.AspNetCore.FunctionalTests/Codebelt.Extensions.Xunit.Hosting.AspNetCore.FunctionalTests.csproj' - $test = 'Codebelt.Extensions.Xunit.Hosting.AspNetCore.WebApplicationTestTest.ShouldBootstrapApplication_WhenEntryPointUsesModernProgramPattern' - Push-Location "$work/repo" - try { - dotnet run --project $project --framework net11.0 -p:SkipSignAssembly=true -- --filter-method $test --report-xunit-xml --report-xunit-xml-filename result.xml --results-directory "$work/results" 2>&1 | Tee-Object -FilePath "$work/run.log" - } - finally { Pop-Location } - $code = $LASTEXITCODE - if ($code -ne 0) { throw "Repository test failed with exit code $code. See $work/run.log" } - # Require exactly the original test, executed and passing, with no runner errors. - [xml] $report = Get-Content -LiteralPath "$work/results/result.xml" -Raw - $tests = @($report.SelectNodes('/assemblies/assembly/collection/test')) - $assemblies = @($report.SelectNodes('/assemblies/assembly')) - if ($assemblies.Count -ne 1 -or $assemblies[0].total -ne '1' -or $assemblies[0].passed -ne '1' -or - $assemblies[0].errors -ne '0' -or $tests.Count -ne 1 -or $tests[0].name -cne $test -or $tests[0].result -cne 'Pass') { - throw "Expected exactly one passing $test; inspect $work/results/result.xml" - } - Write-Host "Verified: $test (1 executed, 1 passed)." - } - catch { - # Preserve diagnostics outside the repository even though downloaded source is cleaned. - $diagnostics = "$work-diagnostics" - $null = New-Item -ItemType Directory -Path $diagnostics -Force - foreach ($name in @('run.log', 'results')) { - if (Test-Path -LiteralPath "$work/$name") { Copy-Item -LiteralPath "$work/$name" -Destination $diagnostics -Recurse } - } - Write-Warning "Execution not verified. Diagnostics: $diagnostics" - throw - } - finally { - $resolved = [IO.Path]::GetFullPath($work) - $temp = [IO.Path]::GetFullPath([IO.Path]::GetTempPath()).TrimEnd('/','\') + [IO.Path]::DirectorySeparatorChar - if (-not $resolved.StartsWith($temp, [StringComparison]::OrdinalIgnoreCase)) { throw 'Unsafe cleanup path.' } - Remove-Item -LiteralPath $resolved -Recurse -Force - } -} \ No newline at end of file diff --git a/.docfx/run-actions/513a785b0e0abbe2284270b9/docker.ps1 b/.docfx/run-actions/513a785b0e0abbe2284270b9/docker.ps1 deleted file mode 100644 index 985b55c..0000000 --- a/.docfx/run-actions/513a785b0e0abbe2284270b9/docker.ps1 +++ /dev/null @@ -1,83 +0,0 @@ -& { -#requires -Version 7.0 -$ErrorActionPreference = 'Stop' -$PSNativeCommandUseErrorActionPreference = $false -$manifest = @' -{ - "dependsOn": [ - "Codebelt.Extensions.Xunit.Hosting@13.0.0", - "Microsoft.Extensions.Hosting@10.0.15", - "xunit.v3@4.0.3" - ], - "framework": "net10.0", - "mode": "test", - "schemaVersion": 1, - "source": "using Codebelt.Extensions.Xunit;\nusing Codebelt.Extensions.Xunit.Hosting;\nusing Microsoft.Extensions.DependencyInjection;\nusing Microsoft.Extensions.Logging;\nusing Xunit;\n\nnamespace HostFixtureTests;\n\npublic class LogInspector\n{\n public ITestStore GetEntries(ILogger logger)\n {\n return logger.GetTestStore();\n }\n\n public ITestStore GetEntries(ILogger logger)\n {\n return logger.GetTestStore();\n }\n}\n\npublic sealed class RunExample\n{\n [Fact]\n public void ExercisesExample()\n {\n var services = new ServiceCollection();\n services.AddXunitTestLogging();\n using var provider = services.BuildServiceProvider();\n var logger = provider.GetRequiredService>();\n logger.LogWarning(\"queue ready\");\n var inspector = new LogInspector();\n Assert.Contains(inspector.GetEntries((ILogger)logger).Query(), entry => entry.Severity == LogLevel.Warning && entry.Message == \"Warning: queue ready\");\n Assert.Contains(inspector.GetEntries(logger).Query(), entry => entry.Severity == LogLevel.Warning && entry.Message == \"Warning: queue ready\");\n }\n}" -} -'@ -$OutputEncoding = [Text.UTF8Encoding]::new($false) -[Console]::OutputEncoding = $OutputEncoding -$verifyTests = $true -function Assert-CsrunTestOutput([string] $Output) { - $lines = @($Output -split '\r?\n') - $headers = @($lines | Where-Object { $_ -match '^Test run summary: Passed! - .+\)$' }) - if ($headers.Count -ne 1) { throw 'Expected exactly one completed xUnit test summary.' } - $headerIndex = [Array]::IndexOf($lines, $headers[0]) - $summaryLines = @($lines | Select-Object -Skip ($headerIndex + 1) -First 4) - $counts = @{} - foreach ($line in $summaryLines) { - if ($line -match '^\s*(total|failed|succeeded|skipped):\s*(\d+)\s*$') { $counts[$Matches[1]] = [int]$Matches[2] } - } - if ($counts.Count -ne 4) { throw 'The xUnit test summary counts are incomplete or ambiguous.' } - $failed = $counts.failed - $passed = $counts.succeeded - $skipped = $counts.skipped - $total = $counts.total - if ($total -lt 1 -or $passed -lt 1 -or $failed -ne 0 -or $skipped -ne 0 -or $passed -ne $total) { - throw 'Tests must execute at least once, all pass, and none fail or skip.' - } -} -# Downloads and executes the latest stable csrun release with your permissions. -# Source and release history: https://github.com/codebeltnet/csrun -$engineDirectory = Join-Path ([IO.Path]::GetTempPath()) ('csrun-' + [guid]::NewGuid().ToString('N')) -$null = New-Item -ItemType Directory -Path $engineDirectory -$enginePath = Join-Path $engineDirectory 'csrun.ps1' -$process = $null -try { - $release = Invoke-RestMethod 'https://api.github.com/repos/codebeltnet/csrun/releases/latest' - $assets = @($release.assets | Where-Object name -CEQ 'csrun.ps1') - if ($assets.Count -ne 1 -or $assets[0].digest -notmatch '^sha256:[0-9a-f]{64}$') { - throw "csrun release $($release.tag_name) must publish one csrun.ps1 asset with a SHA-256 digest." - } - $asset = $assets[0] - Invoke-WebRequest $asset.browser_download_url -OutFile $enginePath - $actualHash = (Get-FileHash -LiteralPath $enginePath -Algorithm SHA256).Hash - if ("sha256:$actualHash" -ne $asset.digest) { throw "csrun asset checksum mismatch: $actualHash" } -$enginePayload = [Convert]::ToBase64String([IO.File]::ReadAllBytes($enginePath)) -$containerInput = $enginePayload + "`n" + $manifest -$command = ' -$ErrorActionPreference = "Stop" -$enginePath = Join-Path ([IO.Path]::GetTempPath()) ("csrun-release-" + [guid]::NewGuid().ToString("N") + ".ps1") -$engineBytes = [Convert]::FromBase64String([Console]::In.ReadLine()) -[IO.File]::WriteAllBytes($enginePath, $engineBytes) -$manifest = [Console]::In.ReadToEnd() -& $enginePath -ManifestJson $manifest -exit $LASTEXITCODE -' -$output = (@($containerInput | & docker run --rm -i --entrypoint pwsh 'codebeltnet/csrun:10' -NoProfile -NonInteractive -Command $command) -join [Environment]::NewLine) -$process = [pscustomobject]@{ ExitCode = $LASTEXITCODE } -$diagnostics = '' -Write-Output $output -} catch { - [Console]::Error.WriteLine("csrun diagnostics retained in: $engineDirectory") - throw -} finally { - $resolvedTemp = [IO.Path]::TrimEndingDirectorySeparator([IO.Path]::GetFullPath([IO.Path]::GetTempPath())) - $resolvedEngineDirectory = [IO.Path]::GetFullPath($engineDirectory) - if ([IO.Path]::GetDirectoryName($resolvedEngineDirectory) -ne $resolvedTemp -or - [IO.Path]::GetFileName($resolvedEngineDirectory) -cnotmatch '^csrun-[a-f0-9]{32}$') { throw 'Unsafe cleanup path.' } - if ($process -and $process.ExitCode -eq 0) { Remove-Item -LiteralPath $resolvedEngineDirectory -Recurse -Force } -} -if ($process.ExitCode -ne 0) { throw "csrun execution failed with exit code $($process.ExitCode). $diagnostics" } -if ($verifyTests) { Assert-CsrunTestOutput $output } -} \ No newline at end of file diff --git a/.docfx/run-actions/513a785b0e0abbe2284270b9/native.ps1 b/.docfx/run-actions/513a785b0e0abbe2284270b9/native.ps1 deleted file mode 100644 index a3942c6..0000000 --- a/.docfx/run-actions/513a785b0e0abbe2284270b9/native.ps1 +++ /dev/null @@ -1,86 +0,0 @@ -& { -#requires -Version 7.0 -$ErrorActionPreference = 'Stop' -$PSNativeCommandUseErrorActionPreference = $false -$manifest = @' -{ - "dependsOn": [ - "Codebelt.Extensions.Xunit.Hosting@13.0.0", - "Microsoft.Extensions.Hosting@10.0.15", - "xunit.v3@4.0.3" - ], - "framework": "net10.0", - "mode": "test", - "schemaVersion": 1, - "source": "using Codebelt.Extensions.Xunit;\nusing Codebelt.Extensions.Xunit.Hosting;\nusing Microsoft.Extensions.DependencyInjection;\nusing Microsoft.Extensions.Logging;\nusing Xunit;\n\nnamespace HostFixtureTests;\n\npublic class LogInspector\n{\n public ITestStore GetEntries(ILogger logger)\n {\n return logger.GetTestStore();\n }\n\n public ITestStore GetEntries(ILogger logger)\n {\n return logger.GetTestStore();\n }\n}\n\npublic sealed class RunExample\n{\n [Fact]\n public void ExercisesExample()\n {\n var services = new ServiceCollection();\n services.AddXunitTestLogging();\n using var provider = services.BuildServiceProvider();\n var logger = provider.GetRequiredService>();\n logger.LogWarning(\"queue ready\");\n var inspector = new LogInspector();\n Assert.Contains(inspector.GetEntries((ILogger)logger).Query(), entry => entry.Severity == LogLevel.Warning && entry.Message == \"Warning: queue ready\");\n Assert.Contains(inspector.GetEntries(logger).Query(), entry => entry.Severity == LogLevel.Warning && entry.Message == \"Warning: queue ready\");\n }\n}" -} -'@ -$OutputEncoding = [Text.UTF8Encoding]::new($false) -[Console]::OutputEncoding = $OutputEncoding -$verifyTests = $true -function Assert-CsrunTestOutput([string] $Output) { - $lines = @($Output -split '\r?\n') - $headers = @($lines | Where-Object { $_ -match '^Test run summary: Passed! - .+\)$' }) - if ($headers.Count -ne 1) { throw 'Expected exactly one completed xUnit test summary.' } - $headerIndex = [Array]::IndexOf($lines, $headers[0]) - $summaryLines = @($lines | Select-Object -Skip ($headerIndex + 1) -First 4) - $counts = @{} - foreach ($line in $summaryLines) { - if ($line -match '^\s*(total|failed|succeeded|skipped):\s*(\d+)\s*$') { $counts[$Matches[1]] = [int]$Matches[2] } - } - if ($counts.Count -ne 4) { throw 'The xUnit test summary counts are incomplete or ambiguous.' } - $failed = $counts.failed - $passed = $counts.succeeded - $skipped = $counts.skipped - $total = $counts.total - if ($total -lt 1 -or $passed -lt 1 -or $failed -ne 0 -or $skipped -ne 0 -or $passed -ne $total) { - throw 'Tests must execute at least once, all pass, and none fail or skip.' - } -} -# Downloads and executes the latest stable csrun release with your permissions. -# Source and release history: https://github.com/codebeltnet/csrun -$engineDirectory = Join-Path ([IO.Path]::GetTempPath()) ('csrun-' + [guid]::NewGuid().ToString('N')) -$null = New-Item -ItemType Directory -Path $engineDirectory -$enginePath = Join-Path $engineDirectory 'csrun.ps1' -$process = $null -try { - $release = Invoke-RestMethod 'https://api.github.com/repos/codebeltnet/csrun/releases/latest' - $assets = @($release.assets | Where-Object name -CEQ 'csrun.ps1') - if ($assets.Count -ne 1 -or $assets[0].digest -notmatch '^sha256:[0-9a-f]{64}$') { - throw "csrun release $($release.tag_name) must publish one csrun.ps1 asset with a SHA-256 digest." - } - $asset = $assets[0] - Invoke-WebRequest $asset.browser_download_url -OutFile $enginePath - $actualHash = (Get-FileHash -LiteralPath $enginePath -Algorithm SHA256).Hash - if ("sha256:$actualHash" -ne $asset.digest) { throw "csrun asset checksum mismatch: $actualHash" } -$startInfo = [Diagnostics.ProcessStartInfo]::new('pwsh') -foreach ($argument in @('-NoProfile','-NonInteractive','-File')) { $startInfo.ArgumentList.Add($argument) } -$startInfo.ArgumentList.Add($enginePath) -$startInfo.ArgumentList.Add('-ManifestJson') -$startInfo.ArgumentList.Add($manifest) -$startInfo.RedirectStandardOutput = $true -$startInfo.RedirectStandardError = $true -$startInfo.UseShellExecute = $false -$process = [Diagnostics.Process]::new() -$process.StartInfo = $startInfo -if (-not $process.Start()) { throw 'Could not start csrun.' } -$stdoutTask = $process.StandardOutput.ReadToEndAsync() -$stderrTask = $process.StandardError.ReadToEndAsync() -$process.WaitForExit() -$output = $stdoutTask.GetAwaiter().GetResult() -$diagnostics = $stderrTask.GetAwaiter().GetResult() -Write-Output $output -if ($diagnostics) { [Console]::Error.Write($diagnostics) } -} catch { - [Console]::Error.WriteLine("csrun diagnostics retained in: $engineDirectory") - throw -} finally { - $resolvedTemp = [IO.Path]::TrimEndingDirectorySeparator([IO.Path]::GetFullPath([IO.Path]::GetTempPath())) - $resolvedEngineDirectory = [IO.Path]::GetFullPath($engineDirectory) - if ([IO.Path]::GetDirectoryName($resolvedEngineDirectory) -ne $resolvedTemp -or - [IO.Path]::GetFileName($resolvedEngineDirectory) -cnotmatch '^csrun-[a-f0-9]{32}$') { throw 'Unsafe cleanup path.' } - if ($process -and $process.ExitCode -eq 0) { Remove-Item -LiteralPath $resolvedEngineDirectory -Recurse -Force } -} -if ($process.ExitCode -ne 0) { throw "csrun execution failed with exit code $($process.ExitCode). $diagnostics" } -if ($verifyTests) { Assert-CsrunTestOutput $output } -} \ No newline at end of file diff --git a/.docfx/run-actions/515575be5bb7683cac9903a5/docker.ps1 b/.docfx/run-actions/515575be5bb7683cac9903a5/docker.ps1 deleted file mode 100644 index 287cef2..0000000 --- a/.docfx/run-actions/515575be5bb7683cac9903a5/docker.ps1 +++ /dev/null @@ -1,83 +0,0 @@ -& { -#requires -Version 7.0 -$ErrorActionPreference = 'Stop' -$PSNativeCommandUseErrorActionPreference = $false -$manifest = @' -{ - "dependsOn": [ - "Codebelt.Extensions.Xunit.Hosting@13.0.0", - "Microsoft.Extensions.Hosting@10.0.15", - "xunit.v3@4.0.3" - ], - "framework": "net10.0", - "mode": "test", - "schemaVersion": 1, - "source": "using System.Threading.Tasks;\nusing Codebelt.Extensions.Xunit.Hosting;\nusing Microsoft.Extensions.DependencyInjection;\nusing Microsoft.Extensions.Hosting;\nusing Xunit;\n\nnamespace WorkerLifecycle.Tests;\n\npublic sealed class SelfManagedHostFixtureExample\n{\n public async Task StartAfterAttachingObserverAsync()\n {\n using var host = HostTestFactory.Create(\n hostFixture: new SelfManagedHostFixture());\n\n var started = false;\n var lifetime = host.Host.Services.GetRequiredService();\n using var registration = lifetime.ApplicationStarted.Register(() => started = true);\n\n Assert.False(started);\n await host.Host.StartAsync().ConfigureAwait(false);\n Assert.True(started);\n }\n}\n\npublic sealed class RunExample\n{\n [Fact]\n public async Task ExercisesExample()\n {\n await new SelfManagedHostFixtureExample().StartAfterAttachingObserverAsync();\n }\n}" -} -'@ -$OutputEncoding = [Text.UTF8Encoding]::new($false) -[Console]::OutputEncoding = $OutputEncoding -$verifyTests = $true -function Assert-CsrunTestOutput([string] $Output) { - $lines = @($Output -split '\r?\n') - $headers = @($lines | Where-Object { $_ -match '^Test run summary: Passed! - .+\)$' }) - if ($headers.Count -ne 1) { throw 'Expected exactly one completed xUnit test summary.' } - $headerIndex = [Array]::IndexOf($lines, $headers[0]) - $summaryLines = @($lines | Select-Object -Skip ($headerIndex + 1) -First 4) - $counts = @{} - foreach ($line in $summaryLines) { - if ($line -match '^\s*(total|failed|succeeded|skipped):\s*(\d+)\s*$') { $counts[$Matches[1]] = [int]$Matches[2] } - } - if ($counts.Count -ne 4) { throw 'The xUnit test summary counts are incomplete or ambiguous.' } - $failed = $counts.failed - $passed = $counts.succeeded - $skipped = $counts.skipped - $total = $counts.total - if ($total -lt 1 -or $passed -lt 1 -or $failed -ne 0 -or $skipped -ne 0 -or $passed -ne $total) { - throw 'Tests must execute at least once, all pass, and none fail or skip.' - } -} -# Downloads and executes the latest stable csrun release with your permissions. -# Source and release history: https://github.com/codebeltnet/csrun -$engineDirectory = Join-Path ([IO.Path]::GetTempPath()) ('csrun-' + [guid]::NewGuid().ToString('N')) -$null = New-Item -ItemType Directory -Path $engineDirectory -$enginePath = Join-Path $engineDirectory 'csrun.ps1' -$process = $null -try { - $release = Invoke-RestMethod 'https://api.github.com/repos/codebeltnet/csrun/releases/latest' - $assets = @($release.assets | Where-Object name -CEQ 'csrun.ps1') - if ($assets.Count -ne 1 -or $assets[0].digest -notmatch '^sha256:[0-9a-f]{64}$') { - throw "csrun release $($release.tag_name) must publish one csrun.ps1 asset with a SHA-256 digest." - } - $asset = $assets[0] - Invoke-WebRequest $asset.browser_download_url -OutFile $enginePath - $actualHash = (Get-FileHash -LiteralPath $enginePath -Algorithm SHA256).Hash - if ("sha256:$actualHash" -ne $asset.digest) { throw "csrun asset checksum mismatch: $actualHash" } -$enginePayload = [Convert]::ToBase64String([IO.File]::ReadAllBytes($enginePath)) -$containerInput = $enginePayload + "`n" + $manifest -$command = ' -$ErrorActionPreference = "Stop" -$enginePath = Join-Path ([IO.Path]::GetTempPath()) ("csrun-release-" + [guid]::NewGuid().ToString("N") + ".ps1") -$engineBytes = [Convert]::FromBase64String([Console]::In.ReadLine()) -[IO.File]::WriteAllBytes($enginePath, $engineBytes) -$manifest = [Console]::In.ReadToEnd() -& $enginePath -ManifestJson $manifest -exit $LASTEXITCODE -' -$output = (@($containerInput | & docker run --rm -i --entrypoint pwsh 'codebeltnet/csrun:10' -NoProfile -NonInteractive -Command $command) -join [Environment]::NewLine) -$process = [pscustomobject]@{ ExitCode = $LASTEXITCODE } -$diagnostics = '' -Write-Output $output -} catch { - [Console]::Error.WriteLine("csrun diagnostics retained in: $engineDirectory") - throw -} finally { - $resolvedTemp = [IO.Path]::TrimEndingDirectorySeparator([IO.Path]::GetFullPath([IO.Path]::GetTempPath())) - $resolvedEngineDirectory = [IO.Path]::GetFullPath($engineDirectory) - if ([IO.Path]::GetDirectoryName($resolvedEngineDirectory) -ne $resolvedTemp -or - [IO.Path]::GetFileName($resolvedEngineDirectory) -cnotmatch '^csrun-[a-f0-9]{32}$') { throw 'Unsafe cleanup path.' } - if ($process -and $process.ExitCode -eq 0) { Remove-Item -LiteralPath $resolvedEngineDirectory -Recurse -Force } -} -if ($process.ExitCode -ne 0) { throw "csrun execution failed with exit code $($process.ExitCode). $diagnostics" } -if ($verifyTests) { Assert-CsrunTestOutput $output } -} \ No newline at end of file diff --git a/.docfx/run-actions/515575be5bb7683cac9903a5/native.ps1 b/.docfx/run-actions/515575be5bb7683cac9903a5/native.ps1 deleted file mode 100644 index 38c1908..0000000 --- a/.docfx/run-actions/515575be5bb7683cac9903a5/native.ps1 +++ /dev/null @@ -1,86 +0,0 @@ -& { -#requires -Version 7.0 -$ErrorActionPreference = 'Stop' -$PSNativeCommandUseErrorActionPreference = $false -$manifest = @' -{ - "dependsOn": [ - "Codebelt.Extensions.Xunit.Hosting@13.0.0", - "Microsoft.Extensions.Hosting@10.0.15", - "xunit.v3@4.0.3" - ], - "framework": "net10.0", - "mode": "test", - "schemaVersion": 1, - "source": "using System.Threading.Tasks;\nusing Codebelt.Extensions.Xunit.Hosting;\nusing Microsoft.Extensions.DependencyInjection;\nusing Microsoft.Extensions.Hosting;\nusing Xunit;\n\nnamespace WorkerLifecycle.Tests;\n\npublic sealed class SelfManagedHostFixtureExample\n{\n public async Task StartAfterAttachingObserverAsync()\n {\n using var host = HostTestFactory.Create(\n hostFixture: new SelfManagedHostFixture());\n\n var started = false;\n var lifetime = host.Host.Services.GetRequiredService();\n using var registration = lifetime.ApplicationStarted.Register(() => started = true);\n\n Assert.False(started);\n await host.Host.StartAsync().ConfigureAwait(false);\n Assert.True(started);\n }\n}\n\npublic sealed class RunExample\n{\n [Fact]\n public async Task ExercisesExample()\n {\n await new SelfManagedHostFixtureExample().StartAfterAttachingObserverAsync();\n }\n}" -} -'@ -$OutputEncoding = [Text.UTF8Encoding]::new($false) -[Console]::OutputEncoding = $OutputEncoding -$verifyTests = $true -function Assert-CsrunTestOutput([string] $Output) { - $lines = @($Output -split '\r?\n') - $headers = @($lines | Where-Object { $_ -match '^Test run summary: Passed! - .+\)$' }) - if ($headers.Count -ne 1) { throw 'Expected exactly one completed xUnit test summary.' } - $headerIndex = [Array]::IndexOf($lines, $headers[0]) - $summaryLines = @($lines | Select-Object -Skip ($headerIndex + 1) -First 4) - $counts = @{} - foreach ($line in $summaryLines) { - if ($line -match '^\s*(total|failed|succeeded|skipped):\s*(\d+)\s*$') { $counts[$Matches[1]] = [int]$Matches[2] } - } - if ($counts.Count -ne 4) { throw 'The xUnit test summary counts are incomplete or ambiguous.' } - $failed = $counts.failed - $passed = $counts.succeeded - $skipped = $counts.skipped - $total = $counts.total - if ($total -lt 1 -or $passed -lt 1 -or $failed -ne 0 -or $skipped -ne 0 -or $passed -ne $total) { - throw 'Tests must execute at least once, all pass, and none fail or skip.' - } -} -# Downloads and executes the latest stable csrun release with your permissions. -# Source and release history: https://github.com/codebeltnet/csrun -$engineDirectory = Join-Path ([IO.Path]::GetTempPath()) ('csrun-' + [guid]::NewGuid().ToString('N')) -$null = New-Item -ItemType Directory -Path $engineDirectory -$enginePath = Join-Path $engineDirectory 'csrun.ps1' -$process = $null -try { - $release = Invoke-RestMethod 'https://api.github.com/repos/codebeltnet/csrun/releases/latest' - $assets = @($release.assets | Where-Object name -CEQ 'csrun.ps1') - if ($assets.Count -ne 1 -or $assets[0].digest -notmatch '^sha256:[0-9a-f]{64}$') { - throw "csrun release $($release.tag_name) must publish one csrun.ps1 asset with a SHA-256 digest." - } - $asset = $assets[0] - Invoke-WebRequest $asset.browser_download_url -OutFile $enginePath - $actualHash = (Get-FileHash -LiteralPath $enginePath -Algorithm SHA256).Hash - if ("sha256:$actualHash" -ne $asset.digest) { throw "csrun asset checksum mismatch: $actualHash" } -$startInfo = [Diagnostics.ProcessStartInfo]::new('pwsh') -foreach ($argument in @('-NoProfile','-NonInteractive','-File')) { $startInfo.ArgumentList.Add($argument) } -$startInfo.ArgumentList.Add($enginePath) -$startInfo.ArgumentList.Add('-ManifestJson') -$startInfo.ArgumentList.Add($manifest) -$startInfo.RedirectStandardOutput = $true -$startInfo.RedirectStandardError = $true -$startInfo.UseShellExecute = $false -$process = [Diagnostics.Process]::new() -$process.StartInfo = $startInfo -if (-not $process.Start()) { throw 'Could not start csrun.' } -$stdoutTask = $process.StandardOutput.ReadToEndAsync() -$stderrTask = $process.StandardError.ReadToEndAsync() -$process.WaitForExit() -$output = $stdoutTask.GetAwaiter().GetResult() -$diagnostics = $stderrTask.GetAwaiter().GetResult() -Write-Output $output -if ($diagnostics) { [Console]::Error.Write($diagnostics) } -} catch { - [Console]::Error.WriteLine("csrun diagnostics retained in: $engineDirectory") - throw -} finally { - $resolvedTemp = [IO.Path]::TrimEndingDirectorySeparator([IO.Path]::GetFullPath([IO.Path]::GetTempPath())) - $resolvedEngineDirectory = [IO.Path]::GetFullPath($engineDirectory) - if ([IO.Path]::GetDirectoryName($resolvedEngineDirectory) -ne $resolvedTemp -or - [IO.Path]::GetFileName($resolvedEngineDirectory) -cnotmatch '^csrun-[a-f0-9]{32}$') { throw 'Unsafe cleanup path.' } - if ($process -and $process.ExitCode -eq 0) { Remove-Item -LiteralPath $resolvedEngineDirectory -Recurse -Force } -} -if ($process.ExitCode -ne 0) { throw "csrun execution failed with exit code $($process.ExitCode). $diagnostics" } -if ($verifyTests) { Assert-CsrunTestOutput $output } -} \ No newline at end of file diff --git a/.docfx/run-actions/545543e49c6bf054a9e06186/docker.ps1 b/.docfx/run-actions/545543e49c6bf054a9e06186/docker.ps1 deleted file mode 100644 index 84dc9ac..0000000 --- a/.docfx/run-actions/545543e49c6bf054a9e06186/docker.ps1 +++ /dev/null @@ -1,82 +0,0 @@ -& { -#requires -Version 7.0 -$ErrorActionPreference = 'Stop' -$PSNativeCommandUseErrorActionPreference = $false -$manifest = @' -{ - "dependsOn": [ - "Codebelt.Extensions.Xunit@13.0.0", - "xunit.v3@4.0.3" - ], - "framework": "net10.0", - "mode": "test", - "schemaVersion": 1, - "source": "using Codebelt.Extensions.Xunit;\nusing Xunit;\n\nnamespace Example.Tests;\n\npublic class OutputAccessorTest : Test\n{\n public OutputAccessorTest(ITestOutputHelper output) : base(output) { }\n\n [Fact]\n public void ShouldExposeCurrentOutput()\n {\n var accessor = new TestOutputHelperAccessor(TestOutput);\n Assert.Same(TestOutput, accessor.TestOutput);\n }\n}" -} -'@ -$OutputEncoding = [Text.UTF8Encoding]::new($false) -[Console]::OutputEncoding = $OutputEncoding -$verifyTests = $true -function Assert-CsrunTestOutput([string] $Output) { - $lines = @($Output -split '\r?\n') - $headers = @($lines | Where-Object { $_ -match '^Test run summary: Passed! - .+\)$' }) - if ($headers.Count -ne 1) { throw 'Expected exactly one completed xUnit test summary.' } - $headerIndex = [Array]::IndexOf($lines, $headers[0]) - $summaryLines = @($lines | Select-Object -Skip ($headerIndex + 1) -First 4) - $counts = @{} - foreach ($line in $summaryLines) { - if ($line -match '^\s*(total|failed|succeeded|skipped):\s*(\d+)\s*$') { $counts[$Matches[1]] = [int]$Matches[2] } - } - if ($counts.Count -ne 4) { throw 'The xUnit test summary counts are incomplete or ambiguous.' } - $failed = $counts.failed - $passed = $counts.succeeded - $skipped = $counts.skipped - $total = $counts.total - if ($total -lt 1 -or $passed -lt 1 -or $failed -ne 0 -or $skipped -ne 0 -or $passed -ne $total) { - throw 'Tests must execute at least once, all pass, and none fail or skip.' - } -} -# Downloads and executes the latest stable csrun release with your permissions. -# Source and release history: https://github.com/codebeltnet/csrun -$engineDirectory = Join-Path ([IO.Path]::GetTempPath()) ('csrun-' + [guid]::NewGuid().ToString('N')) -$null = New-Item -ItemType Directory -Path $engineDirectory -$enginePath = Join-Path $engineDirectory 'csrun.ps1' -$process = $null -try { - $release = Invoke-RestMethod 'https://api.github.com/repos/codebeltnet/csrun/releases/latest' - $assets = @($release.assets | Where-Object name -CEQ 'csrun.ps1') - if ($assets.Count -ne 1 -or $assets[0].digest -notmatch '^sha256:[0-9a-f]{64}$') { - throw "csrun release $($release.tag_name) must publish one csrun.ps1 asset with a SHA-256 digest." - } - $asset = $assets[0] - Invoke-WebRequest $asset.browser_download_url -OutFile $enginePath - $actualHash = (Get-FileHash -LiteralPath $enginePath -Algorithm SHA256).Hash - if ("sha256:$actualHash" -ne $asset.digest) { throw "csrun asset checksum mismatch: $actualHash" } -$enginePayload = [Convert]::ToBase64String([IO.File]::ReadAllBytes($enginePath)) -$containerInput = $enginePayload + "`n" + $manifest -$command = ' -$ErrorActionPreference = "Stop" -$enginePath = Join-Path ([IO.Path]::GetTempPath()) ("csrun-release-" + [guid]::NewGuid().ToString("N") + ".ps1") -$engineBytes = [Convert]::FromBase64String([Console]::In.ReadLine()) -[IO.File]::WriteAllBytes($enginePath, $engineBytes) -$manifest = [Console]::In.ReadToEnd() -& $enginePath -ManifestJson $manifest -exit $LASTEXITCODE -' -$output = (@($containerInput | & docker run --rm -i --entrypoint pwsh 'codebeltnet/csrun:10' -NoProfile -NonInteractive -Command $command) -join [Environment]::NewLine) -$process = [pscustomobject]@{ ExitCode = $LASTEXITCODE } -$diagnostics = '' -Write-Output $output -} catch { - [Console]::Error.WriteLine("csrun diagnostics retained in: $engineDirectory") - throw -} finally { - $resolvedTemp = [IO.Path]::TrimEndingDirectorySeparator([IO.Path]::GetFullPath([IO.Path]::GetTempPath())) - $resolvedEngineDirectory = [IO.Path]::GetFullPath($engineDirectory) - if ([IO.Path]::GetDirectoryName($resolvedEngineDirectory) -ne $resolvedTemp -or - [IO.Path]::GetFileName($resolvedEngineDirectory) -cnotmatch '^csrun-[a-f0-9]{32}$') { throw 'Unsafe cleanup path.' } - if ($process -and $process.ExitCode -eq 0) { Remove-Item -LiteralPath $resolvedEngineDirectory -Recurse -Force } -} -if ($process.ExitCode -ne 0) { throw "csrun execution failed with exit code $($process.ExitCode). $diagnostics" } -if ($verifyTests) { Assert-CsrunTestOutput $output } -} \ No newline at end of file diff --git a/.docfx/run-actions/545543e49c6bf054a9e06186/native.ps1 b/.docfx/run-actions/545543e49c6bf054a9e06186/native.ps1 deleted file mode 100644 index 822d1f2..0000000 --- a/.docfx/run-actions/545543e49c6bf054a9e06186/native.ps1 +++ /dev/null @@ -1,85 +0,0 @@ -& { -#requires -Version 7.0 -$ErrorActionPreference = 'Stop' -$PSNativeCommandUseErrorActionPreference = $false -$manifest = @' -{ - "dependsOn": [ - "Codebelt.Extensions.Xunit@13.0.0", - "xunit.v3@4.0.3" - ], - "framework": "net10.0", - "mode": "test", - "schemaVersion": 1, - "source": "using Codebelt.Extensions.Xunit;\nusing Xunit;\n\nnamespace Example.Tests;\n\npublic class OutputAccessorTest : Test\n{\n public OutputAccessorTest(ITestOutputHelper output) : base(output) { }\n\n [Fact]\n public void ShouldExposeCurrentOutput()\n {\n var accessor = new TestOutputHelperAccessor(TestOutput);\n Assert.Same(TestOutput, accessor.TestOutput);\n }\n}" -} -'@ -$OutputEncoding = [Text.UTF8Encoding]::new($false) -[Console]::OutputEncoding = $OutputEncoding -$verifyTests = $true -function Assert-CsrunTestOutput([string] $Output) { - $lines = @($Output -split '\r?\n') - $headers = @($lines | Where-Object { $_ -match '^Test run summary: Passed! - .+\)$' }) - if ($headers.Count -ne 1) { throw 'Expected exactly one completed xUnit test summary.' } - $headerIndex = [Array]::IndexOf($lines, $headers[0]) - $summaryLines = @($lines | Select-Object -Skip ($headerIndex + 1) -First 4) - $counts = @{} - foreach ($line in $summaryLines) { - if ($line -match '^\s*(total|failed|succeeded|skipped):\s*(\d+)\s*$') { $counts[$Matches[1]] = [int]$Matches[2] } - } - if ($counts.Count -ne 4) { throw 'The xUnit test summary counts are incomplete or ambiguous.' } - $failed = $counts.failed - $passed = $counts.succeeded - $skipped = $counts.skipped - $total = $counts.total - if ($total -lt 1 -or $passed -lt 1 -or $failed -ne 0 -or $skipped -ne 0 -or $passed -ne $total) { - throw 'Tests must execute at least once, all pass, and none fail or skip.' - } -} -# Downloads and executes the latest stable csrun release with your permissions. -# Source and release history: https://github.com/codebeltnet/csrun -$engineDirectory = Join-Path ([IO.Path]::GetTempPath()) ('csrun-' + [guid]::NewGuid().ToString('N')) -$null = New-Item -ItemType Directory -Path $engineDirectory -$enginePath = Join-Path $engineDirectory 'csrun.ps1' -$process = $null -try { - $release = Invoke-RestMethod 'https://api.github.com/repos/codebeltnet/csrun/releases/latest' - $assets = @($release.assets | Where-Object name -CEQ 'csrun.ps1') - if ($assets.Count -ne 1 -or $assets[0].digest -notmatch '^sha256:[0-9a-f]{64}$') { - throw "csrun release $($release.tag_name) must publish one csrun.ps1 asset with a SHA-256 digest." - } - $asset = $assets[0] - Invoke-WebRequest $asset.browser_download_url -OutFile $enginePath - $actualHash = (Get-FileHash -LiteralPath $enginePath -Algorithm SHA256).Hash - if ("sha256:$actualHash" -ne $asset.digest) { throw "csrun asset checksum mismatch: $actualHash" } -$startInfo = [Diagnostics.ProcessStartInfo]::new('pwsh') -foreach ($argument in @('-NoProfile','-NonInteractive','-File')) { $startInfo.ArgumentList.Add($argument) } -$startInfo.ArgumentList.Add($enginePath) -$startInfo.ArgumentList.Add('-ManifestJson') -$startInfo.ArgumentList.Add($manifest) -$startInfo.RedirectStandardOutput = $true -$startInfo.RedirectStandardError = $true -$startInfo.UseShellExecute = $false -$process = [Diagnostics.Process]::new() -$process.StartInfo = $startInfo -if (-not $process.Start()) { throw 'Could not start csrun.' } -$stdoutTask = $process.StandardOutput.ReadToEndAsync() -$stderrTask = $process.StandardError.ReadToEndAsync() -$process.WaitForExit() -$output = $stdoutTask.GetAwaiter().GetResult() -$diagnostics = $stderrTask.GetAwaiter().GetResult() -Write-Output $output -if ($diagnostics) { [Console]::Error.Write($diagnostics) } -} catch { - [Console]::Error.WriteLine("csrun diagnostics retained in: $engineDirectory") - throw -} finally { - $resolvedTemp = [IO.Path]::TrimEndingDirectorySeparator([IO.Path]::GetFullPath([IO.Path]::GetTempPath())) - $resolvedEngineDirectory = [IO.Path]::GetFullPath($engineDirectory) - if ([IO.Path]::GetDirectoryName($resolvedEngineDirectory) -ne $resolvedTemp -or - [IO.Path]::GetFileName($resolvedEngineDirectory) -cnotmatch '^csrun-[a-f0-9]{32}$') { throw 'Unsafe cleanup path.' } - if ($process -and $process.ExitCode -eq 0) { Remove-Item -LiteralPath $resolvedEngineDirectory -Recurse -Force } -} -if ($process.ExitCode -ne 0) { throw "csrun execution failed with exit code $($process.ExitCode). $diagnostics" } -if ($verifyTests) { Assert-CsrunTestOutput $output } -} \ No newline at end of file diff --git a/.docfx/run-actions/549c3e82bd0bcb99e9f05bfa/docker.ps1 b/.docfx/run-actions/549c3e82bd0bcb99e9f05bfa/docker.ps1 deleted file mode 100644 index fdec138..0000000 --- a/.docfx/run-actions/549c3e82bd0bcb99e9f05bfa/docker.ps1 +++ /dev/null @@ -1,86 +0,0 @@ -& { -#requires -Version 7.0 -$ErrorActionPreference = 'Stop' -$PSNativeCommandUseErrorActionPreference = $false -$manifest = @' -{ - "dependsOn": [ - "Codebelt.Extensions.Xunit.Hosting.AspNetCore@13.0.0", - "Microsoft.Extensions.Hosting@10.0.15", - "xunit.v3@4.0.3" - ], - "framework": "net10.0", - "frameworkReferences": [ - "Microsoft.AspNetCore.App" - ], - "mode": "test", - "schemaVersion": 1, - "source": "using Codebelt.Extensions.Xunit.Hosting.AspNetCore;\nusing Xunit;\n\nnamespace WebFixtureTests;\n\npublic class WebAppStateGuard\n{\n public bool EnsureFixtureIsReady(IWebApplicationFixture fixture) where TEntryPoint : class\n {\n return fixture.HasValidState();\n }\n}\n\npublic sealed class RunExample\n{\n [Fact]\n public void ExercisesExample()\n {\n using var fixture = new ManagedWebApplicationFixture();\n Assert.False(new WebAppStateGuard().EnsureFixtureIsReady(fixture));\n }\n}" -} -'@ -$OutputEncoding = [Text.UTF8Encoding]::new($false) -[Console]::OutputEncoding = $OutputEncoding -$verifyTests = $true -function Assert-CsrunTestOutput([string] $Output) { - $lines = @($Output -split '\r?\n') - $headers = @($lines | Where-Object { $_ -match '^Test run summary: Passed! - .+\)$' }) - if ($headers.Count -ne 1) { throw 'Expected exactly one completed xUnit test summary.' } - $headerIndex = [Array]::IndexOf($lines, $headers[0]) - $summaryLines = @($lines | Select-Object -Skip ($headerIndex + 1) -First 4) - $counts = @{} - foreach ($line in $summaryLines) { - if ($line -match '^\s*(total|failed|succeeded|skipped):\s*(\d+)\s*$') { $counts[$Matches[1]] = [int]$Matches[2] } - } - if ($counts.Count -ne 4) { throw 'The xUnit test summary counts are incomplete or ambiguous.' } - $failed = $counts.failed - $passed = $counts.succeeded - $skipped = $counts.skipped - $total = $counts.total - if ($total -lt 1 -or $passed -lt 1 -or $failed -ne 0 -or $skipped -ne 0 -or $passed -ne $total) { - throw 'Tests must execute at least once, all pass, and none fail or skip.' - } -} -# Downloads and executes the latest stable csrun release with your permissions. -# Source and release history: https://github.com/codebeltnet/csrun -$engineDirectory = Join-Path ([IO.Path]::GetTempPath()) ('csrun-' + [guid]::NewGuid().ToString('N')) -$null = New-Item -ItemType Directory -Path $engineDirectory -$enginePath = Join-Path $engineDirectory 'csrun.ps1' -$process = $null -try { - $release = Invoke-RestMethod 'https://api.github.com/repos/codebeltnet/csrun/releases/latest' - $assets = @($release.assets | Where-Object name -CEQ 'csrun.ps1') - if ($assets.Count -ne 1 -or $assets[0].digest -notmatch '^sha256:[0-9a-f]{64}$') { - throw "csrun release $($release.tag_name) must publish one csrun.ps1 asset with a SHA-256 digest." - } - $asset = $assets[0] - Invoke-WebRequest $asset.browser_download_url -OutFile $enginePath - $actualHash = (Get-FileHash -LiteralPath $enginePath -Algorithm SHA256).Hash - if ("sha256:$actualHash" -ne $asset.digest) { throw "csrun asset checksum mismatch: $actualHash" } -$enginePayload = [Convert]::ToBase64String([IO.File]::ReadAllBytes($enginePath)) -$containerInput = $enginePayload + "`n" + $manifest -$command = ' -$ErrorActionPreference = "Stop" -$enginePath = Join-Path ([IO.Path]::GetTempPath()) ("csrun-release-" + [guid]::NewGuid().ToString("N") + ".ps1") -$engineBytes = [Convert]::FromBase64String([Console]::In.ReadLine()) -[IO.File]::WriteAllBytes($enginePath, $engineBytes) -$manifest = [Console]::In.ReadToEnd() -& $enginePath -ManifestJson $manifest -exit $LASTEXITCODE -' -$output = (@($containerInput | & docker run --rm -i --entrypoint pwsh 'codebeltnet/csrun:10' -NoProfile -NonInteractive -Command $command) -join [Environment]::NewLine) -$process = [pscustomobject]@{ ExitCode = $LASTEXITCODE } -$diagnostics = '' -Write-Output $output -} catch { - [Console]::Error.WriteLine("csrun diagnostics retained in: $engineDirectory") - throw -} finally { - $resolvedTemp = [IO.Path]::TrimEndingDirectorySeparator([IO.Path]::GetFullPath([IO.Path]::GetTempPath())) - $resolvedEngineDirectory = [IO.Path]::GetFullPath($engineDirectory) - if ([IO.Path]::GetDirectoryName($resolvedEngineDirectory) -ne $resolvedTemp -or - [IO.Path]::GetFileName($resolvedEngineDirectory) -cnotmatch '^csrun-[a-f0-9]{32}$') { throw 'Unsafe cleanup path.' } - if ($process -and $process.ExitCode -eq 0) { Remove-Item -LiteralPath $resolvedEngineDirectory -Recurse -Force } -} -if ($process.ExitCode -ne 0) { throw "csrun execution failed with exit code $($process.ExitCode). $diagnostics" } -if ($verifyTests) { Assert-CsrunTestOutput $output } -} \ No newline at end of file diff --git a/.docfx/run-actions/549c3e82bd0bcb99e9f05bfa/native.ps1 b/.docfx/run-actions/549c3e82bd0bcb99e9f05bfa/native.ps1 deleted file mode 100644 index 09ff572..0000000 --- a/.docfx/run-actions/549c3e82bd0bcb99e9f05bfa/native.ps1 +++ /dev/null @@ -1,89 +0,0 @@ -& { -#requires -Version 7.0 -$ErrorActionPreference = 'Stop' -$PSNativeCommandUseErrorActionPreference = $false -$manifest = @' -{ - "dependsOn": [ - "Codebelt.Extensions.Xunit.Hosting.AspNetCore@13.0.0", - "Microsoft.Extensions.Hosting@10.0.15", - "xunit.v3@4.0.3" - ], - "framework": "net10.0", - "frameworkReferences": [ - "Microsoft.AspNetCore.App" - ], - "mode": "test", - "schemaVersion": 1, - "source": "using Codebelt.Extensions.Xunit.Hosting.AspNetCore;\nusing Xunit;\n\nnamespace WebFixtureTests;\n\npublic class WebAppStateGuard\n{\n public bool EnsureFixtureIsReady(IWebApplicationFixture fixture) where TEntryPoint : class\n {\n return fixture.HasValidState();\n }\n}\n\npublic sealed class RunExample\n{\n [Fact]\n public void ExercisesExample()\n {\n using var fixture = new ManagedWebApplicationFixture();\n Assert.False(new WebAppStateGuard().EnsureFixtureIsReady(fixture));\n }\n}" -} -'@ -$OutputEncoding = [Text.UTF8Encoding]::new($false) -[Console]::OutputEncoding = $OutputEncoding -$verifyTests = $true -function Assert-CsrunTestOutput([string] $Output) { - $lines = @($Output -split '\r?\n') - $headers = @($lines | Where-Object { $_ -match '^Test run summary: Passed! - .+\)$' }) - if ($headers.Count -ne 1) { throw 'Expected exactly one completed xUnit test summary.' } - $headerIndex = [Array]::IndexOf($lines, $headers[0]) - $summaryLines = @($lines | Select-Object -Skip ($headerIndex + 1) -First 4) - $counts = @{} - foreach ($line in $summaryLines) { - if ($line -match '^\s*(total|failed|succeeded|skipped):\s*(\d+)\s*$') { $counts[$Matches[1]] = [int]$Matches[2] } - } - if ($counts.Count -ne 4) { throw 'The xUnit test summary counts are incomplete or ambiguous.' } - $failed = $counts.failed - $passed = $counts.succeeded - $skipped = $counts.skipped - $total = $counts.total - if ($total -lt 1 -or $passed -lt 1 -or $failed -ne 0 -or $skipped -ne 0 -or $passed -ne $total) { - throw 'Tests must execute at least once, all pass, and none fail or skip.' - } -} -# Downloads and executes the latest stable csrun release with your permissions. -# Source and release history: https://github.com/codebeltnet/csrun -$engineDirectory = Join-Path ([IO.Path]::GetTempPath()) ('csrun-' + [guid]::NewGuid().ToString('N')) -$null = New-Item -ItemType Directory -Path $engineDirectory -$enginePath = Join-Path $engineDirectory 'csrun.ps1' -$process = $null -try { - $release = Invoke-RestMethod 'https://api.github.com/repos/codebeltnet/csrun/releases/latest' - $assets = @($release.assets | Where-Object name -CEQ 'csrun.ps1') - if ($assets.Count -ne 1 -or $assets[0].digest -notmatch '^sha256:[0-9a-f]{64}$') { - throw "csrun release $($release.tag_name) must publish one csrun.ps1 asset with a SHA-256 digest." - } - $asset = $assets[0] - Invoke-WebRequest $asset.browser_download_url -OutFile $enginePath - $actualHash = (Get-FileHash -LiteralPath $enginePath -Algorithm SHA256).Hash - if ("sha256:$actualHash" -ne $asset.digest) { throw "csrun asset checksum mismatch: $actualHash" } -$startInfo = [Diagnostics.ProcessStartInfo]::new('pwsh') -foreach ($argument in @('-NoProfile','-NonInteractive','-File')) { $startInfo.ArgumentList.Add($argument) } -$startInfo.ArgumentList.Add($enginePath) -$startInfo.ArgumentList.Add('-ManifestJson') -$startInfo.ArgumentList.Add($manifest) -$startInfo.RedirectStandardOutput = $true -$startInfo.RedirectStandardError = $true -$startInfo.UseShellExecute = $false -$process = [Diagnostics.Process]::new() -$process.StartInfo = $startInfo -if (-not $process.Start()) { throw 'Could not start csrun.' } -$stdoutTask = $process.StandardOutput.ReadToEndAsync() -$stderrTask = $process.StandardError.ReadToEndAsync() -$process.WaitForExit() -$output = $stdoutTask.GetAwaiter().GetResult() -$diagnostics = $stderrTask.GetAwaiter().GetResult() -Write-Output $output -if ($diagnostics) { [Console]::Error.Write($diagnostics) } -} catch { - [Console]::Error.WriteLine("csrun diagnostics retained in: $engineDirectory") - throw -} finally { - $resolvedTemp = [IO.Path]::TrimEndingDirectorySeparator([IO.Path]::GetFullPath([IO.Path]::GetTempPath())) - $resolvedEngineDirectory = [IO.Path]::GetFullPath($engineDirectory) - if ([IO.Path]::GetDirectoryName($resolvedEngineDirectory) -ne $resolvedTemp -or - [IO.Path]::GetFileName($resolvedEngineDirectory) -cnotmatch '^csrun-[a-f0-9]{32}$') { throw 'Unsafe cleanup path.' } - if ($process -and $process.ExitCode -eq 0) { Remove-Item -LiteralPath $resolvedEngineDirectory -Recurse -Force } -} -if ($process.ExitCode -ne 0) { throw "csrun execution failed with exit code $($process.ExitCode). $diagnostics" } -if ($verifyTests) { Assert-CsrunTestOutput $output } -} \ No newline at end of file diff --git a/.docfx/run-actions/578d467fd203f66cc41b0364/docker.ps1 b/.docfx/run-actions/578d467fd203f66cc41b0364/docker.ps1 deleted file mode 100644 index 2ef8a3c..0000000 --- a/.docfx/run-actions/578d467fd203f66cc41b0364/docker.ps1 +++ /dev/null @@ -1,82 +0,0 @@ -& { -#requires -Version 7.0 -$ErrorActionPreference = 'Stop' -$PSNativeCommandUseErrorActionPreference = $false -$manifest = @' -{ - "dependsOn": [ - "Codebelt.Extensions.Xunit@13.0.0", - "xunit.v3@4.0.3" - ], - "framework": "net10.0", - "mode": "test", - "schemaVersion": 1, - "source": "using Codebelt.Extensions.Xunit;\nusing Xunit;\n\nnamespace Example.Tests;\n\npublic class MixedOutputTest : Test\n{\n public MixedOutputTest(ITestOutputHelper output) : base(output) { }\n\n [Fact]\n public void ShouldWriteMixedValues()\n {\n TestOutput.WriteLines((object)\"cache\", 3);\n Assert.True(HasTestOutput);\n }\n}" -} -'@ -$OutputEncoding = [Text.UTF8Encoding]::new($false) -[Console]::OutputEncoding = $OutputEncoding -$verifyTests = $true -function Assert-CsrunTestOutput([string] $Output) { - $lines = @($Output -split '\r?\n') - $headers = @($lines | Where-Object { $_ -match '^Test run summary: Passed! - .+\)$' }) - if ($headers.Count -ne 1) { throw 'Expected exactly one completed xUnit test summary.' } - $headerIndex = [Array]::IndexOf($lines, $headers[0]) - $summaryLines = @($lines | Select-Object -Skip ($headerIndex + 1) -First 4) - $counts = @{} - foreach ($line in $summaryLines) { - if ($line -match '^\s*(total|failed|succeeded|skipped):\s*(\d+)\s*$') { $counts[$Matches[1]] = [int]$Matches[2] } - } - if ($counts.Count -ne 4) { throw 'The xUnit test summary counts are incomplete or ambiguous.' } - $failed = $counts.failed - $passed = $counts.succeeded - $skipped = $counts.skipped - $total = $counts.total - if ($total -lt 1 -or $passed -lt 1 -or $failed -ne 0 -or $skipped -ne 0 -or $passed -ne $total) { - throw 'Tests must execute at least once, all pass, and none fail or skip.' - } -} -# Downloads and executes the latest stable csrun release with your permissions. -# Source and release history: https://github.com/codebeltnet/csrun -$engineDirectory = Join-Path ([IO.Path]::GetTempPath()) ('csrun-' + [guid]::NewGuid().ToString('N')) -$null = New-Item -ItemType Directory -Path $engineDirectory -$enginePath = Join-Path $engineDirectory 'csrun.ps1' -$process = $null -try { - $release = Invoke-RestMethod 'https://api.github.com/repos/codebeltnet/csrun/releases/latest' - $assets = @($release.assets | Where-Object name -CEQ 'csrun.ps1') - if ($assets.Count -ne 1 -or $assets[0].digest -notmatch '^sha256:[0-9a-f]{64}$') { - throw "csrun release $($release.tag_name) must publish one csrun.ps1 asset with a SHA-256 digest." - } - $asset = $assets[0] - Invoke-WebRequest $asset.browser_download_url -OutFile $enginePath - $actualHash = (Get-FileHash -LiteralPath $enginePath -Algorithm SHA256).Hash - if ("sha256:$actualHash" -ne $asset.digest) { throw "csrun asset checksum mismatch: $actualHash" } -$enginePayload = [Convert]::ToBase64String([IO.File]::ReadAllBytes($enginePath)) -$containerInput = $enginePayload + "`n" + $manifest -$command = ' -$ErrorActionPreference = "Stop" -$enginePath = Join-Path ([IO.Path]::GetTempPath()) ("csrun-release-" + [guid]::NewGuid().ToString("N") + ".ps1") -$engineBytes = [Convert]::FromBase64String([Console]::In.ReadLine()) -[IO.File]::WriteAllBytes($enginePath, $engineBytes) -$manifest = [Console]::In.ReadToEnd() -& $enginePath -ManifestJson $manifest -exit $LASTEXITCODE -' -$output = (@($containerInput | & docker run --rm -i --entrypoint pwsh 'codebeltnet/csrun:10' -NoProfile -NonInteractive -Command $command) -join [Environment]::NewLine) -$process = [pscustomobject]@{ ExitCode = $LASTEXITCODE } -$diagnostics = '' -Write-Output $output -} catch { - [Console]::Error.WriteLine("csrun diagnostics retained in: $engineDirectory") - throw -} finally { - $resolvedTemp = [IO.Path]::TrimEndingDirectorySeparator([IO.Path]::GetFullPath([IO.Path]::GetTempPath())) - $resolvedEngineDirectory = [IO.Path]::GetFullPath($engineDirectory) - if ([IO.Path]::GetDirectoryName($resolvedEngineDirectory) -ne $resolvedTemp -or - [IO.Path]::GetFileName($resolvedEngineDirectory) -cnotmatch '^csrun-[a-f0-9]{32}$') { throw 'Unsafe cleanup path.' } - if ($process -and $process.ExitCode -eq 0) { Remove-Item -LiteralPath $resolvedEngineDirectory -Recurse -Force } -} -if ($process.ExitCode -ne 0) { throw "csrun execution failed with exit code $($process.ExitCode). $diagnostics" } -if ($verifyTests) { Assert-CsrunTestOutput $output } -} \ No newline at end of file diff --git a/.docfx/run-actions/578d467fd203f66cc41b0364/native.ps1 b/.docfx/run-actions/578d467fd203f66cc41b0364/native.ps1 deleted file mode 100644 index 60ddb06..0000000 --- a/.docfx/run-actions/578d467fd203f66cc41b0364/native.ps1 +++ /dev/null @@ -1,85 +0,0 @@ -& { -#requires -Version 7.0 -$ErrorActionPreference = 'Stop' -$PSNativeCommandUseErrorActionPreference = $false -$manifest = @' -{ - "dependsOn": [ - "Codebelt.Extensions.Xunit@13.0.0", - "xunit.v3@4.0.3" - ], - "framework": "net10.0", - "mode": "test", - "schemaVersion": 1, - "source": "using Codebelt.Extensions.Xunit;\nusing Xunit;\n\nnamespace Example.Tests;\n\npublic class MixedOutputTest : Test\n{\n public MixedOutputTest(ITestOutputHelper output) : base(output) { }\n\n [Fact]\n public void ShouldWriteMixedValues()\n {\n TestOutput.WriteLines((object)\"cache\", 3);\n Assert.True(HasTestOutput);\n }\n}" -} -'@ -$OutputEncoding = [Text.UTF8Encoding]::new($false) -[Console]::OutputEncoding = $OutputEncoding -$verifyTests = $true -function Assert-CsrunTestOutput([string] $Output) { - $lines = @($Output -split '\r?\n') - $headers = @($lines | Where-Object { $_ -match '^Test run summary: Passed! - .+\)$' }) - if ($headers.Count -ne 1) { throw 'Expected exactly one completed xUnit test summary.' } - $headerIndex = [Array]::IndexOf($lines, $headers[0]) - $summaryLines = @($lines | Select-Object -Skip ($headerIndex + 1) -First 4) - $counts = @{} - foreach ($line in $summaryLines) { - if ($line -match '^\s*(total|failed|succeeded|skipped):\s*(\d+)\s*$') { $counts[$Matches[1]] = [int]$Matches[2] } - } - if ($counts.Count -ne 4) { throw 'The xUnit test summary counts are incomplete or ambiguous.' } - $failed = $counts.failed - $passed = $counts.succeeded - $skipped = $counts.skipped - $total = $counts.total - if ($total -lt 1 -or $passed -lt 1 -or $failed -ne 0 -or $skipped -ne 0 -or $passed -ne $total) { - throw 'Tests must execute at least once, all pass, and none fail or skip.' - } -} -# Downloads and executes the latest stable csrun release with your permissions. -# Source and release history: https://github.com/codebeltnet/csrun -$engineDirectory = Join-Path ([IO.Path]::GetTempPath()) ('csrun-' + [guid]::NewGuid().ToString('N')) -$null = New-Item -ItemType Directory -Path $engineDirectory -$enginePath = Join-Path $engineDirectory 'csrun.ps1' -$process = $null -try { - $release = Invoke-RestMethod 'https://api.github.com/repos/codebeltnet/csrun/releases/latest' - $assets = @($release.assets | Where-Object name -CEQ 'csrun.ps1') - if ($assets.Count -ne 1 -or $assets[0].digest -notmatch '^sha256:[0-9a-f]{64}$') { - throw "csrun release $($release.tag_name) must publish one csrun.ps1 asset with a SHA-256 digest." - } - $asset = $assets[0] - Invoke-WebRequest $asset.browser_download_url -OutFile $enginePath - $actualHash = (Get-FileHash -LiteralPath $enginePath -Algorithm SHA256).Hash - if ("sha256:$actualHash" -ne $asset.digest) { throw "csrun asset checksum mismatch: $actualHash" } -$startInfo = [Diagnostics.ProcessStartInfo]::new('pwsh') -foreach ($argument in @('-NoProfile','-NonInteractive','-File')) { $startInfo.ArgumentList.Add($argument) } -$startInfo.ArgumentList.Add($enginePath) -$startInfo.ArgumentList.Add('-ManifestJson') -$startInfo.ArgumentList.Add($manifest) -$startInfo.RedirectStandardOutput = $true -$startInfo.RedirectStandardError = $true -$startInfo.UseShellExecute = $false -$process = [Diagnostics.Process]::new() -$process.StartInfo = $startInfo -if (-not $process.Start()) { throw 'Could not start csrun.' } -$stdoutTask = $process.StandardOutput.ReadToEndAsync() -$stderrTask = $process.StandardError.ReadToEndAsync() -$process.WaitForExit() -$output = $stdoutTask.GetAwaiter().GetResult() -$diagnostics = $stderrTask.GetAwaiter().GetResult() -Write-Output $output -if ($diagnostics) { [Console]::Error.Write($diagnostics) } -} catch { - [Console]::Error.WriteLine("csrun diagnostics retained in: $engineDirectory") - throw -} finally { - $resolvedTemp = [IO.Path]::TrimEndingDirectorySeparator([IO.Path]::GetFullPath([IO.Path]::GetTempPath())) - $resolvedEngineDirectory = [IO.Path]::GetFullPath($engineDirectory) - if ([IO.Path]::GetDirectoryName($resolvedEngineDirectory) -ne $resolvedTemp -or - [IO.Path]::GetFileName($resolvedEngineDirectory) -cnotmatch '^csrun-[a-f0-9]{32}$') { throw 'Unsafe cleanup path.' } - if ($process -and $process.ExitCode -eq 0) { Remove-Item -LiteralPath $resolvedEngineDirectory -Recurse -Force } -} -if ($process.ExitCode -ne 0) { throw "csrun execution failed with exit code $($process.ExitCode). $diagnostics" } -if ($verifyTests) { Assert-CsrunTestOutput $output } -} \ No newline at end of file diff --git a/.docfx/run-actions/5e35a33e56470f93afbedf19/docker.ps1 b/.docfx/run-actions/5e35a33e56470f93afbedf19/docker.ps1 deleted file mode 100644 index 315cacc..0000000 --- a/.docfx/run-actions/5e35a33e56470f93afbedf19/docker.ps1 +++ /dev/null @@ -1,83 +0,0 @@ -& { -#requires -Version 7.0 -$ErrorActionPreference = 'Stop' -$PSNativeCommandUseErrorActionPreference = $false -$manifest = @' -{ - "dependsOn": [ - "Codebelt.Extensions.Xunit.Hosting@13.0.0", - "Microsoft.Extensions.Hosting@10.0.15", - "xunit.v3@4.0.3" - ], - "framework": "net10.0", - "mode": "test", - "schemaVersion": 1, - "source": "using System;\nusing Codebelt.Extensions.Xunit.Hosting;\nusing Microsoft.Extensions.DependencyInjection;\nusing Xunit;\n\nnamespace HostFixtureTests;\n\npublic class ServiceResolver\n{\n public T Resolve(IServiceProvider provider) where T : notnull\n {\n return provider.GetRequiredScopedService();\n }\n}\n\npublic sealed class RunExample\n{\n [Fact]\n public void ExercisesExample()\n {\n var services = new ServiceCollection();\n services.AddScoped(_ => new object());\n using var provider = services.BuildServiceProvider(new ServiceProviderOptions\n {\n ValidateScopes = true\n });\n Assert.NotSame(new ServiceResolver().Resolve(provider), new ServiceResolver().Resolve(provider));\n }\n}" -} -'@ -$OutputEncoding = [Text.UTF8Encoding]::new($false) -[Console]::OutputEncoding = $OutputEncoding -$verifyTests = $true -function Assert-CsrunTestOutput([string] $Output) { - $lines = @($Output -split '\r?\n') - $headers = @($lines | Where-Object { $_ -match '^Test run summary: Passed! - .+\)$' }) - if ($headers.Count -ne 1) { throw 'Expected exactly one completed xUnit test summary.' } - $headerIndex = [Array]::IndexOf($lines, $headers[0]) - $summaryLines = @($lines | Select-Object -Skip ($headerIndex + 1) -First 4) - $counts = @{} - foreach ($line in $summaryLines) { - if ($line -match '^\s*(total|failed|succeeded|skipped):\s*(\d+)\s*$') { $counts[$Matches[1]] = [int]$Matches[2] } - } - if ($counts.Count -ne 4) { throw 'The xUnit test summary counts are incomplete or ambiguous.' } - $failed = $counts.failed - $passed = $counts.succeeded - $skipped = $counts.skipped - $total = $counts.total - if ($total -lt 1 -or $passed -lt 1 -or $failed -ne 0 -or $skipped -ne 0 -or $passed -ne $total) { - throw 'Tests must execute at least once, all pass, and none fail or skip.' - } -} -# Downloads and executes the latest stable csrun release with your permissions. -# Source and release history: https://github.com/codebeltnet/csrun -$engineDirectory = Join-Path ([IO.Path]::GetTempPath()) ('csrun-' + [guid]::NewGuid().ToString('N')) -$null = New-Item -ItemType Directory -Path $engineDirectory -$enginePath = Join-Path $engineDirectory 'csrun.ps1' -$process = $null -try { - $release = Invoke-RestMethod 'https://api.github.com/repos/codebeltnet/csrun/releases/latest' - $assets = @($release.assets | Where-Object name -CEQ 'csrun.ps1') - if ($assets.Count -ne 1 -or $assets[0].digest -notmatch '^sha256:[0-9a-f]{64}$') { - throw "csrun release $($release.tag_name) must publish one csrun.ps1 asset with a SHA-256 digest." - } - $asset = $assets[0] - Invoke-WebRequest $asset.browser_download_url -OutFile $enginePath - $actualHash = (Get-FileHash -LiteralPath $enginePath -Algorithm SHA256).Hash - if ("sha256:$actualHash" -ne $asset.digest) { throw "csrun asset checksum mismatch: $actualHash" } -$enginePayload = [Convert]::ToBase64String([IO.File]::ReadAllBytes($enginePath)) -$containerInput = $enginePayload + "`n" + $manifest -$command = ' -$ErrorActionPreference = "Stop" -$enginePath = Join-Path ([IO.Path]::GetTempPath()) ("csrun-release-" + [guid]::NewGuid().ToString("N") + ".ps1") -$engineBytes = [Convert]::FromBase64String([Console]::In.ReadLine()) -[IO.File]::WriteAllBytes($enginePath, $engineBytes) -$manifest = [Console]::In.ReadToEnd() -& $enginePath -ManifestJson $manifest -exit $LASTEXITCODE -' -$output = (@($containerInput | & docker run --rm -i --entrypoint pwsh 'codebeltnet/csrun:10' -NoProfile -NonInteractive -Command $command) -join [Environment]::NewLine) -$process = [pscustomobject]@{ ExitCode = $LASTEXITCODE } -$diagnostics = '' -Write-Output $output -} catch { - [Console]::Error.WriteLine("csrun diagnostics retained in: $engineDirectory") - throw -} finally { - $resolvedTemp = [IO.Path]::TrimEndingDirectorySeparator([IO.Path]::GetFullPath([IO.Path]::GetTempPath())) - $resolvedEngineDirectory = [IO.Path]::GetFullPath($engineDirectory) - if ([IO.Path]::GetDirectoryName($resolvedEngineDirectory) -ne $resolvedTemp -or - [IO.Path]::GetFileName($resolvedEngineDirectory) -cnotmatch '^csrun-[a-f0-9]{32}$') { throw 'Unsafe cleanup path.' } - if ($process -and $process.ExitCode -eq 0) { Remove-Item -LiteralPath $resolvedEngineDirectory -Recurse -Force } -} -if ($process.ExitCode -ne 0) { throw "csrun execution failed with exit code $($process.ExitCode). $diagnostics" } -if ($verifyTests) { Assert-CsrunTestOutput $output } -} \ No newline at end of file diff --git a/.docfx/run-actions/5e35a33e56470f93afbedf19/native.ps1 b/.docfx/run-actions/5e35a33e56470f93afbedf19/native.ps1 deleted file mode 100644 index acead69..0000000 --- a/.docfx/run-actions/5e35a33e56470f93afbedf19/native.ps1 +++ /dev/null @@ -1,86 +0,0 @@ -& { -#requires -Version 7.0 -$ErrorActionPreference = 'Stop' -$PSNativeCommandUseErrorActionPreference = $false -$manifest = @' -{ - "dependsOn": [ - "Codebelt.Extensions.Xunit.Hosting@13.0.0", - "Microsoft.Extensions.Hosting@10.0.15", - "xunit.v3@4.0.3" - ], - "framework": "net10.0", - "mode": "test", - "schemaVersion": 1, - "source": "using System;\nusing Codebelt.Extensions.Xunit.Hosting;\nusing Microsoft.Extensions.DependencyInjection;\nusing Xunit;\n\nnamespace HostFixtureTests;\n\npublic class ServiceResolver\n{\n public T Resolve(IServiceProvider provider) where T : notnull\n {\n return provider.GetRequiredScopedService();\n }\n}\n\npublic sealed class RunExample\n{\n [Fact]\n public void ExercisesExample()\n {\n var services = new ServiceCollection();\n services.AddScoped(_ => new object());\n using var provider = services.BuildServiceProvider(new ServiceProviderOptions\n {\n ValidateScopes = true\n });\n Assert.NotSame(new ServiceResolver().Resolve(provider), new ServiceResolver().Resolve(provider));\n }\n}" -} -'@ -$OutputEncoding = [Text.UTF8Encoding]::new($false) -[Console]::OutputEncoding = $OutputEncoding -$verifyTests = $true -function Assert-CsrunTestOutput([string] $Output) { - $lines = @($Output -split '\r?\n') - $headers = @($lines | Where-Object { $_ -match '^Test run summary: Passed! - .+\)$' }) - if ($headers.Count -ne 1) { throw 'Expected exactly one completed xUnit test summary.' } - $headerIndex = [Array]::IndexOf($lines, $headers[0]) - $summaryLines = @($lines | Select-Object -Skip ($headerIndex + 1) -First 4) - $counts = @{} - foreach ($line in $summaryLines) { - if ($line -match '^\s*(total|failed|succeeded|skipped):\s*(\d+)\s*$') { $counts[$Matches[1]] = [int]$Matches[2] } - } - if ($counts.Count -ne 4) { throw 'The xUnit test summary counts are incomplete or ambiguous.' } - $failed = $counts.failed - $passed = $counts.succeeded - $skipped = $counts.skipped - $total = $counts.total - if ($total -lt 1 -or $passed -lt 1 -or $failed -ne 0 -or $skipped -ne 0 -or $passed -ne $total) { - throw 'Tests must execute at least once, all pass, and none fail or skip.' - } -} -# Downloads and executes the latest stable csrun release with your permissions. -# Source and release history: https://github.com/codebeltnet/csrun -$engineDirectory = Join-Path ([IO.Path]::GetTempPath()) ('csrun-' + [guid]::NewGuid().ToString('N')) -$null = New-Item -ItemType Directory -Path $engineDirectory -$enginePath = Join-Path $engineDirectory 'csrun.ps1' -$process = $null -try { - $release = Invoke-RestMethod 'https://api.github.com/repos/codebeltnet/csrun/releases/latest' - $assets = @($release.assets | Where-Object name -CEQ 'csrun.ps1') - if ($assets.Count -ne 1 -or $assets[0].digest -notmatch '^sha256:[0-9a-f]{64}$') { - throw "csrun release $($release.tag_name) must publish one csrun.ps1 asset with a SHA-256 digest." - } - $asset = $assets[0] - Invoke-WebRequest $asset.browser_download_url -OutFile $enginePath - $actualHash = (Get-FileHash -LiteralPath $enginePath -Algorithm SHA256).Hash - if ("sha256:$actualHash" -ne $asset.digest) { throw "csrun asset checksum mismatch: $actualHash" } -$startInfo = [Diagnostics.ProcessStartInfo]::new('pwsh') -foreach ($argument in @('-NoProfile','-NonInteractive','-File')) { $startInfo.ArgumentList.Add($argument) } -$startInfo.ArgumentList.Add($enginePath) -$startInfo.ArgumentList.Add('-ManifestJson') -$startInfo.ArgumentList.Add($manifest) -$startInfo.RedirectStandardOutput = $true -$startInfo.RedirectStandardError = $true -$startInfo.UseShellExecute = $false -$process = [Diagnostics.Process]::new() -$process.StartInfo = $startInfo -if (-not $process.Start()) { throw 'Could not start csrun.' } -$stdoutTask = $process.StandardOutput.ReadToEndAsync() -$stderrTask = $process.StandardError.ReadToEndAsync() -$process.WaitForExit() -$output = $stdoutTask.GetAwaiter().GetResult() -$diagnostics = $stderrTask.GetAwaiter().GetResult() -Write-Output $output -if ($diagnostics) { [Console]::Error.Write($diagnostics) } -} catch { - [Console]::Error.WriteLine("csrun diagnostics retained in: $engineDirectory") - throw -} finally { - $resolvedTemp = [IO.Path]::TrimEndingDirectorySeparator([IO.Path]::GetFullPath([IO.Path]::GetTempPath())) - $resolvedEngineDirectory = [IO.Path]::GetFullPath($engineDirectory) - if ([IO.Path]::GetDirectoryName($resolvedEngineDirectory) -ne $resolvedTemp -or - [IO.Path]::GetFileName($resolvedEngineDirectory) -cnotmatch '^csrun-[a-f0-9]{32}$') { throw 'Unsafe cleanup path.' } - if ($process -and $process.ExitCode -eq 0) { Remove-Item -LiteralPath $resolvedEngineDirectory -Recurse -Force } -} -if ($process.ExitCode -ne 0) { throw "csrun execution failed with exit code $($process.ExitCode). $diagnostics" } -if ($verifyTests) { Assert-CsrunTestOutput $output } -} \ No newline at end of file diff --git a/.docfx/run-actions/6a59b7744a7d9994ffc04782/docker.ps1 b/.docfx/run-actions/6a59b7744a7d9994ffc04782/docker.ps1 deleted file mode 100644 index b581a6b..0000000 --- a/.docfx/run-actions/6a59b7744a7d9994ffc04782/docker.ps1 +++ /dev/null @@ -1,83 +0,0 @@ -& { -#requires -Version 7.0 -$ErrorActionPreference = 'Stop' -$PSNativeCommandUseErrorActionPreference = $false -$manifest = @' -{ - "dependsOn": [ - "Codebelt.Extensions.Xunit.Hosting@13.0.0", - "Microsoft.Extensions.Hosting@10.0.15", - "xunit.v3@4.0.3" - ], - "framework": "net10.0", - "mode": "test", - "schemaVersion": 1, - "source": "using Codebelt.Extensions.Xunit.Hosting;\nusing Microsoft.Extensions.DependencyInjection;\nusing Microsoft.Extensions.Hosting;\nusing Xunit;\n\nnamespace HostFixtureTests;\n\npublic class MinimalWorkerTest : MinimalHostTest\n{\n public MinimalWorkerTest(ManagedMinimalHostFixture hostFixture, ITestOutputHelper output) : base(hostFixture, output)\n {\n }\n\n protected override void ConfigureHost(IHostApplicationBuilder hb)\n {\n hb.Services.AddSingleton();\n hb.Services.AddXunitTestLogging();\n }\n\n [Fact]\n public void Host_ShouldNotBeNull()\n {\n Assert.NotNull(Host);\n }\n}\n\npublic class MetricsTracker;" -} -'@ -$OutputEncoding = [Text.UTF8Encoding]::new($false) -[Console]::OutputEncoding = $OutputEncoding -$verifyTests = $true -function Assert-CsrunTestOutput([string] $Output) { - $lines = @($Output -split '\r?\n') - $headers = @($lines | Where-Object { $_ -match '^Test run summary: Passed! - .+\)$' }) - if ($headers.Count -ne 1) { throw 'Expected exactly one completed xUnit test summary.' } - $headerIndex = [Array]::IndexOf($lines, $headers[0]) - $summaryLines = @($lines | Select-Object -Skip ($headerIndex + 1) -First 4) - $counts = @{} - foreach ($line in $summaryLines) { - if ($line -match '^\s*(total|failed|succeeded|skipped):\s*(\d+)\s*$') { $counts[$Matches[1]] = [int]$Matches[2] } - } - if ($counts.Count -ne 4) { throw 'The xUnit test summary counts are incomplete or ambiguous.' } - $failed = $counts.failed - $passed = $counts.succeeded - $skipped = $counts.skipped - $total = $counts.total - if ($total -lt 1 -or $passed -lt 1 -or $failed -ne 0 -or $skipped -ne 0 -or $passed -ne $total) { - throw 'Tests must execute at least once, all pass, and none fail or skip.' - } -} -# Downloads and executes the latest stable csrun release with your permissions. -# Source and release history: https://github.com/codebeltnet/csrun -$engineDirectory = Join-Path ([IO.Path]::GetTempPath()) ('csrun-' + [guid]::NewGuid().ToString('N')) -$null = New-Item -ItemType Directory -Path $engineDirectory -$enginePath = Join-Path $engineDirectory 'csrun.ps1' -$process = $null -try { - $release = Invoke-RestMethod 'https://api.github.com/repos/codebeltnet/csrun/releases/latest' - $assets = @($release.assets | Where-Object name -CEQ 'csrun.ps1') - if ($assets.Count -ne 1 -or $assets[0].digest -notmatch '^sha256:[0-9a-f]{64}$') { - throw "csrun release $($release.tag_name) must publish one csrun.ps1 asset with a SHA-256 digest." - } - $asset = $assets[0] - Invoke-WebRequest $asset.browser_download_url -OutFile $enginePath - $actualHash = (Get-FileHash -LiteralPath $enginePath -Algorithm SHA256).Hash - if ("sha256:$actualHash" -ne $asset.digest) { throw "csrun asset checksum mismatch: $actualHash" } -$enginePayload = [Convert]::ToBase64String([IO.File]::ReadAllBytes($enginePath)) -$containerInput = $enginePayload + "`n" + $manifest -$command = ' -$ErrorActionPreference = "Stop" -$enginePath = Join-Path ([IO.Path]::GetTempPath()) ("csrun-release-" + [guid]::NewGuid().ToString("N") + ".ps1") -$engineBytes = [Convert]::FromBase64String([Console]::In.ReadLine()) -[IO.File]::WriteAllBytes($enginePath, $engineBytes) -$manifest = [Console]::In.ReadToEnd() -& $enginePath -ManifestJson $manifest -exit $LASTEXITCODE -' -$output = (@($containerInput | & docker run --rm -i --entrypoint pwsh 'codebeltnet/csrun:10' -NoProfile -NonInteractive -Command $command) -join [Environment]::NewLine) -$process = [pscustomobject]@{ ExitCode = $LASTEXITCODE } -$diagnostics = '' -Write-Output $output -} catch { - [Console]::Error.WriteLine("csrun diagnostics retained in: $engineDirectory") - throw -} finally { - $resolvedTemp = [IO.Path]::TrimEndingDirectorySeparator([IO.Path]::GetFullPath([IO.Path]::GetTempPath())) - $resolvedEngineDirectory = [IO.Path]::GetFullPath($engineDirectory) - if ([IO.Path]::GetDirectoryName($resolvedEngineDirectory) -ne $resolvedTemp -or - [IO.Path]::GetFileName($resolvedEngineDirectory) -cnotmatch '^csrun-[a-f0-9]{32}$') { throw 'Unsafe cleanup path.' } - if ($process -and $process.ExitCode -eq 0) { Remove-Item -LiteralPath $resolvedEngineDirectory -Recurse -Force } -} -if ($process.ExitCode -ne 0) { throw "csrun execution failed with exit code $($process.ExitCode). $diagnostics" } -if ($verifyTests) { Assert-CsrunTestOutput $output } -} \ No newline at end of file diff --git a/.docfx/run-actions/6a59b7744a7d9994ffc04782/native.ps1 b/.docfx/run-actions/6a59b7744a7d9994ffc04782/native.ps1 deleted file mode 100644 index de3f93d..0000000 --- a/.docfx/run-actions/6a59b7744a7d9994ffc04782/native.ps1 +++ /dev/null @@ -1,86 +0,0 @@ -& { -#requires -Version 7.0 -$ErrorActionPreference = 'Stop' -$PSNativeCommandUseErrorActionPreference = $false -$manifest = @' -{ - "dependsOn": [ - "Codebelt.Extensions.Xunit.Hosting@13.0.0", - "Microsoft.Extensions.Hosting@10.0.15", - "xunit.v3@4.0.3" - ], - "framework": "net10.0", - "mode": "test", - "schemaVersion": 1, - "source": "using Codebelt.Extensions.Xunit.Hosting;\nusing Microsoft.Extensions.DependencyInjection;\nusing Microsoft.Extensions.Hosting;\nusing Xunit;\n\nnamespace HostFixtureTests;\n\npublic class MinimalWorkerTest : MinimalHostTest\n{\n public MinimalWorkerTest(ManagedMinimalHostFixture hostFixture, ITestOutputHelper output) : base(hostFixture, output)\n {\n }\n\n protected override void ConfigureHost(IHostApplicationBuilder hb)\n {\n hb.Services.AddSingleton();\n hb.Services.AddXunitTestLogging();\n }\n\n [Fact]\n public void Host_ShouldNotBeNull()\n {\n Assert.NotNull(Host);\n }\n}\n\npublic class MetricsTracker;" -} -'@ -$OutputEncoding = [Text.UTF8Encoding]::new($false) -[Console]::OutputEncoding = $OutputEncoding -$verifyTests = $true -function Assert-CsrunTestOutput([string] $Output) { - $lines = @($Output -split '\r?\n') - $headers = @($lines | Where-Object { $_ -match '^Test run summary: Passed! - .+\)$' }) - if ($headers.Count -ne 1) { throw 'Expected exactly one completed xUnit test summary.' } - $headerIndex = [Array]::IndexOf($lines, $headers[0]) - $summaryLines = @($lines | Select-Object -Skip ($headerIndex + 1) -First 4) - $counts = @{} - foreach ($line in $summaryLines) { - if ($line -match '^\s*(total|failed|succeeded|skipped):\s*(\d+)\s*$') { $counts[$Matches[1]] = [int]$Matches[2] } - } - if ($counts.Count -ne 4) { throw 'The xUnit test summary counts are incomplete or ambiguous.' } - $failed = $counts.failed - $passed = $counts.succeeded - $skipped = $counts.skipped - $total = $counts.total - if ($total -lt 1 -or $passed -lt 1 -or $failed -ne 0 -or $skipped -ne 0 -or $passed -ne $total) { - throw 'Tests must execute at least once, all pass, and none fail or skip.' - } -} -# Downloads and executes the latest stable csrun release with your permissions. -# Source and release history: https://github.com/codebeltnet/csrun -$engineDirectory = Join-Path ([IO.Path]::GetTempPath()) ('csrun-' + [guid]::NewGuid().ToString('N')) -$null = New-Item -ItemType Directory -Path $engineDirectory -$enginePath = Join-Path $engineDirectory 'csrun.ps1' -$process = $null -try { - $release = Invoke-RestMethod 'https://api.github.com/repos/codebeltnet/csrun/releases/latest' - $assets = @($release.assets | Where-Object name -CEQ 'csrun.ps1') - if ($assets.Count -ne 1 -or $assets[0].digest -notmatch '^sha256:[0-9a-f]{64}$') { - throw "csrun release $($release.tag_name) must publish one csrun.ps1 asset with a SHA-256 digest." - } - $asset = $assets[0] - Invoke-WebRequest $asset.browser_download_url -OutFile $enginePath - $actualHash = (Get-FileHash -LiteralPath $enginePath -Algorithm SHA256).Hash - if ("sha256:$actualHash" -ne $asset.digest) { throw "csrun asset checksum mismatch: $actualHash" } -$startInfo = [Diagnostics.ProcessStartInfo]::new('pwsh') -foreach ($argument in @('-NoProfile','-NonInteractive','-File')) { $startInfo.ArgumentList.Add($argument) } -$startInfo.ArgumentList.Add($enginePath) -$startInfo.ArgumentList.Add('-ManifestJson') -$startInfo.ArgumentList.Add($manifest) -$startInfo.RedirectStandardOutput = $true -$startInfo.RedirectStandardError = $true -$startInfo.UseShellExecute = $false -$process = [Diagnostics.Process]::new() -$process.StartInfo = $startInfo -if (-not $process.Start()) { throw 'Could not start csrun.' } -$stdoutTask = $process.StandardOutput.ReadToEndAsync() -$stderrTask = $process.StandardError.ReadToEndAsync() -$process.WaitForExit() -$output = $stdoutTask.GetAwaiter().GetResult() -$diagnostics = $stderrTask.GetAwaiter().GetResult() -Write-Output $output -if ($diagnostics) { [Console]::Error.Write($diagnostics) } -} catch { - [Console]::Error.WriteLine("csrun diagnostics retained in: $engineDirectory") - throw -} finally { - $resolvedTemp = [IO.Path]::TrimEndingDirectorySeparator([IO.Path]::GetFullPath([IO.Path]::GetTempPath())) - $resolvedEngineDirectory = [IO.Path]::GetFullPath($engineDirectory) - if ([IO.Path]::GetDirectoryName($resolvedEngineDirectory) -ne $resolvedTemp -or - [IO.Path]::GetFileName($resolvedEngineDirectory) -cnotmatch '^csrun-[a-f0-9]{32}$') { throw 'Unsafe cleanup path.' } - if ($process -and $process.ExitCode -eq 0) { Remove-Item -LiteralPath $resolvedEngineDirectory -Recurse -Force } -} -if ($process.ExitCode -ne 0) { throw "csrun execution failed with exit code $($process.ExitCode). $diagnostics" } -if ($verifyTests) { Assert-CsrunTestOutput $output } -} \ No newline at end of file diff --git a/.docfx/run-actions/782f24d34260070258f6d164/docker.ps1 b/.docfx/run-actions/782f24d34260070258f6d164/docker.ps1 deleted file mode 100644 index 6c98954..0000000 --- a/.docfx/run-actions/782f24d34260070258f6d164/docker.ps1 +++ /dev/null @@ -1,82 +0,0 @@ -& { -#requires -Version 7.0 -$ErrorActionPreference = 'Stop' -$PSNativeCommandUseErrorActionPreference = $false -$manifest = @' -{ - "dependsOn": [ - "Codebelt.Extensions.Xunit@13.0.0", - "xunit.v3@4.0.3" - ], - "framework": "net10.0", - "mode": "test", - "schemaVersion": 1, - "source": "using System;\nusing Codebelt.Extensions.Xunit;\nusing Xunit;\nusing Xunit.Sdk;\n\nnamespace Example.Tests;\n\n[TestMethodOrderer(typeof(PriorityTestMethodOrderer))]\npublic class CacheLifecycleTest : Test\n{\n private static bool _initialized;\n\n public CacheLifecycleTest(ITestOutputHelper output) : base(output) { }\n\n [Fact, Priority(-1)]\n public void ShouldInitializeCache()\n {\n var orderer = new PriorityTestMethodOrderer();\n Assert.Empty(orderer.OrderTestMethods(Array.Empty()));\n _initialized = true;\n }\n\n [Fact, Priority(0)]\n public void ShouldUseInitializedCache()\n {\n Assert.True(_initialized);\n }\n}" -} -'@ -$OutputEncoding = [Text.UTF8Encoding]::new($false) -[Console]::OutputEncoding = $OutputEncoding -$verifyTests = $true -function Assert-CsrunTestOutput([string] $Output) { - $lines = @($Output -split '\r?\n') - $headers = @($lines | Where-Object { $_ -match '^Test run summary: Passed! - .+\)$' }) - if ($headers.Count -ne 1) { throw 'Expected exactly one completed xUnit test summary.' } - $headerIndex = [Array]::IndexOf($lines, $headers[0]) - $summaryLines = @($lines | Select-Object -Skip ($headerIndex + 1) -First 4) - $counts = @{} - foreach ($line in $summaryLines) { - if ($line -match '^\s*(total|failed|succeeded|skipped):\s*(\d+)\s*$') { $counts[$Matches[1]] = [int]$Matches[2] } - } - if ($counts.Count -ne 4) { throw 'The xUnit test summary counts are incomplete or ambiguous.' } - $failed = $counts.failed - $passed = $counts.succeeded - $skipped = $counts.skipped - $total = $counts.total - if ($total -lt 1 -or $passed -lt 1 -or $failed -ne 0 -or $skipped -ne 0 -or $passed -ne $total) { - throw 'Tests must execute at least once, all pass, and none fail or skip.' - } -} -# Downloads and executes the latest stable csrun release with your permissions. -# Source and release history: https://github.com/codebeltnet/csrun -$engineDirectory = Join-Path ([IO.Path]::GetTempPath()) ('csrun-' + [guid]::NewGuid().ToString('N')) -$null = New-Item -ItemType Directory -Path $engineDirectory -$enginePath = Join-Path $engineDirectory 'csrun.ps1' -$process = $null -try { - $release = Invoke-RestMethod 'https://api.github.com/repos/codebeltnet/csrun/releases/latest' - $assets = @($release.assets | Where-Object name -CEQ 'csrun.ps1') - if ($assets.Count -ne 1 -or $assets[0].digest -notmatch '^sha256:[0-9a-f]{64}$') { - throw "csrun release $($release.tag_name) must publish one csrun.ps1 asset with a SHA-256 digest." - } - $asset = $assets[0] - Invoke-WebRequest $asset.browser_download_url -OutFile $enginePath - $actualHash = (Get-FileHash -LiteralPath $enginePath -Algorithm SHA256).Hash - if ("sha256:$actualHash" -ne $asset.digest) { throw "csrun asset checksum mismatch: $actualHash" } -$enginePayload = [Convert]::ToBase64String([IO.File]::ReadAllBytes($enginePath)) -$containerInput = $enginePayload + "`n" + $manifest -$command = ' -$ErrorActionPreference = "Stop" -$enginePath = Join-Path ([IO.Path]::GetTempPath()) ("csrun-release-" + [guid]::NewGuid().ToString("N") + ".ps1") -$engineBytes = [Convert]::FromBase64String([Console]::In.ReadLine()) -[IO.File]::WriteAllBytes($enginePath, $engineBytes) -$manifest = [Console]::In.ReadToEnd() -& $enginePath -ManifestJson $manifest -exit $LASTEXITCODE -' -$output = (@($containerInput | & docker run --rm -i --entrypoint pwsh 'codebeltnet/csrun:10' -NoProfile -NonInteractive -Command $command) -join [Environment]::NewLine) -$process = [pscustomobject]@{ ExitCode = $LASTEXITCODE } -$diagnostics = '' -Write-Output $output -} catch { - [Console]::Error.WriteLine("csrun diagnostics retained in: $engineDirectory") - throw -} finally { - $resolvedTemp = [IO.Path]::TrimEndingDirectorySeparator([IO.Path]::GetFullPath([IO.Path]::GetTempPath())) - $resolvedEngineDirectory = [IO.Path]::GetFullPath($engineDirectory) - if ([IO.Path]::GetDirectoryName($resolvedEngineDirectory) -ne $resolvedTemp -or - [IO.Path]::GetFileName($resolvedEngineDirectory) -cnotmatch '^csrun-[a-f0-9]{32}$') { throw 'Unsafe cleanup path.' } - if ($process -and $process.ExitCode -eq 0) { Remove-Item -LiteralPath $resolvedEngineDirectory -Recurse -Force } -} -if ($process.ExitCode -ne 0) { throw "csrun execution failed with exit code $($process.ExitCode). $diagnostics" } -if ($verifyTests) { Assert-CsrunTestOutput $output } -} \ No newline at end of file diff --git a/.docfx/run-actions/782f24d34260070258f6d164/native.ps1 b/.docfx/run-actions/782f24d34260070258f6d164/native.ps1 deleted file mode 100644 index 290f2a4..0000000 --- a/.docfx/run-actions/782f24d34260070258f6d164/native.ps1 +++ /dev/null @@ -1,85 +0,0 @@ -& { -#requires -Version 7.0 -$ErrorActionPreference = 'Stop' -$PSNativeCommandUseErrorActionPreference = $false -$manifest = @' -{ - "dependsOn": [ - "Codebelt.Extensions.Xunit@13.0.0", - "xunit.v3@4.0.3" - ], - "framework": "net10.0", - "mode": "test", - "schemaVersion": 1, - "source": "using System;\nusing Codebelt.Extensions.Xunit;\nusing Xunit;\nusing Xunit.Sdk;\n\nnamespace Example.Tests;\n\n[TestMethodOrderer(typeof(PriorityTestMethodOrderer))]\npublic class CacheLifecycleTest : Test\n{\n private static bool _initialized;\n\n public CacheLifecycleTest(ITestOutputHelper output) : base(output) { }\n\n [Fact, Priority(-1)]\n public void ShouldInitializeCache()\n {\n var orderer = new PriorityTestMethodOrderer();\n Assert.Empty(orderer.OrderTestMethods(Array.Empty()));\n _initialized = true;\n }\n\n [Fact, Priority(0)]\n public void ShouldUseInitializedCache()\n {\n Assert.True(_initialized);\n }\n}" -} -'@ -$OutputEncoding = [Text.UTF8Encoding]::new($false) -[Console]::OutputEncoding = $OutputEncoding -$verifyTests = $true -function Assert-CsrunTestOutput([string] $Output) { - $lines = @($Output -split '\r?\n') - $headers = @($lines | Where-Object { $_ -match '^Test run summary: Passed! - .+\)$' }) - if ($headers.Count -ne 1) { throw 'Expected exactly one completed xUnit test summary.' } - $headerIndex = [Array]::IndexOf($lines, $headers[0]) - $summaryLines = @($lines | Select-Object -Skip ($headerIndex + 1) -First 4) - $counts = @{} - foreach ($line in $summaryLines) { - if ($line -match '^\s*(total|failed|succeeded|skipped):\s*(\d+)\s*$') { $counts[$Matches[1]] = [int]$Matches[2] } - } - if ($counts.Count -ne 4) { throw 'The xUnit test summary counts are incomplete or ambiguous.' } - $failed = $counts.failed - $passed = $counts.succeeded - $skipped = $counts.skipped - $total = $counts.total - if ($total -lt 1 -or $passed -lt 1 -or $failed -ne 0 -or $skipped -ne 0 -or $passed -ne $total) { - throw 'Tests must execute at least once, all pass, and none fail or skip.' - } -} -# Downloads and executes the latest stable csrun release with your permissions. -# Source and release history: https://github.com/codebeltnet/csrun -$engineDirectory = Join-Path ([IO.Path]::GetTempPath()) ('csrun-' + [guid]::NewGuid().ToString('N')) -$null = New-Item -ItemType Directory -Path $engineDirectory -$enginePath = Join-Path $engineDirectory 'csrun.ps1' -$process = $null -try { - $release = Invoke-RestMethod 'https://api.github.com/repos/codebeltnet/csrun/releases/latest' - $assets = @($release.assets | Where-Object name -CEQ 'csrun.ps1') - if ($assets.Count -ne 1 -or $assets[0].digest -notmatch '^sha256:[0-9a-f]{64}$') { - throw "csrun release $($release.tag_name) must publish one csrun.ps1 asset with a SHA-256 digest." - } - $asset = $assets[0] - Invoke-WebRequest $asset.browser_download_url -OutFile $enginePath - $actualHash = (Get-FileHash -LiteralPath $enginePath -Algorithm SHA256).Hash - if ("sha256:$actualHash" -ne $asset.digest) { throw "csrun asset checksum mismatch: $actualHash" } -$startInfo = [Diagnostics.ProcessStartInfo]::new('pwsh') -foreach ($argument in @('-NoProfile','-NonInteractive','-File')) { $startInfo.ArgumentList.Add($argument) } -$startInfo.ArgumentList.Add($enginePath) -$startInfo.ArgumentList.Add('-ManifestJson') -$startInfo.ArgumentList.Add($manifest) -$startInfo.RedirectStandardOutput = $true -$startInfo.RedirectStandardError = $true -$startInfo.UseShellExecute = $false -$process = [Diagnostics.Process]::new() -$process.StartInfo = $startInfo -if (-not $process.Start()) { throw 'Could not start csrun.' } -$stdoutTask = $process.StandardOutput.ReadToEndAsync() -$stderrTask = $process.StandardError.ReadToEndAsync() -$process.WaitForExit() -$output = $stdoutTask.GetAwaiter().GetResult() -$diagnostics = $stderrTask.GetAwaiter().GetResult() -Write-Output $output -if ($diagnostics) { [Console]::Error.Write($diagnostics) } -} catch { - [Console]::Error.WriteLine("csrun diagnostics retained in: $engineDirectory") - throw -} finally { - $resolvedTemp = [IO.Path]::TrimEndingDirectorySeparator([IO.Path]::GetFullPath([IO.Path]::GetTempPath())) - $resolvedEngineDirectory = [IO.Path]::GetFullPath($engineDirectory) - if ([IO.Path]::GetDirectoryName($resolvedEngineDirectory) -ne $resolvedTemp -or - [IO.Path]::GetFileName($resolvedEngineDirectory) -cnotmatch '^csrun-[a-f0-9]{32}$') { throw 'Unsafe cleanup path.' } - if ($process -and $process.ExitCode -eq 0) { Remove-Item -LiteralPath $resolvedEngineDirectory -Recurse -Force } -} -if ($process.ExitCode -ne 0) { throw "csrun execution failed with exit code $($process.ExitCode). $diagnostics" } -if ($verifyTests) { Assert-CsrunTestOutput $output } -} \ No newline at end of file diff --git a/.docfx/run-actions/812efaa205554c7bdcd80831/docker.ps1 b/.docfx/run-actions/812efaa205554c7bdcd80831/docker.ps1 deleted file mode 100644 index d1f8e6b..0000000 --- a/.docfx/run-actions/812efaa205554c7bdcd80831/docker.ps1 +++ /dev/null @@ -1,82 +0,0 @@ -& { -#requires -Version 7.0 -$ErrorActionPreference = 'Stop' -$PSNativeCommandUseErrorActionPreference = $false -$manifest = @' -{ - "dependsOn": [ - "Codebelt.Extensions.Xunit@13.0.0", - "xunit.v3@4.0.3" - ], - "framework": "net10.0", - "mode": "test", - "schemaVersion": 1, - "source": "using Codebelt.Extensions.Xunit;\nusing Xunit;\n\nnamespace Example.Tests;\n\n[TestMethodOrderer(typeof(PriorityTestMethodOrderer))]\npublic class InitializationTest : Test\n{\n private static string _value;\n\n public InitializationTest(ITestOutputHelper output) : base(output) { }\n\n [Fact, Priority(0)]\n public void ShouldInitializeFirst()\n {\n var priority = new PriorityAttribute(0);\n Assert.Equal(0, priority.Priority);\n _value = \"ready\";\n }\n\n [Fact, Priority(1)]\n public void ShouldReadInitializedValue()\n {\n Assert.Equal(\"ready\", _value);\n }\n}" -} -'@ -$OutputEncoding = [Text.UTF8Encoding]::new($false) -[Console]::OutputEncoding = $OutputEncoding -$verifyTests = $true -function Assert-CsrunTestOutput([string] $Output) { - $lines = @($Output -split '\r?\n') - $headers = @($lines | Where-Object { $_ -match '^Test run summary: Passed! - .+\)$' }) - if ($headers.Count -ne 1) { throw 'Expected exactly one completed xUnit test summary.' } - $headerIndex = [Array]::IndexOf($lines, $headers[0]) - $summaryLines = @($lines | Select-Object -Skip ($headerIndex + 1) -First 4) - $counts = @{} - foreach ($line in $summaryLines) { - if ($line -match '^\s*(total|failed|succeeded|skipped):\s*(\d+)\s*$') { $counts[$Matches[1]] = [int]$Matches[2] } - } - if ($counts.Count -ne 4) { throw 'The xUnit test summary counts are incomplete or ambiguous.' } - $failed = $counts.failed - $passed = $counts.succeeded - $skipped = $counts.skipped - $total = $counts.total - if ($total -lt 1 -or $passed -lt 1 -or $failed -ne 0 -or $skipped -ne 0 -or $passed -ne $total) { - throw 'Tests must execute at least once, all pass, and none fail or skip.' - } -} -# Downloads and executes the latest stable csrun release with your permissions. -# Source and release history: https://github.com/codebeltnet/csrun -$engineDirectory = Join-Path ([IO.Path]::GetTempPath()) ('csrun-' + [guid]::NewGuid().ToString('N')) -$null = New-Item -ItemType Directory -Path $engineDirectory -$enginePath = Join-Path $engineDirectory 'csrun.ps1' -$process = $null -try { - $release = Invoke-RestMethod 'https://api.github.com/repos/codebeltnet/csrun/releases/latest' - $assets = @($release.assets | Where-Object name -CEQ 'csrun.ps1') - if ($assets.Count -ne 1 -or $assets[0].digest -notmatch '^sha256:[0-9a-f]{64}$') { - throw "csrun release $($release.tag_name) must publish one csrun.ps1 asset with a SHA-256 digest." - } - $asset = $assets[0] - Invoke-WebRequest $asset.browser_download_url -OutFile $enginePath - $actualHash = (Get-FileHash -LiteralPath $enginePath -Algorithm SHA256).Hash - if ("sha256:$actualHash" -ne $asset.digest) { throw "csrun asset checksum mismatch: $actualHash" } -$enginePayload = [Convert]::ToBase64String([IO.File]::ReadAllBytes($enginePath)) -$containerInput = $enginePayload + "`n" + $manifest -$command = ' -$ErrorActionPreference = "Stop" -$enginePath = Join-Path ([IO.Path]::GetTempPath()) ("csrun-release-" + [guid]::NewGuid().ToString("N") + ".ps1") -$engineBytes = [Convert]::FromBase64String([Console]::In.ReadLine()) -[IO.File]::WriteAllBytes($enginePath, $engineBytes) -$manifest = [Console]::In.ReadToEnd() -& $enginePath -ManifestJson $manifest -exit $LASTEXITCODE -' -$output = (@($containerInput | & docker run --rm -i --entrypoint pwsh 'codebeltnet/csrun:10' -NoProfile -NonInteractive -Command $command) -join [Environment]::NewLine) -$process = [pscustomobject]@{ ExitCode = $LASTEXITCODE } -$diagnostics = '' -Write-Output $output -} catch { - [Console]::Error.WriteLine("csrun diagnostics retained in: $engineDirectory") - throw -} finally { - $resolvedTemp = [IO.Path]::TrimEndingDirectorySeparator([IO.Path]::GetFullPath([IO.Path]::GetTempPath())) - $resolvedEngineDirectory = [IO.Path]::GetFullPath($engineDirectory) - if ([IO.Path]::GetDirectoryName($resolvedEngineDirectory) -ne $resolvedTemp -or - [IO.Path]::GetFileName($resolvedEngineDirectory) -cnotmatch '^csrun-[a-f0-9]{32}$') { throw 'Unsafe cleanup path.' } - if ($process -and $process.ExitCode -eq 0) { Remove-Item -LiteralPath $resolvedEngineDirectory -Recurse -Force } -} -if ($process.ExitCode -ne 0) { throw "csrun execution failed with exit code $($process.ExitCode). $diagnostics" } -if ($verifyTests) { Assert-CsrunTestOutput $output } -} \ No newline at end of file diff --git a/.docfx/run-actions/812efaa205554c7bdcd80831/native.ps1 b/.docfx/run-actions/812efaa205554c7bdcd80831/native.ps1 deleted file mode 100644 index bb270a5..0000000 --- a/.docfx/run-actions/812efaa205554c7bdcd80831/native.ps1 +++ /dev/null @@ -1,85 +0,0 @@ -& { -#requires -Version 7.0 -$ErrorActionPreference = 'Stop' -$PSNativeCommandUseErrorActionPreference = $false -$manifest = @' -{ - "dependsOn": [ - "Codebelt.Extensions.Xunit@13.0.0", - "xunit.v3@4.0.3" - ], - "framework": "net10.0", - "mode": "test", - "schemaVersion": 1, - "source": "using Codebelt.Extensions.Xunit;\nusing Xunit;\n\nnamespace Example.Tests;\n\n[TestMethodOrderer(typeof(PriorityTestMethodOrderer))]\npublic class InitializationTest : Test\n{\n private static string _value;\n\n public InitializationTest(ITestOutputHelper output) : base(output) { }\n\n [Fact, Priority(0)]\n public void ShouldInitializeFirst()\n {\n var priority = new PriorityAttribute(0);\n Assert.Equal(0, priority.Priority);\n _value = \"ready\";\n }\n\n [Fact, Priority(1)]\n public void ShouldReadInitializedValue()\n {\n Assert.Equal(\"ready\", _value);\n }\n}" -} -'@ -$OutputEncoding = [Text.UTF8Encoding]::new($false) -[Console]::OutputEncoding = $OutputEncoding -$verifyTests = $true -function Assert-CsrunTestOutput([string] $Output) { - $lines = @($Output -split '\r?\n') - $headers = @($lines | Where-Object { $_ -match '^Test run summary: Passed! - .+\)$' }) - if ($headers.Count -ne 1) { throw 'Expected exactly one completed xUnit test summary.' } - $headerIndex = [Array]::IndexOf($lines, $headers[0]) - $summaryLines = @($lines | Select-Object -Skip ($headerIndex + 1) -First 4) - $counts = @{} - foreach ($line in $summaryLines) { - if ($line -match '^\s*(total|failed|succeeded|skipped):\s*(\d+)\s*$') { $counts[$Matches[1]] = [int]$Matches[2] } - } - if ($counts.Count -ne 4) { throw 'The xUnit test summary counts are incomplete or ambiguous.' } - $failed = $counts.failed - $passed = $counts.succeeded - $skipped = $counts.skipped - $total = $counts.total - if ($total -lt 1 -or $passed -lt 1 -or $failed -ne 0 -or $skipped -ne 0 -or $passed -ne $total) { - throw 'Tests must execute at least once, all pass, and none fail or skip.' - } -} -# Downloads and executes the latest stable csrun release with your permissions. -# Source and release history: https://github.com/codebeltnet/csrun -$engineDirectory = Join-Path ([IO.Path]::GetTempPath()) ('csrun-' + [guid]::NewGuid().ToString('N')) -$null = New-Item -ItemType Directory -Path $engineDirectory -$enginePath = Join-Path $engineDirectory 'csrun.ps1' -$process = $null -try { - $release = Invoke-RestMethod 'https://api.github.com/repos/codebeltnet/csrun/releases/latest' - $assets = @($release.assets | Where-Object name -CEQ 'csrun.ps1') - if ($assets.Count -ne 1 -or $assets[0].digest -notmatch '^sha256:[0-9a-f]{64}$') { - throw "csrun release $($release.tag_name) must publish one csrun.ps1 asset with a SHA-256 digest." - } - $asset = $assets[0] - Invoke-WebRequest $asset.browser_download_url -OutFile $enginePath - $actualHash = (Get-FileHash -LiteralPath $enginePath -Algorithm SHA256).Hash - if ("sha256:$actualHash" -ne $asset.digest) { throw "csrun asset checksum mismatch: $actualHash" } -$startInfo = [Diagnostics.ProcessStartInfo]::new('pwsh') -foreach ($argument in @('-NoProfile','-NonInteractive','-File')) { $startInfo.ArgumentList.Add($argument) } -$startInfo.ArgumentList.Add($enginePath) -$startInfo.ArgumentList.Add('-ManifestJson') -$startInfo.ArgumentList.Add($manifest) -$startInfo.RedirectStandardOutput = $true -$startInfo.RedirectStandardError = $true -$startInfo.UseShellExecute = $false -$process = [Diagnostics.Process]::new() -$process.StartInfo = $startInfo -if (-not $process.Start()) { throw 'Could not start csrun.' } -$stdoutTask = $process.StandardOutput.ReadToEndAsync() -$stderrTask = $process.StandardError.ReadToEndAsync() -$process.WaitForExit() -$output = $stdoutTask.GetAwaiter().GetResult() -$diagnostics = $stderrTask.GetAwaiter().GetResult() -Write-Output $output -if ($diagnostics) { [Console]::Error.Write($diagnostics) } -} catch { - [Console]::Error.WriteLine("csrun diagnostics retained in: $engineDirectory") - throw -} finally { - $resolvedTemp = [IO.Path]::TrimEndingDirectorySeparator([IO.Path]::GetFullPath([IO.Path]::GetTempPath())) - $resolvedEngineDirectory = [IO.Path]::GetFullPath($engineDirectory) - if ([IO.Path]::GetDirectoryName($resolvedEngineDirectory) -ne $resolvedTemp -or - [IO.Path]::GetFileName($resolvedEngineDirectory) -cnotmatch '^csrun-[a-f0-9]{32}$') { throw 'Unsafe cleanup path.' } - if ($process -and $process.ExitCode -eq 0) { Remove-Item -LiteralPath $resolvedEngineDirectory -Recurse -Force } -} -if ($process.ExitCode -ne 0) { throw "csrun execution failed with exit code $($process.ExitCode). $diagnostics" } -if ($verifyTests) { Assert-CsrunTestOutput $output } -} \ No newline at end of file diff --git a/.docfx/run-actions/90a8cd444bd08a0115613e58/docker.ps1 b/.docfx/run-actions/90a8cd444bd08a0115613e58/docker.ps1 deleted file mode 100644 index b7d2512..0000000 --- a/.docfx/run-actions/90a8cd444bd08a0115613e58/docker.ps1 +++ /dev/null @@ -1,58 +0,0 @@ -& { -#requires -Version 7.0 - $ErrorActionPreference = 'Stop' - $PSNativeCommandUseErrorActionPreference = $false - # Executes trusted repository build tasks and NuGet packages with your permissions. - # Review the pinned source before running; a container is not a security sandbox. - $null = Get-Command docker -ErrorAction Stop - docker info *> $null - if ($LASTEXITCODE -ne 0) { throw 'Docker daemon unavailable.' } - $work = Join-Path ([IO.Path]::GetTempPath()) ('dx-' + [guid]::NewGuid().ToString('N').Substring(0, 8)) - $null = New-Item -ItemType Directory -Path $work - try { - $commit = '84b13767cb9484f8f3a36a71875662edfdb3e511' - Invoke-WebRequest "https://codeload.github.com/codebeltnet/xunit/zip/$commit" -OutFile "$work/source.zip" - Expand-Archive -LiteralPath "$work/source.zip" -DestinationPath "$work/extracted" - Move-Item -LiteralPath "$work/extracted/xunit-$commit" -Destination "$work/repo" - $project = 'test/Codebelt.Extensions.Xunit.Hosting.FunctionalTests/Codebelt.Extensions.Xunit.Hosting.FunctionalTests.csproj' - $test = 'Codebelt.Extensions.Xunit.Hosting.ApplicationTestFactoryTest.Create_ShouldBootstrapApplication_WhenEntryPointUsesBootstrapperMinimalWorkerProgram' - $dockerUser = @() - if ($IsLinux) { - # Keep bind-mounted build output removable by the host user. - $hostUid = id -u - if ($LASTEXITCODE -ne 0) { throw 'Cannot resolve host UID.' } - $hostGid = id -g - if ($LASTEXITCODE -ne 0) { throw 'Cannot resolve host GID.' } - $dockerUser = @('--user', "${hostUid}:${hostGid}") - } - # Let Docker's init reap orphaned build processes and keep build servers disposable. - docker run --rm --init @dockerUser --env HOME=/tmp --env DOTNET_CLI_HOME=/tmp --env MSBUILDDISABLENODEREUSE=1 --mount "type=bind,source=$work,target=/work" --workdir /work/repo mcr.microsoft.com/dotnet/sdk:11.0 dotnet run --disable-build-servers --project $project --framework net11.0 -p:SkipSignAssembly=true -- --filter-method $test --report-xunit-xml --report-xunit-xml-filename result.xml --results-directory /work/results 2>&1 | Tee-Object -FilePath "$work/run.log" - $code = $LASTEXITCODE - if ($code -ne 0) { throw "Repository test failed with exit code $code. See $work/run.log" } - # Require exactly the original test, executed and passing, with no runner errors. - [xml] $report = Get-Content -LiteralPath "$work/results/result.xml" -Raw - $tests = @($report.SelectNodes('/assemblies/assembly/collection/test')) - $assemblies = @($report.SelectNodes('/assemblies/assembly')) - if ($assemblies.Count -ne 1 -or $assemblies[0].total -ne '1' -or $assemblies[0].passed -ne '1' -or - $assemblies[0].errors -ne '0' -or $tests.Count -ne 1 -or $tests[0].name -cne $test -or $tests[0].result -cne 'Pass') { - throw "Expected exactly one passing $test; inspect $work/results/result.xml" - } - Write-Host "Verified: $test (1 executed, 1 passed)." - } - catch { - # Preserve diagnostics outside the repository even though downloaded source is cleaned. - $diagnostics = "$work-diagnostics" - $null = New-Item -ItemType Directory -Path $diagnostics -Force - foreach ($name in @('run.log', 'results')) { - if (Test-Path -LiteralPath "$work/$name") { Copy-Item -LiteralPath "$work/$name" -Destination $diagnostics -Recurse } - } - Write-Warning "Execution not verified. Diagnostics: $diagnostics" - throw - } - finally { - $resolved = [IO.Path]::GetFullPath($work) - $temp = [IO.Path]::GetFullPath([IO.Path]::GetTempPath()).TrimEnd('/','\') + [IO.Path]::DirectorySeparatorChar - if (-not $resolved.StartsWith($temp, [StringComparison]::OrdinalIgnoreCase)) { throw 'Unsafe cleanup path.' } - Remove-Item -LiteralPath $resolved -Recurse -Force - } -} \ No newline at end of file diff --git a/.docfx/run-actions/90a8cd444bd08a0115613e58/native.ps1 b/.docfx/run-actions/90a8cd444bd08a0115613e58/native.ps1 deleted file mode 100644 index 5e9b40c..0000000 --- a/.docfx/run-actions/90a8cd444bd08a0115613e58/native.ps1 +++ /dev/null @@ -1,50 +0,0 @@ -& { -#requires -Version 7.0 - $ErrorActionPreference = 'Stop' - $PSNativeCommandUseErrorActionPreference = $false - # Executes trusted repository build tasks and NuGet packages with your permissions. - # Review the pinned source before running; a container is not a security sandbox. - $null = Get-Command dotnet -ErrorAction Stop - $work = Join-Path ([IO.Path]::GetTempPath()) ('dx-' + [guid]::NewGuid().ToString('N').Substring(0, 8)) - $null = New-Item -ItemType Directory -Path $work - try { - $commit = '84b13767cb9484f8f3a36a71875662edfdb3e511' - Invoke-WebRequest "https://codeload.github.com/codebeltnet/xunit/zip/$commit" -OutFile "$work/source.zip" - Expand-Archive -LiteralPath "$work/source.zip" -DestinationPath "$work/extracted" - Move-Item -LiteralPath "$work/extracted/xunit-$commit" -Destination "$work/repo" - $project = 'test/Codebelt.Extensions.Xunit.Hosting.FunctionalTests/Codebelt.Extensions.Xunit.Hosting.FunctionalTests.csproj' - $test = 'Codebelt.Extensions.Xunit.Hosting.ApplicationTestFactoryTest.Create_ShouldBootstrapApplication_WhenEntryPointUsesBootstrapperMinimalWorkerProgram' - Push-Location "$work/repo" - try { - dotnet run --project $project --framework net11.0 -p:SkipSignAssembly=true -- --filter-method $test --report-xunit-xml --report-xunit-xml-filename result.xml --results-directory "$work/results" 2>&1 | Tee-Object -FilePath "$work/run.log" - } - finally { Pop-Location } - $code = $LASTEXITCODE - if ($code -ne 0) { throw "Repository test failed with exit code $code. See $work/run.log" } - # Require exactly the original test, executed and passing, with no runner errors. - [xml] $report = Get-Content -LiteralPath "$work/results/result.xml" -Raw - $tests = @($report.SelectNodes('/assemblies/assembly/collection/test')) - $assemblies = @($report.SelectNodes('/assemblies/assembly')) - if ($assemblies.Count -ne 1 -or $assemblies[0].total -ne '1' -or $assemblies[0].passed -ne '1' -or - $assemblies[0].errors -ne '0' -or $tests.Count -ne 1 -or $tests[0].name -cne $test -or $tests[0].result -cne 'Pass') { - throw "Expected exactly one passing $test; inspect $work/results/result.xml" - } - Write-Host "Verified: $test (1 executed, 1 passed)." - } - catch { - # Preserve diagnostics outside the repository even though downloaded source is cleaned. - $diagnostics = "$work-diagnostics" - $null = New-Item -ItemType Directory -Path $diagnostics -Force - foreach ($name in @('run.log', 'results')) { - if (Test-Path -LiteralPath "$work/$name") { Copy-Item -LiteralPath "$work/$name" -Destination $diagnostics -Recurse } - } - Write-Warning "Execution not verified. Diagnostics: $diagnostics" - throw - } - finally { - $resolved = [IO.Path]::GetFullPath($work) - $temp = [IO.Path]::GetFullPath([IO.Path]::GetTempPath()).TrimEnd('/','\') + [IO.Path]::DirectorySeparatorChar - if (-not $resolved.StartsWith($temp, [StringComparison]::OrdinalIgnoreCase)) { throw 'Unsafe cleanup path.' } - Remove-Item -LiteralPath $resolved -Recurse -Force - } -} \ No newline at end of file diff --git a/.docfx/run-actions/927ca9f6a3bf893bc52887f4/docker.ps1 b/.docfx/run-actions/927ca9f6a3bf893bc52887f4/docker.ps1 deleted file mode 100644 index be7beec..0000000 --- a/.docfx/run-actions/927ca9f6a3bf893bc52887f4/docker.ps1 +++ /dev/null @@ -1,86 +0,0 @@ -& { -#requires -Version 7.0 -$ErrorActionPreference = 'Stop' -$PSNativeCommandUseErrorActionPreference = $false -$manifest = @' -{ - "dependsOn": [ - "Codebelt.Extensions.Xunit.Hosting.AspNetCore@13.0.0", - "Microsoft.Extensions.Hosting@10.0.15", - "xunit.v3@4.0.3" - ], - "framework": "net10.0", - "frameworkReferences": [ - "Microsoft.AspNetCore.App" - ], - "mode": "test", - "schemaVersion": 1, - "source": "using System.Threading.Tasks;\nusing Codebelt.Extensions.Xunit.Hosting.AspNetCore;\nusing Microsoft.AspNetCore.Builder;\nusing Microsoft.AspNetCore.Http;\nusing Microsoft.Extensions.DependencyInjection;\nusing Xunit;\n\nnamespace WebFixtureTests;\n\npublic class MiddlewareTest : WebHostTest\n{\n public MiddlewareTest(ManagedWebHostFixture hostFixture, ITestOutputHelper output) : base(hostFixture, output)\n {\n }\n\n public override void ConfigureServices(IServiceCollection services)\n {\n services.AddFakeHttpContextAccessor();\n }\n\n public override void ConfigureApplication(IApplicationBuilder app)\n {\n app.UseMiddleware();\n }\n\n [Fact]\n public async Task Middleware_ShouldAddHeader()\n {\n var pipeline = Application.Build();\n var context = new DefaultHttpContext();\n await pipeline(context);\n Assert.True(context.Response.Headers.ContainsKey(\"X-Test\"));\n }\n}\n\npublic class TestMiddleware(RequestDelegate next)\n{\n public async Task InvokeAsync(HttpContext context)\n {\n context.Response.Headers[\"X-Test\"] = \"true\";\n await next(context);\n }\n}" -} -'@ -$OutputEncoding = [Text.UTF8Encoding]::new($false) -[Console]::OutputEncoding = $OutputEncoding -$verifyTests = $true -function Assert-CsrunTestOutput([string] $Output) { - $lines = @($Output -split '\r?\n') - $headers = @($lines | Where-Object { $_ -match '^Test run summary: Passed! - .+\)$' }) - if ($headers.Count -ne 1) { throw 'Expected exactly one completed xUnit test summary.' } - $headerIndex = [Array]::IndexOf($lines, $headers[0]) - $summaryLines = @($lines | Select-Object -Skip ($headerIndex + 1) -First 4) - $counts = @{} - foreach ($line in $summaryLines) { - if ($line -match '^\s*(total|failed|succeeded|skipped):\s*(\d+)\s*$') { $counts[$Matches[1]] = [int]$Matches[2] } - } - if ($counts.Count -ne 4) { throw 'The xUnit test summary counts are incomplete or ambiguous.' } - $failed = $counts.failed - $passed = $counts.succeeded - $skipped = $counts.skipped - $total = $counts.total - if ($total -lt 1 -or $passed -lt 1 -or $failed -ne 0 -or $skipped -ne 0 -or $passed -ne $total) { - throw 'Tests must execute at least once, all pass, and none fail or skip.' - } -} -# Downloads and executes the latest stable csrun release with your permissions. -# Source and release history: https://github.com/codebeltnet/csrun -$engineDirectory = Join-Path ([IO.Path]::GetTempPath()) ('csrun-' + [guid]::NewGuid().ToString('N')) -$null = New-Item -ItemType Directory -Path $engineDirectory -$enginePath = Join-Path $engineDirectory 'csrun.ps1' -$process = $null -try { - $release = Invoke-RestMethod 'https://api.github.com/repos/codebeltnet/csrun/releases/latest' - $assets = @($release.assets | Where-Object name -CEQ 'csrun.ps1') - if ($assets.Count -ne 1 -or $assets[0].digest -notmatch '^sha256:[0-9a-f]{64}$') { - throw "csrun release $($release.tag_name) must publish one csrun.ps1 asset with a SHA-256 digest." - } - $asset = $assets[0] - Invoke-WebRequest $asset.browser_download_url -OutFile $enginePath - $actualHash = (Get-FileHash -LiteralPath $enginePath -Algorithm SHA256).Hash - if ("sha256:$actualHash" -ne $asset.digest) { throw "csrun asset checksum mismatch: $actualHash" } -$enginePayload = [Convert]::ToBase64String([IO.File]::ReadAllBytes($enginePath)) -$containerInput = $enginePayload + "`n" + $manifest -$command = ' -$ErrorActionPreference = "Stop" -$enginePath = Join-Path ([IO.Path]::GetTempPath()) ("csrun-release-" + [guid]::NewGuid().ToString("N") + ".ps1") -$engineBytes = [Convert]::FromBase64String([Console]::In.ReadLine()) -[IO.File]::WriteAllBytes($enginePath, $engineBytes) -$manifest = [Console]::In.ReadToEnd() -& $enginePath -ManifestJson $manifest -exit $LASTEXITCODE -' -$output = (@($containerInput | & docker run --rm -i --entrypoint pwsh 'codebeltnet/csrun:10' -NoProfile -NonInteractive -Command $command) -join [Environment]::NewLine) -$process = [pscustomobject]@{ ExitCode = $LASTEXITCODE } -$diagnostics = '' -Write-Output $output -} catch { - [Console]::Error.WriteLine("csrun diagnostics retained in: $engineDirectory") - throw -} finally { - $resolvedTemp = [IO.Path]::TrimEndingDirectorySeparator([IO.Path]::GetFullPath([IO.Path]::GetTempPath())) - $resolvedEngineDirectory = [IO.Path]::GetFullPath($engineDirectory) - if ([IO.Path]::GetDirectoryName($resolvedEngineDirectory) -ne $resolvedTemp -or - [IO.Path]::GetFileName($resolvedEngineDirectory) -cnotmatch '^csrun-[a-f0-9]{32}$') { throw 'Unsafe cleanup path.' } - if ($process -and $process.ExitCode -eq 0) { Remove-Item -LiteralPath $resolvedEngineDirectory -Recurse -Force } -} -if ($process.ExitCode -ne 0) { throw "csrun execution failed with exit code $($process.ExitCode). $diagnostics" } -if ($verifyTests) { Assert-CsrunTestOutput $output } -} \ No newline at end of file diff --git a/.docfx/run-actions/927ca9f6a3bf893bc52887f4/native.ps1 b/.docfx/run-actions/927ca9f6a3bf893bc52887f4/native.ps1 deleted file mode 100644 index ac944b9..0000000 --- a/.docfx/run-actions/927ca9f6a3bf893bc52887f4/native.ps1 +++ /dev/null @@ -1,89 +0,0 @@ -& { -#requires -Version 7.0 -$ErrorActionPreference = 'Stop' -$PSNativeCommandUseErrorActionPreference = $false -$manifest = @' -{ - "dependsOn": [ - "Codebelt.Extensions.Xunit.Hosting.AspNetCore@13.0.0", - "Microsoft.Extensions.Hosting@10.0.15", - "xunit.v3@4.0.3" - ], - "framework": "net10.0", - "frameworkReferences": [ - "Microsoft.AspNetCore.App" - ], - "mode": "test", - "schemaVersion": 1, - "source": "using System.Threading.Tasks;\nusing Codebelt.Extensions.Xunit.Hosting.AspNetCore;\nusing Microsoft.AspNetCore.Builder;\nusing Microsoft.AspNetCore.Http;\nusing Microsoft.Extensions.DependencyInjection;\nusing Xunit;\n\nnamespace WebFixtureTests;\n\npublic class MiddlewareTest : WebHostTest\n{\n public MiddlewareTest(ManagedWebHostFixture hostFixture, ITestOutputHelper output) : base(hostFixture, output)\n {\n }\n\n public override void ConfigureServices(IServiceCollection services)\n {\n services.AddFakeHttpContextAccessor();\n }\n\n public override void ConfigureApplication(IApplicationBuilder app)\n {\n app.UseMiddleware();\n }\n\n [Fact]\n public async Task Middleware_ShouldAddHeader()\n {\n var pipeline = Application.Build();\n var context = new DefaultHttpContext();\n await pipeline(context);\n Assert.True(context.Response.Headers.ContainsKey(\"X-Test\"));\n }\n}\n\npublic class TestMiddleware(RequestDelegate next)\n{\n public async Task InvokeAsync(HttpContext context)\n {\n context.Response.Headers[\"X-Test\"] = \"true\";\n await next(context);\n }\n}" -} -'@ -$OutputEncoding = [Text.UTF8Encoding]::new($false) -[Console]::OutputEncoding = $OutputEncoding -$verifyTests = $true -function Assert-CsrunTestOutput([string] $Output) { - $lines = @($Output -split '\r?\n') - $headers = @($lines | Where-Object { $_ -match '^Test run summary: Passed! - .+\)$' }) - if ($headers.Count -ne 1) { throw 'Expected exactly one completed xUnit test summary.' } - $headerIndex = [Array]::IndexOf($lines, $headers[0]) - $summaryLines = @($lines | Select-Object -Skip ($headerIndex + 1) -First 4) - $counts = @{} - foreach ($line in $summaryLines) { - if ($line -match '^\s*(total|failed|succeeded|skipped):\s*(\d+)\s*$') { $counts[$Matches[1]] = [int]$Matches[2] } - } - if ($counts.Count -ne 4) { throw 'The xUnit test summary counts are incomplete or ambiguous.' } - $failed = $counts.failed - $passed = $counts.succeeded - $skipped = $counts.skipped - $total = $counts.total - if ($total -lt 1 -or $passed -lt 1 -or $failed -ne 0 -or $skipped -ne 0 -or $passed -ne $total) { - throw 'Tests must execute at least once, all pass, and none fail or skip.' - } -} -# Downloads and executes the latest stable csrun release with your permissions. -# Source and release history: https://github.com/codebeltnet/csrun -$engineDirectory = Join-Path ([IO.Path]::GetTempPath()) ('csrun-' + [guid]::NewGuid().ToString('N')) -$null = New-Item -ItemType Directory -Path $engineDirectory -$enginePath = Join-Path $engineDirectory 'csrun.ps1' -$process = $null -try { - $release = Invoke-RestMethod 'https://api.github.com/repos/codebeltnet/csrun/releases/latest' - $assets = @($release.assets | Where-Object name -CEQ 'csrun.ps1') - if ($assets.Count -ne 1 -or $assets[0].digest -notmatch '^sha256:[0-9a-f]{64}$') { - throw "csrun release $($release.tag_name) must publish one csrun.ps1 asset with a SHA-256 digest." - } - $asset = $assets[0] - Invoke-WebRequest $asset.browser_download_url -OutFile $enginePath - $actualHash = (Get-FileHash -LiteralPath $enginePath -Algorithm SHA256).Hash - if ("sha256:$actualHash" -ne $asset.digest) { throw "csrun asset checksum mismatch: $actualHash" } -$startInfo = [Diagnostics.ProcessStartInfo]::new('pwsh') -foreach ($argument in @('-NoProfile','-NonInteractive','-File')) { $startInfo.ArgumentList.Add($argument) } -$startInfo.ArgumentList.Add($enginePath) -$startInfo.ArgumentList.Add('-ManifestJson') -$startInfo.ArgumentList.Add($manifest) -$startInfo.RedirectStandardOutput = $true -$startInfo.RedirectStandardError = $true -$startInfo.UseShellExecute = $false -$process = [Diagnostics.Process]::new() -$process.StartInfo = $startInfo -if (-not $process.Start()) { throw 'Could not start csrun.' } -$stdoutTask = $process.StandardOutput.ReadToEndAsync() -$stderrTask = $process.StandardError.ReadToEndAsync() -$process.WaitForExit() -$output = $stdoutTask.GetAwaiter().GetResult() -$diagnostics = $stderrTask.GetAwaiter().GetResult() -Write-Output $output -if ($diagnostics) { [Console]::Error.Write($diagnostics) } -} catch { - [Console]::Error.WriteLine("csrun diagnostics retained in: $engineDirectory") - throw -} finally { - $resolvedTemp = [IO.Path]::TrimEndingDirectorySeparator([IO.Path]::GetFullPath([IO.Path]::GetTempPath())) - $resolvedEngineDirectory = [IO.Path]::GetFullPath($engineDirectory) - if ([IO.Path]::GetDirectoryName($resolvedEngineDirectory) -ne $resolvedTemp -or - [IO.Path]::GetFileName($resolvedEngineDirectory) -cnotmatch '^csrun-[a-f0-9]{32}$') { throw 'Unsafe cleanup path.' } - if ($process -and $process.ExitCode -eq 0) { Remove-Item -LiteralPath $resolvedEngineDirectory -Recurse -Force } -} -if ($process.ExitCode -ne 0) { throw "csrun execution failed with exit code $($process.ExitCode). $diagnostics" } -if ($verifyTests) { Assert-CsrunTestOutput $output } -} \ No newline at end of file diff --git a/.docfx/run-actions/947406357e3e26b26a71a538/docker.ps1 b/.docfx/run-actions/947406357e3e26b26a71a538/docker.ps1 deleted file mode 100644 index ed02c38..0000000 --- a/.docfx/run-actions/947406357e3e26b26a71a538/docker.ps1 +++ /dev/null @@ -1,87 +0,0 @@ -& { -#requires -Version 7.0 -$ErrorActionPreference = 'Stop' -$PSNativeCommandUseErrorActionPreference = $false -$manifest = @' -{ - "dependsOn": [ - "Codebelt.Extensions.Xunit.Hosting.AspNetCore@13.0.0", - "Microsoft.Extensions.Hosting@10.0.15", - "Microsoft.AspNetCore.TestHost@10.0.15" - ], - "framework": "net10.0", - "frameworkReferences": [ - "Microsoft.AspNetCore.App" - ], - "mode": "console", - "schemaVersion": 1, - "sdk": "Microsoft.NET.Sdk.Web", - "source": "using System;\nusing System.Net.Http;\nusing System.Threading.Tasks;\nusing Codebelt.Extensions.Xunit.Hosting.AspNetCore;\nusing Microsoft.AspNetCore.Builder;\nusing Microsoft.AspNetCore.TestHost;\n\nnamespace WebFixtureTests;\n\npublic class HttpClientExample\n{\n public async Task DemonstrateAsync(HttpClient client)\n {\n var response = await client.ToHttpResponseMessageAsync().ConfigureAwait(false);\n Console.WriteLine(response.StatusCode);\n }\n}\n\ninternal static class RunExample\n{\n static async Task Main()\n {\n using var app = WebHostTestFactory.Create(pipelineSetup: app => app.Run(context =>\n {\n context.Response.StatusCode = 202;\n return Task.CompletedTask;\n }));\n using var client = app.Host.GetTestClient();\n await new HttpClientExample().DemonstrateAsync(client);\n }\n}" -} -'@ -$OutputEncoding = [Text.UTF8Encoding]::new($false) -[Console]::OutputEncoding = $OutputEncoding -$verifyTests = $false -function Assert-CsrunTestOutput([string] $Output) { - $lines = @($Output -split '\r?\n') - $headers = @($lines | Where-Object { $_ -match '^Test run summary: Passed! - .+\)$' }) - if ($headers.Count -ne 1) { throw 'Expected exactly one completed xUnit test summary.' } - $headerIndex = [Array]::IndexOf($lines, $headers[0]) - $summaryLines = @($lines | Select-Object -Skip ($headerIndex + 1) -First 4) - $counts = @{} - foreach ($line in $summaryLines) { - if ($line -match '^\s*(total|failed|succeeded|skipped):\s*(\d+)\s*$') { $counts[$Matches[1]] = [int]$Matches[2] } - } - if ($counts.Count -ne 4) { throw 'The xUnit test summary counts are incomplete or ambiguous.' } - $failed = $counts.failed - $passed = $counts.succeeded - $skipped = $counts.skipped - $total = $counts.total - if ($total -lt 1 -or $passed -lt 1 -or $failed -ne 0 -or $skipped -ne 0 -or $passed -ne $total) { - throw 'Tests must execute at least once, all pass, and none fail or skip.' - } -} -# Downloads and executes the latest stable csrun release with your permissions. -# Source and release history: https://github.com/codebeltnet/csrun -$engineDirectory = Join-Path ([IO.Path]::GetTempPath()) ('csrun-' + [guid]::NewGuid().ToString('N')) -$null = New-Item -ItemType Directory -Path $engineDirectory -$enginePath = Join-Path $engineDirectory 'csrun.ps1' -$process = $null -try { - $release = Invoke-RestMethod 'https://api.github.com/repos/codebeltnet/csrun/releases/latest' - $assets = @($release.assets | Where-Object name -CEQ 'csrun.ps1') - if ($assets.Count -ne 1 -or $assets[0].digest -notmatch '^sha256:[0-9a-f]{64}$') { - throw "csrun release $($release.tag_name) must publish one csrun.ps1 asset with a SHA-256 digest." - } - $asset = $assets[0] - Invoke-WebRequest $asset.browser_download_url -OutFile $enginePath - $actualHash = (Get-FileHash -LiteralPath $enginePath -Algorithm SHA256).Hash - if ("sha256:$actualHash" -ne $asset.digest) { throw "csrun asset checksum mismatch: $actualHash" } -$enginePayload = [Convert]::ToBase64String([IO.File]::ReadAllBytes($enginePath)) -$containerInput = $enginePayload + "`n" + $manifest -$command = ' -$ErrorActionPreference = "Stop" -$enginePath = Join-Path ([IO.Path]::GetTempPath()) ("csrun-release-" + [guid]::NewGuid().ToString("N") + ".ps1") -$engineBytes = [Convert]::FromBase64String([Console]::In.ReadLine()) -[IO.File]::WriteAllBytes($enginePath, $engineBytes) -$manifest = [Console]::In.ReadToEnd() -& $enginePath -ManifestJson $manifest -exit $LASTEXITCODE -' -$output = (@($containerInput | & docker run --rm -i --entrypoint pwsh 'codebeltnet/csrun:10' -NoProfile -NonInteractive -Command $command) -join [Environment]::NewLine) -$process = [pscustomobject]@{ ExitCode = $LASTEXITCODE } -$diagnostics = '' -Write-Output $output -} catch { - [Console]::Error.WriteLine("csrun diagnostics retained in: $engineDirectory") - throw -} finally { - $resolvedTemp = [IO.Path]::TrimEndingDirectorySeparator([IO.Path]::GetFullPath([IO.Path]::GetTempPath())) - $resolvedEngineDirectory = [IO.Path]::GetFullPath($engineDirectory) - if ([IO.Path]::GetDirectoryName($resolvedEngineDirectory) -ne $resolvedTemp -or - [IO.Path]::GetFileName($resolvedEngineDirectory) -cnotmatch '^csrun-[a-f0-9]{32}$') { throw 'Unsafe cleanup path.' } - if ($process -and $process.ExitCode -eq 0) { Remove-Item -LiteralPath $resolvedEngineDirectory -Recurse -Force } -} -if ($process.ExitCode -ne 0) { throw "csrun execution failed with exit code $($process.ExitCode). $diagnostics" } -if ($verifyTests) { Assert-CsrunTestOutput $output } -} \ No newline at end of file diff --git a/.docfx/run-actions/947406357e3e26b26a71a538/native.ps1 b/.docfx/run-actions/947406357e3e26b26a71a538/native.ps1 deleted file mode 100644 index 6774e6c..0000000 --- a/.docfx/run-actions/947406357e3e26b26a71a538/native.ps1 +++ /dev/null @@ -1,90 +0,0 @@ -& { -#requires -Version 7.0 -$ErrorActionPreference = 'Stop' -$PSNativeCommandUseErrorActionPreference = $false -$manifest = @' -{ - "dependsOn": [ - "Codebelt.Extensions.Xunit.Hosting.AspNetCore@13.0.0", - "Microsoft.Extensions.Hosting@10.0.15", - "Microsoft.AspNetCore.TestHost@10.0.15" - ], - "framework": "net10.0", - "frameworkReferences": [ - "Microsoft.AspNetCore.App" - ], - "mode": "console", - "schemaVersion": 1, - "sdk": "Microsoft.NET.Sdk.Web", - "source": "using System;\nusing System.Net.Http;\nusing System.Threading.Tasks;\nusing Codebelt.Extensions.Xunit.Hosting.AspNetCore;\nusing Microsoft.AspNetCore.Builder;\nusing Microsoft.AspNetCore.TestHost;\n\nnamespace WebFixtureTests;\n\npublic class HttpClientExample\n{\n public async Task DemonstrateAsync(HttpClient client)\n {\n var response = await client.ToHttpResponseMessageAsync().ConfigureAwait(false);\n Console.WriteLine(response.StatusCode);\n }\n}\n\ninternal static class RunExample\n{\n static async Task Main()\n {\n using var app = WebHostTestFactory.Create(pipelineSetup: app => app.Run(context =>\n {\n context.Response.StatusCode = 202;\n return Task.CompletedTask;\n }));\n using var client = app.Host.GetTestClient();\n await new HttpClientExample().DemonstrateAsync(client);\n }\n}" -} -'@ -$OutputEncoding = [Text.UTF8Encoding]::new($false) -[Console]::OutputEncoding = $OutputEncoding -$verifyTests = $false -function Assert-CsrunTestOutput([string] $Output) { - $lines = @($Output -split '\r?\n') - $headers = @($lines | Where-Object { $_ -match '^Test run summary: Passed! - .+\)$' }) - if ($headers.Count -ne 1) { throw 'Expected exactly one completed xUnit test summary.' } - $headerIndex = [Array]::IndexOf($lines, $headers[0]) - $summaryLines = @($lines | Select-Object -Skip ($headerIndex + 1) -First 4) - $counts = @{} - foreach ($line in $summaryLines) { - if ($line -match '^\s*(total|failed|succeeded|skipped):\s*(\d+)\s*$') { $counts[$Matches[1]] = [int]$Matches[2] } - } - if ($counts.Count -ne 4) { throw 'The xUnit test summary counts are incomplete or ambiguous.' } - $failed = $counts.failed - $passed = $counts.succeeded - $skipped = $counts.skipped - $total = $counts.total - if ($total -lt 1 -or $passed -lt 1 -or $failed -ne 0 -or $skipped -ne 0 -or $passed -ne $total) { - throw 'Tests must execute at least once, all pass, and none fail or skip.' - } -} -# Downloads and executes the latest stable csrun release with your permissions. -# Source and release history: https://github.com/codebeltnet/csrun -$engineDirectory = Join-Path ([IO.Path]::GetTempPath()) ('csrun-' + [guid]::NewGuid().ToString('N')) -$null = New-Item -ItemType Directory -Path $engineDirectory -$enginePath = Join-Path $engineDirectory 'csrun.ps1' -$process = $null -try { - $release = Invoke-RestMethod 'https://api.github.com/repos/codebeltnet/csrun/releases/latest' - $assets = @($release.assets | Where-Object name -CEQ 'csrun.ps1') - if ($assets.Count -ne 1 -or $assets[0].digest -notmatch '^sha256:[0-9a-f]{64}$') { - throw "csrun release $($release.tag_name) must publish one csrun.ps1 asset with a SHA-256 digest." - } - $asset = $assets[0] - Invoke-WebRequest $asset.browser_download_url -OutFile $enginePath - $actualHash = (Get-FileHash -LiteralPath $enginePath -Algorithm SHA256).Hash - if ("sha256:$actualHash" -ne $asset.digest) { throw "csrun asset checksum mismatch: $actualHash" } -$startInfo = [Diagnostics.ProcessStartInfo]::new('pwsh') -foreach ($argument in @('-NoProfile','-NonInteractive','-File')) { $startInfo.ArgumentList.Add($argument) } -$startInfo.ArgumentList.Add($enginePath) -$startInfo.ArgumentList.Add('-ManifestJson') -$startInfo.ArgumentList.Add($manifest) -$startInfo.RedirectStandardOutput = $true -$startInfo.RedirectStandardError = $true -$startInfo.UseShellExecute = $false -$process = [Diagnostics.Process]::new() -$process.StartInfo = $startInfo -if (-not $process.Start()) { throw 'Could not start csrun.' } -$stdoutTask = $process.StandardOutput.ReadToEndAsync() -$stderrTask = $process.StandardError.ReadToEndAsync() -$process.WaitForExit() -$output = $stdoutTask.GetAwaiter().GetResult() -$diagnostics = $stderrTask.GetAwaiter().GetResult() -Write-Output $output -if ($diagnostics) { [Console]::Error.Write($diagnostics) } -} catch { - [Console]::Error.WriteLine("csrun diagnostics retained in: $engineDirectory") - throw -} finally { - $resolvedTemp = [IO.Path]::TrimEndingDirectorySeparator([IO.Path]::GetFullPath([IO.Path]::GetTempPath())) - $resolvedEngineDirectory = [IO.Path]::GetFullPath($engineDirectory) - if ([IO.Path]::GetDirectoryName($resolvedEngineDirectory) -ne $resolvedTemp -or - [IO.Path]::GetFileName($resolvedEngineDirectory) -cnotmatch '^csrun-[a-f0-9]{32}$') { throw 'Unsafe cleanup path.' } - if ($process -and $process.ExitCode -eq 0) { Remove-Item -LiteralPath $resolvedEngineDirectory -Recurse -Force } -} -if ($process.ExitCode -ne 0) { throw "csrun execution failed with exit code $($process.ExitCode). $diagnostics" } -if ($verifyTests) { Assert-CsrunTestOutput $output } -} \ No newline at end of file diff --git a/.docfx/run-actions/9a558a9a581c6b11ccb28057/docker.ps1 b/.docfx/run-actions/9a558a9a581c6b11ccb28057/docker.ps1 deleted file mode 100644 index 13e5465..0000000 --- a/.docfx/run-actions/9a558a9a581c6b11ccb28057/docker.ps1 +++ /dev/null @@ -1,83 +0,0 @@ -& { -#requires -Version 7.0 -$ErrorActionPreference = 'Stop' -$PSNativeCommandUseErrorActionPreference = $false -$manifest = @' -{ - "dependsOn": [ - "Codebelt.Extensions.Xunit.Hosting@13.0.0", - "Microsoft.Extensions.Hosting@10.0.15", - "xunit.v3@4.0.3" - ], - "framework": "net10.0", - "mode": "test", - "schemaVersion": 1, - "source": "using Codebelt.Extensions.Xunit.Hosting;\nusing Microsoft.Extensions.Logging;\nusing Xunit;\n\nnamespace HostFixtureTests;\n\npublic class LogEntryExample\n{\n public string FormatEntry()\n {\n var entry = new XunitTestLoggerEntry(LogLevel.Warning, new EventId(1001, \"MyEvent\"), \"Something unexpected happened.\");\n return entry.ToString();\n }\n}\n\npublic sealed class RunExample\n{\n [Fact]\n public void ExercisesExample()\n {\n Assert.Equal(\"Something unexpected happened.\", new LogEntryExample().FormatEntry());\n }\n}" -} -'@ -$OutputEncoding = [Text.UTF8Encoding]::new($false) -[Console]::OutputEncoding = $OutputEncoding -$verifyTests = $true -function Assert-CsrunTestOutput([string] $Output) { - $lines = @($Output -split '\r?\n') - $headers = @($lines | Where-Object { $_ -match '^Test run summary: Passed! - .+\)$' }) - if ($headers.Count -ne 1) { throw 'Expected exactly one completed xUnit test summary.' } - $headerIndex = [Array]::IndexOf($lines, $headers[0]) - $summaryLines = @($lines | Select-Object -Skip ($headerIndex + 1) -First 4) - $counts = @{} - foreach ($line in $summaryLines) { - if ($line -match '^\s*(total|failed|succeeded|skipped):\s*(\d+)\s*$') { $counts[$Matches[1]] = [int]$Matches[2] } - } - if ($counts.Count -ne 4) { throw 'The xUnit test summary counts are incomplete or ambiguous.' } - $failed = $counts.failed - $passed = $counts.succeeded - $skipped = $counts.skipped - $total = $counts.total - if ($total -lt 1 -or $passed -lt 1 -or $failed -ne 0 -or $skipped -ne 0 -or $passed -ne $total) { - throw 'Tests must execute at least once, all pass, and none fail or skip.' - } -} -# Downloads and executes the latest stable csrun release with your permissions. -# Source and release history: https://github.com/codebeltnet/csrun -$engineDirectory = Join-Path ([IO.Path]::GetTempPath()) ('csrun-' + [guid]::NewGuid().ToString('N')) -$null = New-Item -ItemType Directory -Path $engineDirectory -$enginePath = Join-Path $engineDirectory 'csrun.ps1' -$process = $null -try { - $release = Invoke-RestMethod 'https://api.github.com/repos/codebeltnet/csrun/releases/latest' - $assets = @($release.assets | Where-Object name -CEQ 'csrun.ps1') - if ($assets.Count -ne 1 -or $assets[0].digest -notmatch '^sha256:[0-9a-f]{64}$') { - throw "csrun release $($release.tag_name) must publish one csrun.ps1 asset with a SHA-256 digest." - } - $asset = $assets[0] - Invoke-WebRequest $asset.browser_download_url -OutFile $enginePath - $actualHash = (Get-FileHash -LiteralPath $enginePath -Algorithm SHA256).Hash - if ("sha256:$actualHash" -ne $asset.digest) { throw "csrun asset checksum mismatch: $actualHash" } -$enginePayload = [Convert]::ToBase64String([IO.File]::ReadAllBytes($enginePath)) -$containerInput = $enginePayload + "`n" + $manifest -$command = ' -$ErrorActionPreference = "Stop" -$enginePath = Join-Path ([IO.Path]::GetTempPath()) ("csrun-release-" + [guid]::NewGuid().ToString("N") + ".ps1") -$engineBytes = [Convert]::FromBase64String([Console]::In.ReadLine()) -[IO.File]::WriteAllBytes($enginePath, $engineBytes) -$manifest = [Console]::In.ReadToEnd() -& $enginePath -ManifestJson $manifest -exit $LASTEXITCODE -' -$output = (@($containerInput | & docker run --rm -i --entrypoint pwsh 'codebeltnet/csrun:10' -NoProfile -NonInteractive -Command $command) -join [Environment]::NewLine) -$process = [pscustomobject]@{ ExitCode = $LASTEXITCODE } -$diagnostics = '' -Write-Output $output -} catch { - [Console]::Error.WriteLine("csrun diagnostics retained in: $engineDirectory") - throw -} finally { - $resolvedTemp = [IO.Path]::TrimEndingDirectorySeparator([IO.Path]::GetFullPath([IO.Path]::GetTempPath())) - $resolvedEngineDirectory = [IO.Path]::GetFullPath($engineDirectory) - if ([IO.Path]::GetDirectoryName($resolvedEngineDirectory) -ne $resolvedTemp -or - [IO.Path]::GetFileName($resolvedEngineDirectory) -cnotmatch '^csrun-[a-f0-9]{32}$') { throw 'Unsafe cleanup path.' } - if ($process -and $process.ExitCode -eq 0) { Remove-Item -LiteralPath $resolvedEngineDirectory -Recurse -Force } -} -if ($process.ExitCode -ne 0) { throw "csrun execution failed with exit code $($process.ExitCode). $diagnostics" } -if ($verifyTests) { Assert-CsrunTestOutput $output } -} \ No newline at end of file diff --git a/.docfx/run-actions/9a558a9a581c6b11ccb28057/native.ps1 b/.docfx/run-actions/9a558a9a581c6b11ccb28057/native.ps1 deleted file mode 100644 index 0e2d591..0000000 --- a/.docfx/run-actions/9a558a9a581c6b11ccb28057/native.ps1 +++ /dev/null @@ -1,86 +0,0 @@ -& { -#requires -Version 7.0 -$ErrorActionPreference = 'Stop' -$PSNativeCommandUseErrorActionPreference = $false -$manifest = @' -{ - "dependsOn": [ - "Codebelt.Extensions.Xunit.Hosting@13.0.0", - "Microsoft.Extensions.Hosting@10.0.15", - "xunit.v3@4.0.3" - ], - "framework": "net10.0", - "mode": "test", - "schemaVersion": 1, - "source": "using Codebelt.Extensions.Xunit.Hosting;\nusing Microsoft.Extensions.Logging;\nusing Xunit;\n\nnamespace HostFixtureTests;\n\npublic class LogEntryExample\n{\n public string FormatEntry()\n {\n var entry = new XunitTestLoggerEntry(LogLevel.Warning, new EventId(1001, \"MyEvent\"), \"Something unexpected happened.\");\n return entry.ToString();\n }\n}\n\npublic sealed class RunExample\n{\n [Fact]\n public void ExercisesExample()\n {\n Assert.Equal(\"Something unexpected happened.\", new LogEntryExample().FormatEntry());\n }\n}" -} -'@ -$OutputEncoding = [Text.UTF8Encoding]::new($false) -[Console]::OutputEncoding = $OutputEncoding -$verifyTests = $true -function Assert-CsrunTestOutput([string] $Output) { - $lines = @($Output -split '\r?\n') - $headers = @($lines | Where-Object { $_ -match '^Test run summary: Passed! - .+\)$' }) - if ($headers.Count -ne 1) { throw 'Expected exactly one completed xUnit test summary.' } - $headerIndex = [Array]::IndexOf($lines, $headers[0]) - $summaryLines = @($lines | Select-Object -Skip ($headerIndex + 1) -First 4) - $counts = @{} - foreach ($line in $summaryLines) { - if ($line -match '^\s*(total|failed|succeeded|skipped):\s*(\d+)\s*$') { $counts[$Matches[1]] = [int]$Matches[2] } - } - if ($counts.Count -ne 4) { throw 'The xUnit test summary counts are incomplete or ambiguous.' } - $failed = $counts.failed - $passed = $counts.succeeded - $skipped = $counts.skipped - $total = $counts.total - if ($total -lt 1 -or $passed -lt 1 -or $failed -ne 0 -or $skipped -ne 0 -or $passed -ne $total) { - throw 'Tests must execute at least once, all pass, and none fail or skip.' - } -} -# Downloads and executes the latest stable csrun release with your permissions. -# Source and release history: https://github.com/codebeltnet/csrun -$engineDirectory = Join-Path ([IO.Path]::GetTempPath()) ('csrun-' + [guid]::NewGuid().ToString('N')) -$null = New-Item -ItemType Directory -Path $engineDirectory -$enginePath = Join-Path $engineDirectory 'csrun.ps1' -$process = $null -try { - $release = Invoke-RestMethod 'https://api.github.com/repos/codebeltnet/csrun/releases/latest' - $assets = @($release.assets | Where-Object name -CEQ 'csrun.ps1') - if ($assets.Count -ne 1 -or $assets[0].digest -notmatch '^sha256:[0-9a-f]{64}$') { - throw "csrun release $($release.tag_name) must publish one csrun.ps1 asset with a SHA-256 digest." - } - $asset = $assets[0] - Invoke-WebRequest $asset.browser_download_url -OutFile $enginePath - $actualHash = (Get-FileHash -LiteralPath $enginePath -Algorithm SHA256).Hash - if ("sha256:$actualHash" -ne $asset.digest) { throw "csrun asset checksum mismatch: $actualHash" } -$startInfo = [Diagnostics.ProcessStartInfo]::new('pwsh') -foreach ($argument in @('-NoProfile','-NonInteractive','-File')) { $startInfo.ArgumentList.Add($argument) } -$startInfo.ArgumentList.Add($enginePath) -$startInfo.ArgumentList.Add('-ManifestJson') -$startInfo.ArgumentList.Add($manifest) -$startInfo.RedirectStandardOutput = $true -$startInfo.RedirectStandardError = $true -$startInfo.UseShellExecute = $false -$process = [Diagnostics.Process]::new() -$process.StartInfo = $startInfo -if (-not $process.Start()) { throw 'Could not start csrun.' } -$stdoutTask = $process.StandardOutput.ReadToEndAsync() -$stderrTask = $process.StandardError.ReadToEndAsync() -$process.WaitForExit() -$output = $stdoutTask.GetAwaiter().GetResult() -$diagnostics = $stderrTask.GetAwaiter().GetResult() -Write-Output $output -if ($diagnostics) { [Console]::Error.Write($diagnostics) } -} catch { - [Console]::Error.WriteLine("csrun diagnostics retained in: $engineDirectory") - throw -} finally { - $resolvedTemp = [IO.Path]::TrimEndingDirectorySeparator([IO.Path]::GetFullPath([IO.Path]::GetTempPath())) - $resolvedEngineDirectory = [IO.Path]::GetFullPath($engineDirectory) - if ([IO.Path]::GetDirectoryName($resolvedEngineDirectory) -ne $resolvedTemp -or - [IO.Path]::GetFileName($resolvedEngineDirectory) -cnotmatch '^csrun-[a-f0-9]{32}$') { throw 'Unsafe cleanup path.' } - if ($process -and $process.ExitCode -eq 0) { Remove-Item -LiteralPath $resolvedEngineDirectory -Recurse -Force } -} -if ($process.ExitCode -ne 0) { throw "csrun execution failed with exit code $($process.ExitCode). $diagnostics" } -if ($verifyTests) { Assert-CsrunTestOutput $output } -} \ No newline at end of file diff --git a/.docfx/run-actions/9cdeb08f8ba8f3b361a98c58/docker.ps1 b/.docfx/run-actions/9cdeb08f8ba8f3b361a98c58/docker.ps1 deleted file mode 100644 index 453d21f..0000000 --- a/.docfx/run-actions/9cdeb08f8ba8f3b361a98c58/docker.ps1 +++ /dev/null @@ -1,83 +0,0 @@ -& { -#requires -Version 7.0 -$ErrorActionPreference = 'Stop' -$PSNativeCommandUseErrorActionPreference = $false -$manifest = @' -{ - "dependsOn": [ - "Codebelt.Extensions.Xunit.Hosting@13.0.0", - "Microsoft.Extensions.Hosting@10.0.15", - "xunit.v3@4.0.3" - ], - "framework": "net10.0", - "mode": "test", - "schemaVersion": 1, - "source": "using Codebelt.Extensions.Xunit.Hosting;\nusing Microsoft.Extensions.DependencyInjection;\nusing Xunit;\n\nnamespace WorkerServices.Tests;\n\npublic sealed class HostTestFactoryExample\n{\n public string ResolveWorkerStatus()\n {\n using var host = HostTestFactory.Create(\n services => services.AddSingleton(new WorkerStatus(\"ready\")));\n\n var status = host.Host.Services.GetRequiredService();\n return status.Value;\n }\n}\n\npublic sealed record WorkerStatus(string Value);\n\npublic sealed class RunExample\n{\n [Fact]\n public void ExercisesExample()\n {\n Assert.Equal(\"ready\", new HostTestFactoryExample().ResolveWorkerStatus());\n }\n}" -} -'@ -$OutputEncoding = [Text.UTF8Encoding]::new($false) -[Console]::OutputEncoding = $OutputEncoding -$verifyTests = $true -function Assert-CsrunTestOutput([string] $Output) { - $lines = @($Output -split '\r?\n') - $headers = @($lines | Where-Object { $_ -match '^Test run summary: Passed! - .+\)$' }) - if ($headers.Count -ne 1) { throw 'Expected exactly one completed xUnit test summary.' } - $headerIndex = [Array]::IndexOf($lines, $headers[0]) - $summaryLines = @($lines | Select-Object -Skip ($headerIndex + 1) -First 4) - $counts = @{} - foreach ($line in $summaryLines) { - if ($line -match '^\s*(total|failed|succeeded|skipped):\s*(\d+)\s*$') { $counts[$Matches[1]] = [int]$Matches[2] } - } - if ($counts.Count -ne 4) { throw 'The xUnit test summary counts are incomplete or ambiguous.' } - $failed = $counts.failed - $passed = $counts.succeeded - $skipped = $counts.skipped - $total = $counts.total - if ($total -lt 1 -or $passed -lt 1 -or $failed -ne 0 -or $skipped -ne 0 -or $passed -ne $total) { - throw 'Tests must execute at least once, all pass, and none fail or skip.' - } -} -# Downloads and executes the latest stable csrun release with your permissions. -# Source and release history: https://github.com/codebeltnet/csrun -$engineDirectory = Join-Path ([IO.Path]::GetTempPath()) ('csrun-' + [guid]::NewGuid().ToString('N')) -$null = New-Item -ItemType Directory -Path $engineDirectory -$enginePath = Join-Path $engineDirectory 'csrun.ps1' -$process = $null -try { - $release = Invoke-RestMethod 'https://api.github.com/repos/codebeltnet/csrun/releases/latest' - $assets = @($release.assets | Where-Object name -CEQ 'csrun.ps1') - if ($assets.Count -ne 1 -or $assets[0].digest -notmatch '^sha256:[0-9a-f]{64}$') { - throw "csrun release $($release.tag_name) must publish one csrun.ps1 asset with a SHA-256 digest." - } - $asset = $assets[0] - Invoke-WebRequest $asset.browser_download_url -OutFile $enginePath - $actualHash = (Get-FileHash -LiteralPath $enginePath -Algorithm SHA256).Hash - if ("sha256:$actualHash" -ne $asset.digest) { throw "csrun asset checksum mismatch: $actualHash" } -$enginePayload = [Convert]::ToBase64String([IO.File]::ReadAllBytes($enginePath)) -$containerInput = $enginePayload + "`n" + $manifest -$command = ' -$ErrorActionPreference = "Stop" -$enginePath = Join-Path ([IO.Path]::GetTempPath()) ("csrun-release-" + [guid]::NewGuid().ToString("N") + ".ps1") -$engineBytes = [Convert]::FromBase64String([Console]::In.ReadLine()) -[IO.File]::WriteAllBytes($enginePath, $engineBytes) -$manifest = [Console]::In.ReadToEnd() -& $enginePath -ManifestJson $manifest -exit $LASTEXITCODE -' -$output = (@($containerInput | & docker run --rm -i --entrypoint pwsh 'codebeltnet/csrun:10' -NoProfile -NonInteractive -Command $command) -join [Environment]::NewLine) -$process = [pscustomobject]@{ ExitCode = $LASTEXITCODE } -$diagnostics = '' -Write-Output $output -} catch { - [Console]::Error.WriteLine("csrun diagnostics retained in: $engineDirectory") - throw -} finally { - $resolvedTemp = [IO.Path]::TrimEndingDirectorySeparator([IO.Path]::GetFullPath([IO.Path]::GetTempPath())) - $resolvedEngineDirectory = [IO.Path]::GetFullPath($engineDirectory) - if ([IO.Path]::GetDirectoryName($resolvedEngineDirectory) -ne $resolvedTemp -or - [IO.Path]::GetFileName($resolvedEngineDirectory) -cnotmatch '^csrun-[a-f0-9]{32}$') { throw 'Unsafe cleanup path.' } - if ($process -and $process.ExitCode -eq 0) { Remove-Item -LiteralPath $resolvedEngineDirectory -Recurse -Force } -} -if ($process.ExitCode -ne 0) { throw "csrun execution failed with exit code $($process.ExitCode). $diagnostics" } -if ($verifyTests) { Assert-CsrunTestOutput $output } -} \ No newline at end of file diff --git a/.docfx/run-actions/9cdeb08f8ba8f3b361a98c58/native.ps1 b/.docfx/run-actions/9cdeb08f8ba8f3b361a98c58/native.ps1 deleted file mode 100644 index eeb9345..0000000 --- a/.docfx/run-actions/9cdeb08f8ba8f3b361a98c58/native.ps1 +++ /dev/null @@ -1,86 +0,0 @@ -& { -#requires -Version 7.0 -$ErrorActionPreference = 'Stop' -$PSNativeCommandUseErrorActionPreference = $false -$manifest = @' -{ - "dependsOn": [ - "Codebelt.Extensions.Xunit.Hosting@13.0.0", - "Microsoft.Extensions.Hosting@10.0.15", - "xunit.v3@4.0.3" - ], - "framework": "net10.0", - "mode": "test", - "schemaVersion": 1, - "source": "using Codebelt.Extensions.Xunit.Hosting;\nusing Microsoft.Extensions.DependencyInjection;\nusing Xunit;\n\nnamespace WorkerServices.Tests;\n\npublic sealed class HostTestFactoryExample\n{\n public string ResolveWorkerStatus()\n {\n using var host = HostTestFactory.Create(\n services => services.AddSingleton(new WorkerStatus(\"ready\")));\n\n var status = host.Host.Services.GetRequiredService();\n return status.Value;\n }\n}\n\npublic sealed record WorkerStatus(string Value);\n\npublic sealed class RunExample\n{\n [Fact]\n public void ExercisesExample()\n {\n Assert.Equal(\"ready\", new HostTestFactoryExample().ResolveWorkerStatus());\n }\n}" -} -'@ -$OutputEncoding = [Text.UTF8Encoding]::new($false) -[Console]::OutputEncoding = $OutputEncoding -$verifyTests = $true -function Assert-CsrunTestOutput([string] $Output) { - $lines = @($Output -split '\r?\n') - $headers = @($lines | Where-Object { $_ -match '^Test run summary: Passed! - .+\)$' }) - if ($headers.Count -ne 1) { throw 'Expected exactly one completed xUnit test summary.' } - $headerIndex = [Array]::IndexOf($lines, $headers[0]) - $summaryLines = @($lines | Select-Object -Skip ($headerIndex + 1) -First 4) - $counts = @{} - foreach ($line in $summaryLines) { - if ($line -match '^\s*(total|failed|succeeded|skipped):\s*(\d+)\s*$') { $counts[$Matches[1]] = [int]$Matches[2] } - } - if ($counts.Count -ne 4) { throw 'The xUnit test summary counts are incomplete or ambiguous.' } - $failed = $counts.failed - $passed = $counts.succeeded - $skipped = $counts.skipped - $total = $counts.total - if ($total -lt 1 -or $passed -lt 1 -or $failed -ne 0 -or $skipped -ne 0 -or $passed -ne $total) { - throw 'Tests must execute at least once, all pass, and none fail or skip.' - } -} -# Downloads and executes the latest stable csrun release with your permissions. -# Source and release history: https://github.com/codebeltnet/csrun -$engineDirectory = Join-Path ([IO.Path]::GetTempPath()) ('csrun-' + [guid]::NewGuid().ToString('N')) -$null = New-Item -ItemType Directory -Path $engineDirectory -$enginePath = Join-Path $engineDirectory 'csrun.ps1' -$process = $null -try { - $release = Invoke-RestMethod 'https://api.github.com/repos/codebeltnet/csrun/releases/latest' - $assets = @($release.assets | Where-Object name -CEQ 'csrun.ps1') - if ($assets.Count -ne 1 -or $assets[0].digest -notmatch '^sha256:[0-9a-f]{64}$') { - throw "csrun release $($release.tag_name) must publish one csrun.ps1 asset with a SHA-256 digest." - } - $asset = $assets[0] - Invoke-WebRequest $asset.browser_download_url -OutFile $enginePath - $actualHash = (Get-FileHash -LiteralPath $enginePath -Algorithm SHA256).Hash - if ("sha256:$actualHash" -ne $asset.digest) { throw "csrun asset checksum mismatch: $actualHash" } -$startInfo = [Diagnostics.ProcessStartInfo]::new('pwsh') -foreach ($argument in @('-NoProfile','-NonInteractive','-File')) { $startInfo.ArgumentList.Add($argument) } -$startInfo.ArgumentList.Add($enginePath) -$startInfo.ArgumentList.Add('-ManifestJson') -$startInfo.ArgumentList.Add($manifest) -$startInfo.RedirectStandardOutput = $true -$startInfo.RedirectStandardError = $true -$startInfo.UseShellExecute = $false -$process = [Diagnostics.Process]::new() -$process.StartInfo = $startInfo -if (-not $process.Start()) { throw 'Could not start csrun.' } -$stdoutTask = $process.StandardOutput.ReadToEndAsync() -$stderrTask = $process.StandardError.ReadToEndAsync() -$process.WaitForExit() -$output = $stdoutTask.GetAwaiter().GetResult() -$diagnostics = $stderrTask.GetAwaiter().GetResult() -Write-Output $output -if ($diagnostics) { [Console]::Error.Write($diagnostics) } -} catch { - [Console]::Error.WriteLine("csrun diagnostics retained in: $engineDirectory") - throw -} finally { - $resolvedTemp = [IO.Path]::TrimEndingDirectorySeparator([IO.Path]::GetFullPath([IO.Path]::GetTempPath())) - $resolvedEngineDirectory = [IO.Path]::GetFullPath($engineDirectory) - if ([IO.Path]::GetDirectoryName($resolvedEngineDirectory) -ne $resolvedTemp -or - [IO.Path]::GetFileName($resolvedEngineDirectory) -cnotmatch '^csrun-[a-f0-9]{32}$') { throw 'Unsafe cleanup path.' } - if ($process -and $process.ExitCode -eq 0) { Remove-Item -LiteralPath $resolvedEngineDirectory -Recurse -Force } -} -if ($process.ExitCode -ne 0) { throw "csrun execution failed with exit code $($process.ExitCode). $diagnostics" } -if ($verifyTests) { Assert-CsrunTestOutput $output } -} \ No newline at end of file diff --git a/.docfx/run-actions/a31971b360a8c557b87f6684/docker.ps1 b/.docfx/run-actions/a31971b360a8c557b87f6684/docker.ps1 deleted file mode 100644 index c8e485a..0000000 --- a/.docfx/run-actions/a31971b360a8c557b87f6684/docker.ps1 +++ /dev/null @@ -1,82 +0,0 @@ -& { -#requires -Version 7.0 -$ErrorActionPreference = 'Stop' -$PSNativeCommandUseErrorActionPreference = $false -$manifest = @' -{ - "dependsOn": [ - "Codebelt.Extensions.Xunit@13.0.0", - "xunit.v3@4.0.3" - ], - "framework": "net10.0", - "mode": "test", - "schemaVersion": 1, - "source": "using System.Linq;\nusing Codebelt.Extensions.Xunit;\nusing Xunit;\n\nnamespace Example.Tests;\n\npublic class StoreExample\n{\n public bool HasMatchingItem()\n {\n var store = new InMemoryTestStore();\n store.Add(\"cached\");\n store.Add(\"other\");\n return store.Count == 2 && store.Query(value => value == \"cached\").Single() == \"cached\";\n }\n}\n\npublic sealed class RunExample\n{\n [Fact]\n public void ExercisesExample()\n {\n Assert.True(new StoreExample().HasMatchingItem());\n }\n}" -} -'@ -$OutputEncoding = [Text.UTF8Encoding]::new($false) -[Console]::OutputEncoding = $OutputEncoding -$verifyTests = $true -function Assert-CsrunTestOutput([string] $Output) { - $lines = @($Output -split '\r?\n') - $headers = @($lines | Where-Object { $_ -match '^Test run summary: Passed! - .+\)$' }) - if ($headers.Count -ne 1) { throw 'Expected exactly one completed xUnit test summary.' } - $headerIndex = [Array]::IndexOf($lines, $headers[0]) - $summaryLines = @($lines | Select-Object -Skip ($headerIndex + 1) -First 4) - $counts = @{} - foreach ($line in $summaryLines) { - if ($line -match '^\s*(total|failed|succeeded|skipped):\s*(\d+)\s*$') { $counts[$Matches[1]] = [int]$Matches[2] } - } - if ($counts.Count -ne 4) { throw 'The xUnit test summary counts are incomplete or ambiguous.' } - $failed = $counts.failed - $passed = $counts.succeeded - $skipped = $counts.skipped - $total = $counts.total - if ($total -lt 1 -or $passed -lt 1 -or $failed -ne 0 -or $skipped -ne 0 -or $passed -ne $total) { - throw 'Tests must execute at least once, all pass, and none fail or skip.' - } -} -# Downloads and executes the latest stable csrun release with your permissions. -# Source and release history: https://github.com/codebeltnet/csrun -$engineDirectory = Join-Path ([IO.Path]::GetTempPath()) ('csrun-' + [guid]::NewGuid().ToString('N')) -$null = New-Item -ItemType Directory -Path $engineDirectory -$enginePath = Join-Path $engineDirectory 'csrun.ps1' -$process = $null -try { - $release = Invoke-RestMethod 'https://api.github.com/repos/codebeltnet/csrun/releases/latest' - $assets = @($release.assets | Where-Object name -CEQ 'csrun.ps1') - if ($assets.Count -ne 1 -or $assets[0].digest -notmatch '^sha256:[0-9a-f]{64}$') { - throw "csrun release $($release.tag_name) must publish one csrun.ps1 asset with a SHA-256 digest." - } - $asset = $assets[0] - Invoke-WebRequest $asset.browser_download_url -OutFile $enginePath - $actualHash = (Get-FileHash -LiteralPath $enginePath -Algorithm SHA256).Hash - if ("sha256:$actualHash" -ne $asset.digest) { throw "csrun asset checksum mismatch: $actualHash" } -$enginePayload = [Convert]::ToBase64String([IO.File]::ReadAllBytes($enginePath)) -$containerInput = $enginePayload + "`n" + $manifest -$command = ' -$ErrorActionPreference = "Stop" -$enginePath = Join-Path ([IO.Path]::GetTempPath()) ("csrun-release-" + [guid]::NewGuid().ToString("N") + ".ps1") -$engineBytes = [Convert]::FromBase64String([Console]::In.ReadLine()) -[IO.File]::WriteAllBytes($enginePath, $engineBytes) -$manifest = [Console]::In.ReadToEnd() -& $enginePath -ManifestJson $manifest -exit $LASTEXITCODE -' -$output = (@($containerInput | & docker run --rm -i --entrypoint pwsh 'codebeltnet/csrun:10' -NoProfile -NonInteractive -Command $command) -join [Environment]::NewLine) -$process = [pscustomobject]@{ ExitCode = $LASTEXITCODE } -$diagnostics = '' -Write-Output $output -} catch { - [Console]::Error.WriteLine("csrun diagnostics retained in: $engineDirectory") - throw -} finally { - $resolvedTemp = [IO.Path]::TrimEndingDirectorySeparator([IO.Path]::GetFullPath([IO.Path]::GetTempPath())) - $resolvedEngineDirectory = [IO.Path]::GetFullPath($engineDirectory) - if ([IO.Path]::GetDirectoryName($resolvedEngineDirectory) -ne $resolvedTemp -or - [IO.Path]::GetFileName($resolvedEngineDirectory) -cnotmatch '^csrun-[a-f0-9]{32}$') { throw 'Unsafe cleanup path.' } - if ($process -and $process.ExitCode -eq 0) { Remove-Item -LiteralPath $resolvedEngineDirectory -Recurse -Force } -} -if ($process.ExitCode -ne 0) { throw "csrun execution failed with exit code $($process.ExitCode). $diagnostics" } -if ($verifyTests) { Assert-CsrunTestOutput $output } -} \ No newline at end of file diff --git a/.docfx/run-actions/a31971b360a8c557b87f6684/native.ps1 b/.docfx/run-actions/a31971b360a8c557b87f6684/native.ps1 deleted file mode 100644 index 702bba8..0000000 --- a/.docfx/run-actions/a31971b360a8c557b87f6684/native.ps1 +++ /dev/null @@ -1,85 +0,0 @@ -& { -#requires -Version 7.0 -$ErrorActionPreference = 'Stop' -$PSNativeCommandUseErrorActionPreference = $false -$manifest = @' -{ - "dependsOn": [ - "Codebelt.Extensions.Xunit@13.0.0", - "xunit.v3@4.0.3" - ], - "framework": "net10.0", - "mode": "test", - "schemaVersion": 1, - "source": "using System.Linq;\nusing Codebelt.Extensions.Xunit;\nusing Xunit;\n\nnamespace Example.Tests;\n\npublic class StoreExample\n{\n public bool HasMatchingItem()\n {\n var store = new InMemoryTestStore();\n store.Add(\"cached\");\n store.Add(\"other\");\n return store.Count == 2 && store.Query(value => value == \"cached\").Single() == \"cached\";\n }\n}\n\npublic sealed class RunExample\n{\n [Fact]\n public void ExercisesExample()\n {\n Assert.True(new StoreExample().HasMatchingItem());\n }\n}" -} -'@ -$OutputEncoding = [Text.UTF8Encoding]::new($false) -[Console]::OutputEncoding = $OutputEncoding -$verifyTests = $true -function Assert-CsrunTestOutput([string] $Output) { - $lines = @($Output -split '\r?\n') - $headers = @($lines | Where-Object { $_ -match '^Test run summary: Passed! - .+\)$' }) - if ($headers.Count -ne 1) { throw 'Expected exactly one completed xUnit test summary.' } - $headerIndex = [Array]::IndexOf($lines, $headers[0]) - $summaryLines = @($lines | Select-Object -Skip ($headerIndex + 1) -First 4) - $counts = @{} - foreach ($line in $summaryLines) { - if ($line -match '^\s*(total|failed|succeeded|skipped):\s*(\d+)\s*$') { $counts[$Matches[1]] = [int]$Matches[2] } - } - if ($counts.Count -ne 4) { throw 'The xUnit test summary counts are incomplete or ambiguous.' } - $failed = $counts.failed - $passed = $counts.succeeded - $skipped = $counts.skipped - $total = $counts.total - if ($total -lt 1 -or $passed -lt 1 -or $failed -ne 0 -or $skipped -ne 0 -or $passed -ne $total) { - throw 'Tests must execute at least once, all pass, and none fail or skip.' - } -} -# Downloads and executes the latest stable csrun release with your permissions. -# Source and release history: https://github.com/codebeltnet/csrun -$engineDirectory = Join-Path ([IO.Path]::GetTempPath()) ('csrun-' + [guid]::NewGuid().ToString('N')) -$null = New-Item -ItemType Directory -Path $engineDirectory -$enginePath = Join-Path $engineDirectory 'csrun.ps1' -$process = $null -try { - $release = Invoke-RestMethod 'https://api.github.com/repos/codebeltnet/csrun/releases/latest' - $assets = @($release.assets | Where-Object name -CEQ 'csrun.ps1') - if ($assets.Count -ne 1 -or $assets[0].digest -notmatch '^sha256:[0-9a-f]{64}$') { - throw "csrun release $($release.tag_name) must publish one csrun.ps1 asset with a SHA-256 digest." - } - $asset = $assets[0] - Invoke-WebRequest $asset.browser_download_url -OutFile $enginePath - $actualHash = (Get-FileHash -LiteralPath $enginePath -Algorithm SHA256).Hash - if ("sha256:$actualHash" -ne $asset.digest) { throw "csrun asset checksum mismatch: $actualHash" } -$startInfo = [Diagnostics.ProcessStartInfo]::new('pwsh') -foreach ($argument in @('-NoProfile','-NonInteractive','-File')) { $startInfo.ArgumentList.Add($argument) } -$startInfo.ArgumentList.Add($enginePath) -$startInfo.ArgumentList.Add('-ManifestJson') -$startInfo.ArgumentList.Add($manifest) -$startInfo.RedirectStandardOutput = $true -$startInfo.RedirectStandardError = $true -$startInfo.UseShellExecute = $false -$process = [Diagnostics.Process]::new() -$process.StartInfo = $startInfo -if (-not $process.Start()) { throw 'Could not start csrun.' } -$stdoutTask = $process.StandardOutput.ReadToEndAsync() -$stderrTask = $process.StandardError.ReadToEndAsync() -$process.WaitForExit() -$output = $stdoutTask.GetAwaiter().GetResult() -$diagnostics = $stderrTask.GetAwaiter().GetResult() -Write-Output $output -if ($diagnostics) { [Console]::Error.Write($diagnostics) } -} catch { - [Console]::Error.WriteLine("csrun diagnostics retained in: $engineDirectory") - throw -} finally { - $resolvedTemp = [IO.Path]::TrimEndingDirectorySeparator([IO.Path]::GetFullPath([IO.Path]::GetTempPath())) - $resolvedEngineDirectory = [IO.Path]::GetFullPath($engineDirectory) - if ([IO.Path]::GetDirectoryName($resolvedEngineDirectory) -ne $resolvedTemp -or - [IO.Path]::GetFileName($resolvedEngineDirectory) -cnotmatch '^csrun-[a-f0-9]{32}$') { throw 'Unsafe cleanup path.' } - if ($process -and $process.ExitCode -eq 0) { Remove-Item -LiteralPath $resolvedEngineDirectory -Recurse -Force } -} -if ($process.ExitCode -ne 0) { throw "csrun execution failed with exit code $($process.ExitCode). $diagnostics" } -if ($verifyTests) { Assert-CsrunTestOutput $output } -} \ No newline at end of file diff --git a/.docfx/run-actions/aa478d74f298d8c98e6cd1bf/docker.ps1 b/.docfx/run-actions/aa478d74f298d8c98e6cd1bf/docker.ps1 deleted file mode 100644 index e23a36b..0000000 --- a/.docfx/run-actions/aa478d74f298d8c98e6cd1bf/docker.ps1 +++ /dev/null @@ -1,83 +0,0 @@ -& { -#requires -Version 7.0 -$ErrorActionPreference = 'Stop' -$PSNativeCommandUseErrorActionPreference = $false -$manifest = @' -{ - "dependsOn": [ - "Codebelt.Extensions.Xunit.Hosting@13.0.0", - "Microsoft.Extensions.Hosting@10.0.15", - "xunit.v3@4.0.3" - ], - "framework": "net10.0", - "mode": "test", - "schemaVersion": 1, - "source": "using System.Threading;\nusing System.Threading.Tasks;\nusing Codebelt.Extensions.Xunit.Hosting;\nusing Microsoft.Extensions.DependencyInjection;\nusing Microsoft.Extensions.Hosting;\nusing Xunit;\n\nnamespace HostFixtureTests;\n\npublic class BackgroundServiceTest : HostTest\n{\n public BackgroundServiceTest(ManagedHostFixture hostFixture, ITestOutputHelper output) : base(hostFixture, output)\n {\n }\n\n public override void ConfigureServices(IServiceCollection services)\n {\n services.AddHostedService();\n services.AddXunitTestLogging();\n }\n\n [Fact]\n public void Host_ShouldBeRunning()\n {\n Assert.NotNull(Host);\n }\n}\n\npublic class TestWorker : BackgroundService\n{\n protected override async Task ExecuteAsync(CancellationToken stoppingToken)\n {\n while (!stoppingToken.IsCancellationRequested)\n {\n await Task.Delay(100, stoppingToken);\n }\n }\n}" -} -'@ -$OutputEncoding = [Text.UTF8Encoding]::new($false) -[Console]::OutputEncoding = $OutputEncoding -$verifyTests = $true -function Assert-CsrunTestOutput([string] $Output) { - $lines = @($Output -split '\r?\n') - $headers = @($lines | Where-Object { $_ -match '^Test run summary: Passed! - .+\)$' }) - if ($headers.Count -ne 1) { throw 'Expected exactly one completed xUnit test summary.' } - $headerIndex = [Array]::IndexOf($lines, $headers[0]) - $summaryLines = @($lines | Select-Object -Skip ($headerIndex + 1) -First 4) - $counts = @{} - foreach ($line in $summaryLines) { - if ($line -match '^\s*(total|failed|succeeded|skipped):\s*(\d+)\s*$') { $counts[$Matches[1]] = [int]$Matches[2] } - } - if ($counts.Count -ne 4) { throw 'The xUnit test summary counts are incomplete or ambiguous.' } - $failed = $counts.failed - $passed = $counts.succeeded - $skipped = $counts.skipped - $total = $counts.total - if ($total -lt 1 -or $passed -lt 1 -or $failed -ne 0 -or $skipped -ne 0 -or $passed -ne $total) { - throw 'Tests must execute at least once, all pass, and none fail or skip.' - } -} -# Downloads and executes the latest stable csrun release with your permissions. -# Source and release history: https://github.com/codebeltnet/csrun -$engineDirectory = Join-Path ([IO.Path]::GetTempPath()) ('csrun-' + [guid]::NewGuid().ToString('N')) -$null = New-Item -ItemType Directory -Path $engineDirectory -$enginePath = Join-Path $engineDirectory 'csrun.ps1' -$process = $null -try { - $release = Invoke-RestMethod 'https://api.github.com/repos/codebeltnet/csrun/releases/latest' - $assets = @($release.assets | Where-Object name -CEQ 'csrun.ps1') - if ($assets.Count -ne 1 -or $assets[0].digest -notmatch '^sha256:[0-9a-f]{64}$') { - throw "csrun release $($release.tag_name) must publish one csrun.ps1 asset with a SHA-256 digest." - } - $asset = $assets[0] - Invoke-WebRequest $asset.browser_download_url -OutFile $enginePath - $actualHash = (Get-FileHash -LiteralPath $enginePath -Algorithm SHA256).Hash - if ("sha256:$actualHash" -ne $asset.digest) { throw "csrun asset checksum mismatch: $actualHash" } -$enginePayload = [Convert]::ToBase64String([IO.File]::ReadAllBytes($enginePath)) -$containerInput = $enginePayload + "`n" + $manifest -$command = ' -$ErrorActionPreference = "Stop" -$enginePath = Join-Path ([IO.Path]::GetTempPath()) ("csrun-release-" + [guid]::NewGuid().ToString("N") + ".ps1") -$engineBytes = [Convert]::FromBase64String([Console]::In.ReadLine()) -[IO.File]::WriteAllBytes($enginePath, $engineBytes) -$manifest = [Console]::In.ReadToEnd() -& $enginePath -ManifestJson $manifest -exit $LASTEXITCODE -' -$output = (@($containerInput | & docker run --rm -i --entrypoint pwsh 'codebeltnet/csrun:10' -NoProfile -NonInteractive -Command $command) -join [Environment]::NewLine) -$process = [pscustomobject]@{ ExitCode = $LASTEXITCODE } -$diagnostics = '' -Write-Output $output -} catch { - [Console]::Error.WriteLine("csrun diagnostics retained in: $engineDirectory") - throw -} finally { - $resolvedTemp = [IO.Path]::TrimEndingDirectorySeparator([IO.Path]::GetFullPath([IO.Path]::GetTempPath())) - $resolvedEngineDirectory = [IO.Path]::GetFullPath($engineDirectory) - if ([IO.Path]::GetDirectoryName($resolvedEngineDirectory) -ne $resolvedTemp -or - [IO.Path]::GetFileName($resolvedEngineDirectory) -cnotmatch '^csrun-[a-f0-9]{32}$') { throw 'Unsafe cleanup path.' } - if ($process -and $process.ExitCode -eq 0) { Remove-Item -LiteralPath $resolvedEngineDirectory -Recurse -Force } -} -if ($process.ExitCode -ne 0) { throw "csrun execution failed with exit code $($process.ExitCode). $diagnostics" } -if ($verifyTests) { Assert-CsrunTestOutput $output } -} \ No newline at end of file diff --git a/.docfx/run-actions/aa478d74f298d8c98e6cd1bf/native.ps1 b/.docfx/run-actions/aa478d74f298d8c98e6cd1bf/native.ps1 deleted file mode 100644 index cc2a267..0000000 --- a/.docfx/run-actions/aa478d74f298d8c98e6cd1bf/native.ps1 +++ /dev/null @@ -1,86 +0,0 @@ -& { -#requires -Version 7.0 -$ErrorActionPreference = 'Stop' -$PSNativeCommandUseErrorActionPreference = $false -$manifest = @' -{ - "dependsOn": [ - "Codebelt.Extensions.Xunit.Hosting@13.0.0", - "Microsoft.Extensions.Hosting@10.0.15", - "xunit.v3@4.0.3" - ], - "framework": "net10.0", - "mode": "test", - "schemaVersion": 1, - "source": "using System.Threading;\nusing System.Threading.Tasks;\nusing Codebelt.Extensions.Xunit.Hosting;\nusing Microsoft.Extensions.DependencyInjection;\nusing Microsoft.Extensions.Hosting;\nusing Xunit;\n\nnamespace HostFixtureTests;\n\npublic class BackgroundServiceTest : HostTest\n{\n public BackgroundServiceTest(ManagedHostFixture hostFixture, ITestOutputHelper output) : base(hostFixture, output)\n {\n }\n\n public override void ConfigureServices(IServiceCollection services)\n {\n services.AddHostedService();\n services.AddXunitTestLogging();\n }\n\n [Fact]\n public void Host_ShouldBeRunning()\n {\n Assert.NotNull(Host);\n }\n}\n\npublic class TestWorker : BackgroundService\n{\n protected override async Task ExecuteAsync(CancellationToken stoppingToken)\n {\n while (!stoppingToken.IsCancellationRequested)\n {\n await Task.Delay(100, stoppingToken);\n }\n }\n}" -} -'@ -$OutputEncoding = [Text.UTF8Encoding]::new($false) -[Console]::OutputEncoding = $OutputEncoding -$verifyTests = $true -function Assert-CsrunTestOutput([string] $Output) { - $lines = @($Output -split '\r?\n') - $headers = @($lines | Where-Object { $_ -match '^Test run summary: Passed! - .+\)$' }) - if ($headers.Count -ne 1) { throw 'Expected exactly one completed xUnit test summary.' } - $headerIndex = [Array]::IndexOf($lines, $headers[0]) - $summaryLines = @($lines | Select-Object -Skip ($headerIndex + 1) -First 4) - $counts = @{} - foreach ($line in $summaryLines) { - if ($line -match '^\s*(total|failed|succeeded|skipped):\s*(\d+)\s*$') { $counts[$Matches[1]] = [int]$Matches[2] } - } - if ($counts.Count -ne 4) { throw 'The xUnit test summary counts are incomplete or ambiguous.' } - $failed = $counts.failed - $passed = $counts.succeeded - $skipped = $counts.skipped - $total = $counts.total - if ($total -lt 1 -or $passed -lt 1 -or $failed -ne 0 -or $skipped -ne 0 -or $passed -ne $total) { - throw 'Tests must execute at least once, all pass, and none fail or skip.' - } -} -# Downloads and executes the latest stable csrun release with your permissions. -# Source and release history: https://github.com/codebeltnet/csrun -$engineDirectory = Join-Path ([IO.Path]::GetTempPath()) ('csrun-' + [guid]::NewGuid().ToString('N')) -$null = New-Item -ItemType Directory -Path $engineDirectory -$enginePath = Join-Path $engineDirectory 'csrun.ps1' -$process = $null -try { - $release = Invoke-RestMethod 'https://api.github.com/repos/codebeltnet/csrun/releases/latest' - $assets = @($release.assets | Where-Object name -CEQ 'csrun.ps1') - if ($assets.Count -ne 1 -or $assets[0].digest -notmatch '^sha256:[0-9a-f]{64}$') { - throw "csrun release $($release.tag_name) must publish one csrun.ps1 asset with a SHA-256 digest." - } - $asset = $assets[0] - Invoke-WebRequest $asset.browser_download_url -OutFile $enginePath - $actualHash = (Get-FileHash -LiteralPath $enginePath -Algorithm SHA256).Hash - if ("sha256:$actualHash" -ne $asset.digest) { throw "csrun asset checksum mismatch: $actualHash" } -$startInfo = [Diagnostics.ProcessStartInfo]::new('pwsh') -foreach ($argument in @('-NoProfile','-NonInteractive','-File')) { $startInfo.ArgumentList.Add($argument) } -$startInfo.ArgumentList.Add($enginePath) -$startInfo.ArgumentList.Add('-ManifestJson') -$startInfo.ArgumentList.Add($manifest) -$startInfo.RedirectStandardOutput = $true -$startInfo.RedirectStandardError = $true -$startInfo.UseShellExecute = $false -$process = [Diagnostics.Process]::new() -$process.StartInfo = $startInfo -if (-not $process.Start()) { throw 'Could not start csrun.' } -$stdoutTask = $process.StandardOutput.ReadToEndAsync() -$stderrTask = $process.StandardError.ReadToEndAsync() -$process.WaitForExit() -$output = $stdoutTask.GetAwaiter().GetResult() -$diagnostics = $stderrTask.GetAwaiter().GetResult() -Write-Output $output -if ($diagnostics) { [Console]::Error.Write($diagnostics) } -} catch { - [Console]::Error.WriteLine("csrun diagnostics retained in: $engineDirectory") - throw -} finally { - $resolvedTemp = [IO.Path]::TrimEndingDirectorySeparator([IO.Path]::GetFullPath([IO.Path]::GetTempPath())) - $resolvedEngineDirectory = [IO.Path]::GetFullPath($engineDirectory) - if ([IO.Path]::GetDirectoryName($resolvedEngineDirectory) -ne $resolvedTemp -or - [IO.Path]::GetFileName($resolvedEngineDirectory) -cnotmatch '^csrun-[a-f0-9]{32}$') { throw 'Unsafe cleanup path.' } - if ($process -and $process.ExitCode -eq 0) { Remove-Item -LiteralPath $resolvedEngineDirectory -Recurse -Force } -} -if ($process.ExitCode -ne 0) { throw "csrun execution failed with exit code $($process.ExitCode). $diagnostics" } -if ($verifyTests) { Assert-CsrunTestOutput $output } -} \ No newline at end of file diff --git a/.docfx/run-actions/b4149382f121a5ffc3c057df/docker.ps1 b/.docfx/run-actions/b4149382f121a5ffc3c057df/docker.ps1 deleted file mode 100644 index efb5ce6..0000000 --- a/.docfx/run-actions/b4149382f121a5ffc3c057df/docker.ps1 +++ /dev/null @@ -1,83 +0,0 @@ -& { -#requires -Version 7.0 -$ErrorActionPreference = 'Stop' -$PSNativeCommandUseErrorActionPreference = $false -$manifest = @' -{ - "dependsOn": [ - "Codebelt.Extensions.Xunit.Hosting@13.0.0", - "Microsoft.Extensions.Hosting@10.0.15", - "xunit.v3@4.0.3" - ], - "framework": "net10.0", - "mode": "test", - "schemaVersion": 1, - "source": "using System.Threading.Tasks;\nusing Codebelt.Extensions.Xunit.Hosting;\nusing Microsoft.Extensions.DependencyInjection;\nusing Xunit;\n\nnamespace MinimalWorkerLifecycle.Tests;\n\npublic sealed class SelfManagedMinimalHostFixtureExample\n{\n public async Task ConfigureBeforeStartingAsync()\n {\n using var host = MinimalHostTestFactory.Create(\n services => services.AddSingleton(new StartupState(\"configured\")),\n hostFixture: new SelfManagedMinimalHostFixture());\n\n var beforeStart = host.Host.Services.GetRequiredService();\n Assert.Equal(\"configured\", beforeStart.Value);\n\n await host.Host.StartAsync().ConfigureAwait(false);\n\n var afterStart = host.Host.Services.GetRequiredService();\n Assert.Same(beforeStart, afterStart);\n }\n}\n\npublic sealed record StartupState(string Value);\n\npublic sealed class RunExample\n{\n [Fact]\n public async Task ExercisesExample()\n {\n await new SelfManagedMinimalHostFixtureExample().ConfigureBeforeStartingAsync();\n }\n}" -} -'@ -$OutputEncoding = [Text.UTF8Encoding]::new($false) -[Console]::OutputEncoding = $OutputEncoding -$verifyTests = $true -function Assert-CsrunTestOutput([string] $Output) { - $lines = @($Output -split '\r?\n') - $headers = @($lines | Where-Object { $_ -match '^Test run summary: Passed! - .+\)$' }) - if ($headers.Count -ne 1) { throw 'Expected exactly one completed xUnit test summary.' } - $headerIndex = [Array]::IndexOf($lines, $headers[0]) - $summaryLines = @($lines | Select-Object -Skip ($headerIndex + 1) -First 4) - $counts = @{} - foreach ($line in $summaryLines) { - if ($line -match '^\s*(total|failed|succeeded|skipped):\s*(\d+)\s*$') { $counts[$Matches[1]] = [int]$Matches[2] } - } - if ($counts.Count -ne 4) { throw 'The xUnit test summary counts are incomplete or ambiguous.' } - $failed = $counts.failed - $passed = $counts.succeeded - $skipped = $counts.skipped - $total = $counts.total - if ($total -lt 1 -or $passed -lt 1 -or $failed -ne 0 -or $skipped -ne 0 -or $passed -ne $total) { - throw 'Tests must execute at least once, all pass, and none fail or skip.' - } -} -# Downloads and executes the latest stable csrun release with your permissions. -# Source and release history: https://github.com/codebeltnet/csrun -$engineDirectory = Join-Path ([IO.Path]::GetTempPath()) ('csrun-' + [guid]::NewGuid().ToString('N')) -$null = New-Item -ItemType Directory -Path $engineDirectory -$enginePath = Join-Path $engineDirectory 'csrun.ps1' -$process = $null -try { - $release = Invoke-RestMethod 'https://api.github.com/repos/codebeltnet/csrun/releases/latest' - $assets = @($release.assets | Where-Object name -CEQ 'csrun.ps1') - if ($assets.Count -ne 1 -or $assets[0].digest -notmatch '^sha256:[0-9a-f]{64}$') { - throw "csrun release $($release.tag_name) must publish one csrun.ps1 asset with a SHA-256 digest." - } - $asset = $assets[0] - Invoke-WebRequest $asset.browser_download_url -OutFile $enginePath - $actualHash = (Get-FileHash -LiteralPath $enginePath -Algorithm SHA256).Hash - if ("sha256:$actualHash" -ne $asset.digest) { throw "csrun asset checksum mismatch: $actualHash" } -$enginePayload = [Convert]::ToBase64String([IO.File]::ReadAllBytes($enginePath)) -$containerInput = $enginePayload + "`n" + $manifest -$command = ' -$ErrorActionPreference = "Stop" -$enginePath = Join-Path ([IO.Path]::GetTempPath()) ("csrun-release-" + [guid]::NewGuid().ToString("N") + ".ps1") -$engineBytes = [Convert]::FromBase64String([Console]::In.ReadLine()) -[IO.File]::WriteAllBytes($enginePath, $engineBytes) -$manifest = [Console]::In.ReadToEnd() -& $enginePath -ManifestJson $manifest -exit $LASTEXITCODE -' -$output = (@($containerInput | & docker run --rm -i --entrypoint pwsh 'codebeltnet/csrun:10' -NoProfile -NonInteractive -Command $command) -join [Environment]::NewLine) -$process = [pscustomobject]@{ ExitCode = $LASTEXITCODE } -$diagnostics = '' -Write-Output $output -} catch { - [Console]::Error.WriteLine("csrun diagnostics retained in: $engineDirectory") - throw -} finally { - $resolvedTemp = [IO.Path]::TrimEndingDirectorySeparator([IO.Path]::GetFullPath([IO.Path]::GetTempPath())) - $resolvedEngineDirectory = [IO.Path]::GetFullPath($engineDirectory) - if ([IO.Path]::GetDirectoryName($resolvedEngineDirectory) -ne $resolvedTemp -or - [IO.Path]::GetFileName($resolvedEngineDirectory) -cnotmatch '^csrun-[a-f0-9]{32}$') { throw 'Unsafe cleanup path.' } - if ($process -and $process.ExitCode -eq 0) { Remove-Item -LiteralPath $resolvedEngineDirectory -Recurse -Force } -} -if ($process.ExitCode -ne 0) { throw "csrun execution failed with exit code $($process.ExitCode). $diagnostics" } -if ($verifyTests) { Assert-CsrunTestOutput $output } -} \ No newline at end of file diff --git a/.docfx/run-actions/b4149382f121a5ffc3c057df/native.ps1 b/.docfx/run-actions/b4149382f121a5ffc3c057df/native.ps1 deleted file mode 100644 index d9a6a46..0000000 --- a/.docfx/run-actions/b4149382f121a5ffc3c057df/native.ps1 +++ /dev/null @@ -1,86 +0,0 @@ -& { -#requires -Version 7.0 -$ErrorActionPreference = 'Stop' -$PSNativeCommandUseErrorActionPreference = $false -$manifest = @' -{ - "dependsOn": [ - "Codebelt.Extensions.Xunit.Hosting@13.0.0", - "Microsoft.Extensions.Hosting@10.0.15", - "xunit.v3@4.0.3" - ], - "framework": "net10.0", - "mode": "test", - "schemaVersion": 1, - "source": "using System.Threading.Tasks;\nusing Codebelt.Extensions.Xunit.Hosting;\nusing Microsoft.Extensions.DependencyInjection;\nusing Xunit;\n\nnamespace MinimalWorkerLifecycle.Tests;\n\npublic sealed class SelfManagedMinimalHostFixtureExample\n{\n public async Task ConfigureBeforeStartingAsync()\n {\n using var host = MinimalHostTestFactory.Create(\n services => services.AddSingleton(new StartupState(\"configured\")),\n hostFixture: new SelfManagedMinimalHostFixture());\n\n var beforeStart = host.Host.Services.GetRequiredService();\n Assert.Equal(\"configured\", beforeStart.Value);\n\n await host.Host.StartAsync().ConfigureAwait(false);\n\n var afterStart = host.Host.Services.GetRequiredService();\n Assert.Same(beforeStart, afterStart);\n }\n}\n\npublic sealed record StartupState(string Value);\n\npublic sealed class RunExample\n{\n [Fact]\n public async Task ExercisesExample()\n {\n await new SelfManagedMinimalHostFixtureExample().ConfigureBeforeStartingAsync();\n }\n}" -} -'@ -$OutputEncoding = [Text.UTF8Encoding]::new($false) -[Console]::OutputEncoding = $OutputEncoding -$verifyTests = $true -function Assert-CsrunTestOutput([string] $Output) { - $lines = @($Output -split '\r?\n') - $headers = @($lines | Where-Object { $_ -match '^Test run summary: Passed! - .+\)$' }) - if ($headers.Count -ne 1) { throw 'Expected exactly one completed xUnit test summary.' } - $headerIndex = [Array]::IndexOf($lines, $headers[0]) - $summaryLines = @($lines | Select-Object -Skip ($headerIndex + 1) -First 4) - $counts = @{} - foreach ($line in $summaryLines) { - if ($line -match '^\s*(total|failed|succeeded|skipped):\s*(\d+)\s*$') { $counts[$Matches[1]] = [int]$Matches[2] } - } - if ($counts.Count -ne 4) { throw 'The xUnit test summary counts are incomplete or ambiguous.' } - $failed = $counts.failed - $passed = $counts.succeeded - $skipped = $counts.skipped - $total = $counts.total - if ($total -lt 1 -or $passed -lt 1 -or $failed -ne 0 -or $skipped -ne 0 -or $passed -ne $total) { - throw 'Tests must execute at least once, all pass, and none fail or skip.' - } -} -# Downloads and executes the latest stable csrun release with your permissions. -# Source and release history: https://github.com/codebeltnet/csrun -$engineDirectory = Join-Path ([IO.Path]::GetTempPath()) ('csrun-' + [guid]::NewGuid().ToString('N')) -$null = New-Item -ItemType Directory -Path $engineDirectory -$enginePath = Join-Path $engineDirectory 'csrun.ps1' -$process = $null -try { - $release = Invoke-RestMethod 'https://api.github.com/repos/codebeltnet/csrun/releases/latest' - $assets = @($release.assets | Where-Object name -CEQ 'csrun.ps1') - if ($assets.Count -ne 1 -or $assets[0].digest -notmatch '^sha256:[0-9a-f]{64}$') { - throw "csrun release $($release.tag_name) must publish one csrun.ps1 asset with a SHA-256 digest." - } - $asset = $assets[0] - Invoke-WebRequest $asset.browser_download_url -OutFile $enginePath - $actualHash = (Get-FileHash -LiteralPath $enginePath -Algorithm SHA256).Hash - if ("sha256:$actualHash" -ne $asset.digest) { throw "csrun asset checksum mismatch: $actualHash" } -$startInfo = [Diagnostics.ProcessStartInfo]::new('pwsh') -foreach ($argument in @('-NoProfile','-NonInteractive','-File')) { $startInfo.ArgumentList.Add($argument) } -$startInfo.ArgumentList.Add($enginePath) -$startInfo.ArgumentList.Add('-ManifestJson') -$startInfo.ArgumentList.Add($manifest) -$startInfo.RedirectStandardOutput = $true -$startInfo.RedirectStandardError = $true -$startInfo.UseShellExecute = $false -$process = [Diagnostics.Process]::new() -$process.StartInfo = $startInfo -if (-not $process.Start()) { throw 'Could not start csrun.' } -$stdoutTask = $process.StandardOutput.ReadToEndAsync() -$stderrTask = $process.StandardError.ReadToEndAsync() -$process.WaitForExit() -$output = $stdoutTask.GetAwaiter().GetResult() -$diagnostics = $stderrTask.GetAwaiter().GetResult() -Write-Output $output -if ($diagnostics) { [Console]::Error.Write($diagnostics) } -} catch { - [Console]::Error.WriteLine("csrun diagnostics retained in: $engineDirectory") - throw -} finally { - $resolvedTemp = [IO.Path]::TrimEndingDirectorySeparator([IO.Path]::GetFullPath([IO.Path]::GetTempPath())) - $resolvedEngineDirectory = [IO.Path]::GetFullPath($engineDirectory) - if ([IO.Path]::GetDirectoryName($resolvedEngineDirectory) -ne $resolvedTemp -or - [IO.Path]::GetFileName($resolvedEngineDirectory) -cnotmatch '^csrun-[a-f0-9]{32}$') { throw 'Unsafe cleanup path.' } - if ($process -and $process.ExitCode -eq 0) { Remove-Item -LiteralPath $resolvedEngineDirectory -Recurse -Force } -} -if ($process.ExitCode -ne 0) { throw "csrun execution failed with exit code $($process.ExitCode). $diagnostics" } -if ($verifyTests) { Assert-CsrunTestOutput $output } -} \ No newline at end of file diff --git a/.docfx/run-actions/becb2fe7446fc1571dc86953/docker.ps1 b/.docfx/run-actions/becb2fe7446fc1571dc86953/docker.ps1 deleted file mode 100644 index 3ab7938..0000000 --- a/.docfx/run-actions/becb2fe7446fc1571dc86953/docker.ps1 +++ /dev/null @@ -1,83 +0,0 @@ -& { -#requires -Version 7.0 -$ErrorActionPreference = 'Stop' -$PSNativeCommandUseErrorActionPreference = $false -$manifest = @' -{ - "dependsOn": [ - "Codebelt.Extensions.Xunit.Hosting@13.0.0", - "Microsoft.Extensions.Hosting@10.0.15", - "xunit.v3@4.0.3" - ], - "framework": "net10.0", - "mode": "test", - "schemaVersion": 1, - "source": "using Codebelt.Extensions.Xunit.Hosting;\nusing Xunit;\n\nnamespace HostFixtureTests;\n\npublic class HostStateGuard\n{\n public bool EnsureFixtureIsReady(IMinimalHostFixture fixture)\n {\n return fixture.HasValidState();\n }\n}\n\npublic sealed class RunExample\n{\n [Fact]\n public void ExercisesExample()\n {\n using var fixture = new ManagedMinimalHostFixture();\n Assert.False(new HostStateGuard().EnsureFixtureIsReady(fixture));\n using var app = MinimalHostTestFactory.Create(hostFixture: fixture);\n Assert.True(new HostStateGuard().EnsureFixtureIsReady(fixture));\n }\n}" -} -'@ -$OutputEncoding = [Text.UTF8Encoding]::new($false) -[Console]::OutputEncoding = $OutputEncoding -$verifyTests = $true -function Assert-CsrunTestOutput([string] $Output) { - $lines = @($Output -split '\r?\n') - $headers = @($lines | Where-Object { $_ -match '^Test run summary: Passed! - .+\)$' }) - if ($headers.Count -ne 1) { throw 'Expected exactly one completed xUnit test summary.' } - $headerIndex = [Array]::IndexOf($lines, $headers[0]) - $summaryLines = @($lines | Select-Object -Skip ($headerIndex + 1) -First 4) - $counts = @{} - foreach ($line in $summaryLines) { - if ($line -match '^\s*(total|failed|succeeded|skipped):\s*(\d+)\s*$') { $counts[$Matches[1]] = [int]$Matches[2] } - } - if ($counts.Count -ne 4) { throw 'The xUnit test summary counts are incomplete or ambiguous.' } - $failed = $counts.failed - $passed = $counts.succeeded - $skipped = $counts.skipped - $total = $counts.total - if ($total -lt 1 -or $passed -lt 1 -or $failed -ne 0 -or $skipped -ne 0 -or $passed -ne $total) { - throw 'Tests must execute at least once, all pass, and none fail or skip.' - } -} -# Downloads and executes the latest stable csrun release with your permissions. -# Source and release history: https://github.com/codebeltnet/csrun -$engineDirectory = Join-Path ([IO.Path]::GetTempPath()) ('csrun-' + [guid]::NewGuid().ToString('N')) -$null = New-Item -ItemType Directory -Path $engineDirectory -$enginePath = Join-Path $engineDirectory 'csrun.ps1' -$process = $null -try { - $release = Invoke-RestMethod 'https://api.github.com/repos/codebeltnet/csrun/releases/latest' - $assets = @($release.assets | Where-Object name -CEQ 'csrun.ps1') - if ($assets.Count -ne 1 -or $assets[0].digest -notmatch '^sha256:[0-9a-f]{64}$') { - throw "csrun release $($release.tag_name) must publish one csrun.ps1 asset with a SHA-256 digest." - } - $asset = $assets[0] - Invoke-WebRequest $asset.browser_download_url -OutFile $enginePath - $actualHash = (Get-FileHash -LiteralPath $enginePath -Algorithm SHA256).Hash - if ("sha256:$actualHash" -ne $asset.digest) { throw "csrun asset checksum mismatch: $actualHash" } -$enginePayload = [Convert]::ToBase64String([IO.File]::ReadAllBytes($enginePath)) -$containerInput = $enginePayload + "`n" + $manifest -$command = ' -$ErrorActionPreference = "Stop" -$enginePath = Join-Path ([IO.Path]::GetTempPath()) ("csrun-release-" + [guid]::NewGuid().ToString("N") + ".ps1") -$engineBytes = [Convert]::FromBase64String([Console]::In.ReadLine()) -[IO.File]::WriteAllBytes($enginePath, $engineBytes) -$manifest = [Console]::In.ReadToEnd() -& $enginePath -ManifestJson $manifest -exit $LASTEXITCODE -' -$output = (@($containerInput | & docker run --rm -i --entrypoint pwsh 'codebeltnet/csrun:10' -NoProfile -NonInteractive -Command $command) -join [Environment]::NewLine) -$process = [pscustomobject]@{ ExitCode = $LASTEXITCODE } -$diagnostics = '' -Write-Output $output -} catch { - [Console]::Error.WriteLine("csrun diagnostics retained in: $engineDirectory") - throw -} finally { - $resolvedTemp = [IO.Path]::TrimEndingDirectorySeparator([IO.Path]::GetFullPath([IO.Path]::GetTempPath())) - $resolvedEngineDirectory = [IO.Path]::GetFullPath($engineDirectory) - if ([IO.Path]::GetDirectoryName($resolvedEngineDirectory) -ne $resolvedTemp -or - [IO.Path]::GetFileName($resolvedEngineDirectory) -cnotmatch '^csrun-[a-f0-9]{32}$') { throw 'Unsafe cleanup path.' } - if ($process -and $process.ExitCode -eq 0) { Remove-Item -LiteralPath $resolvedEngineDirectory -Recurse -Force } -} -if ($process.ExitCode -ne 0) { throw "csrun execution failed with exit code $($process.ExitCode). $diagnostics" } -if ($verifyTests) { Assert-CsrunTestOutput $output } -} \ No newline at end of file diff --git a/.docfx/run-actions/becb2fe7446fc1571dc86953/native.ps1 b/.docfx/run-actions/becb2fe7446fc1571dc86953/native.ps1 deleted file mode 100644 index 7244533..0000000 --- a/.docfx/run-actions/becb2fe7446fc1571dc86953/native.ps1 +++ /dev/null @@ -1,86 +0,0 @@ -& { -#requires -Version 7.0 -$ErrorActionPreference = 'Stop' -$PSNativeCommandUseErrorActionPreference = $false -$manifest = @' -{ - "dependsOn": [ - "Codebelt.Extensions.Xunit.Hosting@13.0.0", - "Microsoft.Extensions.Hosting@10.0.15", - "xunit.v3@4.0.3" - ], - "framework": "net10.0", - "mode": "test", - "schemaVersion": 1, - "source": "using Codebelt.Extensions.Xunit.Hosting;\nusing Xunit;\n\nnamespace HostFixtureTests;\n\npublic class HostStateGuard\n{\n public bool EnsureFixtureIsReady(IMinimalHostFixture fixture)\n {\n return fixture.HasValidState();\n }\n}\n\npublic sealed class RunExample\n{\n [Fact]\n public void ExercisesExample()\n {\n using var fixture = new ManagedMinimalHostFixture();\n Assert.False(new HostStateGuard().EnsureFixtureIsReady(fixture));\n using var app = MinimalHostTestFactory.Create(hostFixture: fixture);\n Assert.True(new HostStateGuard().EnsureFixtureIsReady(fixture));\n }\n}" -} -'@ -$OutputEncoding = [Text.UTF8Encoding]::new($false) -[Console]::OutputEncoding = $OutputEncoding -$verifyTests = $true -function Assert-CsrunTestOutput([string] $Output) { - $lines = @($Output -split '\r?\n') - $headers = @($lines | Where-Object { $_ -match '^Test run summary: Passed! - .+\)$' }) - if ($headers.Count -ne 1) { throw 'Expected exactly one completed xUnit test summary.' } - $headerIndex = [Array]::IndexOf($lines, $headers[0]) - $summaryLines = @($lines | Select-Object -Skip ($headerIndex + 1) -First 4) - $counts = @{} - foreach ($line in $summaryLines) { - if ($line -match '^\s*(total|failed|succeeded|skipped):\s*(\d+)\s*$') { $counts[$Matches[1]] = [int]$Matches[2] } - } - if ($counts.Count -ne 4) { throw 'The xUnit test summary counts are incomplete or ambiguous.' } - $failed = $counts.failed - $passed = $counts.succeeded - $skipped = $counts.skipped - $total = $counts.total - if ($total -lt 1 -or $passed -lt 1 -or $failed -ne 0 -or $skipped -ne 0 -or $passed -ne $total) { - throw 'Tests must execute at least once, all pass, and none fail or skip.' - } -} -# Downloads and executes the latest stable csrun release with your permissions. -# Source and release history: https://github.com/codebeltnet/csrun -$engineDirectory = Join-Path ([IO.Path]::GetTempPath()) ('csrun-' + [guid]::NewGuid().ToString('N')) -$null = New-Item -ItemType Directory -Path $engineDirectory -$enginePath = Join-Path $engineDirectory 'csrun.ps1' -$process = $null -try { - $release = Invoke-RestMethod 'https://api.github.com/repos/codebeltnet/csrun/releases/latest' - $assets = @($release.assets | Where-Object name -CEQ 'csrun.ps1') - if ($assets.Count -ne 1 -or $assets[0].digest -notmatch '^sha256:[0-9a-f]{64}$') { - throw "csrun release $($release.tag_name) must publish one csrun.ps1 asset with a SHA-256 digest." - } - $asset = $assets[0] - Invoke-WebRequest $asset.browser_download_url -OutFile $enginePath - $actualHash = (Get-FileHash -LiteralPath $enginePath -Algorithm SHA256).Hash - if ("sha256:$actualHash" -ne $asset.digest) { throw "csrun asset checksum mismatch: $actualHash" } -$startInfo = [Diagnostics.ProcessStartInfo]::new('pwsh') -foreach ($argument in @('-NoProfile','-NonInteractive','-File')) { $startInfo.ArgumentList.Add($argument) } -$startInfo.ArgumentList.Add($enginePath) -$startInfo.ArgumentList.Add('-ManifestJson') -$startInfo.ArgumentList.Add($manifest) -$startInfo.RedirectStandardOutput = $true -$startInfo.RedirectStandardError = $true -$startInfo.UseShellExecute = $false -$process = [Diagnostics.Process]::new() -$process.StartInfo = $startInfo -if (-not $process.Start()) { throw 'Could not start csrun.' } -$stdoutTask = $process.StandardOutput.ReadToEndAsync() -$stderrTask = $process.StandardError.ReadToEndAsync() -$process.WaitForExit() -$output = $stdoutTask.GetAwaiter().GetResult() -$diagnostics = $stderrTask.GetAwaiter().GetResult() -Write-Output $output -if ($diagnostics) { [Console]::Error.Write($diagnostics) } -} catch { - [Console]::Error.WriteLine("csrun diagnostics retained in: $engineDirectory") - throw -} finally { - $resolvedTemp = [IO.Path]::TrimEndingDirectorySeparator([IO.Path]::GetFullPath([IO.Path]::GetTempPath())) - $resolvedEngineDirectory = [IO.Path]::GetFullPath($engineDirectory) - if ([IO.Path]::GetDirectoryName($resolvedEngineDirectory) -ne $resolvedTemp -or - [IO.Path]::GetFileName($resolvedEngineDirectory) -cnotmatch '^csrun-[a-f0-9]{32}$') { throw 'Unsafe cleanup path.' } - if ($process -and $process.ExitCode -eq 0) { Remove-Item -LiteralPath $resolvedEngineDirectory -Recurse -Force } -} -if ($process.ExitCode -ne 0) { throw "csrun execution failed with exit code $($process.ExitCode). $diagnostics" } -if ($verifyTests) { Assert-CsrunTestOutput $output } -} \ No newline at end of file diff --git a/.docfx/run-actions/d565f9c40d015b247963fdee/docker.ps1 b/.docfx/run-actions/d565f9c40d015b247963fdee/docker.ps1 deleted file mode 100644 index 1b168e4..0000000 --- a/.docfx/run-actions/d565f9c40d015b247963fdee/docker.ps1 +++ /dev/null @@ -1,86 +0,0 @@ -& { -#requires -Version 7.0 -$ErrorActionPreference = 'Stop' -$PSNativeCommandUseErrorActionPreference = $false -$manifest = @' -{ - "dependsOn": [ - "Codebelt.Extensions.Xunit.Hosting.AspNetCore@13.0.0", - "Microsoft.Extensions.Hosting@10.0.15", - "xunit.v3@4.0.3" - ], - "framework": "net10.0", - "frameworkReferences": [ - "Microsoft.AspNetCore.App" - ], - "mode": "test", - "schemaVersion": 1, - "source": "using Codebelt.Extensions.Xunit.Hosting.AspNetCore;\nusing Microsoft.AspNetCore.Builder;\nusing Microsoft.Extensions.Hosting;\nusing Xunit;\n\nnamespace WebFixtureTests;\n\npublic class BuilderConverter\n{\n public IHostBuilder Convert(IHostApplicationBuilder builder)\n {\n return builder.ToHostBuilder();\n }\n}\n\npublic sealed class RunExample\n{\n [Fact]\n public void ReturnsTheWebHostBuilder()\n {\n var builder = WebApplication.CreateBuilder();\n Assert.Same(builder.Host, new BuilderConverter().Convert(builder));\n }\n}" -} -'@ -$OutputEncoding = [Text.UTF8Encoding]::new($false) -[Console]::OutputEncoding = $OutputEncoding -$verifyTests = $true -function Assert-CsrunTestOutput([string] $Output) { - $lines = @($Output -split '\r?\n') - $headers = @($lines | Where-Object { $_ -match '^Test run summary: Passed! - .+\)$' }) - if ($headers.Count -ne 1) { throw 'Expected exactly one completed xUnit test summary.' } - $headerIndex = [Array]::IndexOf($lines, $headers[0]) - $summaryLines = @($lines | Select-Object -Skip ($headerIndex + 1) -First 4) - $counts = @{} - foreach ($line in $summaryLines) { - if ($line -match '^\s*(total|failed|succeeded|skipped):\s*(\d+)\s*$') { $counts[$Matches[1]] = [int]$Matches[2] } - } - if ($counts.Count -ne 4) { throw 'The xUnit test summary counts are incomplete or ambiguous.' } - $failed = $counts.failed - $passed = $counts.succeeded - $skipped = $counts.skipped - $total = $counts.total - if ($total -lt 1 -or $passed -lt 1 -or $failed -ne 0 -or $skipped -ne 0 -or $passed -ne $total) { - throw 'Tests must execute at least once, all pass, and none fail or skip.' - } -} -# Downloads and executes the latest stable csrun release with your permissions. -# Source and release history: https://github.com/codebeltnet/csrun -$engineDirectory = Join-Path ([IO.Path]::GetTempPath()) ('csrun-' + [guid]::NewGuid().ToString('N')) -$null = New-Item -ItemType Directory -Path $engineDirectory -$enginePath = Join-Path $engineDirectory 'csrun.ps1' -$process = $null -try { - $release = Invoke-RestMethod 'https://api.github.com/repos/codebeltnet/csrun/releases/latest' - $assets = @($release.assets | Where-Object name -CEQ 'csrun.ps1') - if ($assets.Count -ne 1 -or $assets[0].digest -notmatch '^sha256:[0-9a-f]{64}$') { - throw "csrun release $($release.tag_name) must publish one csrun.ps1 asset with a SHA-256 digest." - } - $asset = $assets[0] - Invoke-WebRequest $asset.browser_download_url -OutFile $enginePath - $actualHash = (Get-FileHash -LiteralPath $enginePath -Algorithm SHA256).Hash - if ("sha256:$actualHash" -ne $asset.digest) { throw "csrun asset checksum mismatch: $actualHash" } -$enginePayload = [Convert]::ToBase64String([IO.File]::ReadAllBytes($enginePath)) -$containerInput = $enginePayload + "`n" + $manifest -$command = ' -$ErrorActionPreference = "Stop" -$enginePath = Join-Path ([IO.Path]::GetTempPath()) ("csrun-release-" + [guid]::NewGuid().ToString("N") + ".ps1") -$engineBytes = [Convert]::FromBase64String([Console]::In.ReadLine()) -[IO.File]::WriteAllBytes($enginePath, $engineBytes) -$manifest = [Console]::In.ReadToEnd() -& $enginePath -ManifestJson $manifest -exit $LASTEXITCODE -' -$output = (@($containerInput | & docker run --rm -i --entrypoint pwsh 'codebeltnet/csrun:10' -NoProfile -NonInteractive -Command $command) -join [Environment]::NewLine) -$process = [pscustomobject]@{ ExitCode = $LASTEXITCODE } -$diagnostics = '' -Write-Output $output -} catch { - [Console]::Error.WriteLine("csrun diagnostics retained in: $engineDirectory") - throw -} finally { - $resolvedTemp = [IO.Path]::TrimEndingDirectorySeparator([IO.Path]::GetFullPath([IO.Path]::GetTempPath())) - $resolvedEngineDirectory = [IO.Path]::GetFullPath($engineDirectory) - if ([IO.Path]::GetDirectoryName($resolvedEngineDirectory) -ne $resolvedTemp -or - [IO.Path]::GetFileName($resolvedEngineDirectory) -cnotmatch '^csrun-[a-f0-9]{32}$') { throw 'Unsafe cleanup path.' } - if ($process -and $process.ExitCode -eq 0) { Remove-Item -LiteralPath $resolvedEngineDirectory -Recurse -Force } -} -if ($process.ExitCode -ne 0) { throw "csrun execution failed with exit code $($process.ExitCode). $diagnostics" } -if ($verifyTests) { Assert-CsrunTestOutput $output } -} \ No newline at end of file diff --git a/.docfx/run-actions/d565f9c40d015b247963fdee/native.ps1 b/.docfx/run-actions/d565f9c40d015b247963fdee/native.ps1 deleted file mode 100644 index 4df77d6..0000000 --- a/.docfx/run-actions/d565f9c40d015b247963fdee/native.ps1 +++ /dev/null @@ -1,89 +0,0 @@ -& { -#requires -Version 7.0 -$ErrorActionPreference = 'Stop' -$PSNativeCommandUseErrorActionPreference = $false -$manifest = @' -{ - "dependsOn": [ - "Codebelt.Extensions.Xunit.Hosting.AspNetCore@13.0.0", - "Microsoft.Extensions.Hosting@10.0.15", - "xunit.v3@4.0.3" - ], - "framework": "net10.0", - "frameworkReferences": [ - "Microsoft.AspNetCore.App" - ], - "mode": "test", - "schemaVersion": 1, - "source": "using Codebelt.Extensions.Xunit.Hosting.AspNetCore;\nusing Microsoft.AspNetCore.Builder;\nusing Microsoft.Extensions.Hosting;\nusing Xunit;\n\nnamespace WebFixtureTests;\n\npublic class BuilderConverter\n{\n public IHostBuilder Convert(IHostApplicationBuilder builder)\n {\n return builder.ToHostBuilder();\n }\n}\n\npublic sealed class RunExample\n{\n [Fact]\n public void ReturnsTheWebHostBuilder()\n {\n var builder = WebApplication.CreateBuilder();\n Assert.Same(builder.Host, new BuilderConverter().Convert(builder));\n }\n}" -} -'@ -$OutputEncoding = [Text.UTF8Encoding]::new($false) -[Console]::OutputEncoding = $OutputEncoding -$verifyTests = $true -function Assert-CsrunTestOutput([string] $Output) { - $lines = @($Output -split '\r?\n') - $headers = @($lines | Where-Object { $_ -match '^Test run summary: Passed! - .+\)$' }) - if ($headers.Count -ne 1) { throw 'Expected exactly one completed xUnit test summary.' } - $headerIndex = [Array]::IndexOf($lines, $headers[0]) - $summaryLines = @($lines | Select-Object -Skip ($headerIndex + 1) -First 4) - $counts = @{} - foreach ($line in $summaryLines) { - if ($line -match '^\s*(total|failed|succeeded|skipped):\s*(\d+)\s*$') { $counts[$Matches[1]] = [int]$Matches[2] } - } - if ($counts.Count -ne 4) { throw 'The xUnit test summary counts are incomplete or ambiguous.' } - $failed = $counts.failed - $passed = $counts.succeeded - $skipped = $counts.skipped - $total = $counts.total - if ($total -lt 1 -or $passed -lt 1 -or $failed -ne 0 -or $skipped -ne 0 -or $passed -ne $total) { - throw 'Tests must execute at least once, all pass, and none fail or skip.' - } -} -# Downloads and executes the latest stable csrun release with your permissions. -# Source and release history: https://github.com/codebeltnet/csrun -$engineDirectory = Join-Path ([IO.Path]::GetTempPath()) ('csrun-' + [guid]::NewGuid().ToString('N')) -$null = New-Item -ItemType Directory -Path $engineDirectory -$enginePath = Join-Path $engineDirectory 'csrun.ps1' -$process = $null -try { - $release = Invoke-RestMethod 'https://api.github.com/repos/codebeltnet/csrun/releases/latest' - $assets = @($release.assets | Where-Object name -CEQ 'csrun.ps1') - if ($assets.Count -ne 1 -or $assets[0].digest -notmatch '^sha256:[0-9a-f]{64}$') { - throw "csrun release $($release.tag_name) must publish one csrun.ps1 asset with a SHA-256 digest." - } - $asset = $assets[0] - Invoke-WebRequest $asset.browser_download_url -OutFile $enginePath - $actualHash = (Get-FileHash -LiteralPath $enginePath -Algorithm SHA256).Hash - if ("sha256:$actualHash" -ne $asset.digest) { throw "csrun asset checksum mismatch: $actualHash" } -$startInfo = [Diagnostics.ProcessStartInfo]::new('pwsh') -foreach ($argument in @('-NoProfile','-NonInteractive','-File')) { $startInfo.ArgumentList.Add($argument) } -$startInfo.ArgumentList.Add($enginePath) -$startInfo.ArgumentList.Add('-ManifestJson') -$startInfo.ArgumentList.Add($manifest) -$startInfo.RedirectStandardOutput = $true -$startInfo.RedirectStandardError = $true -$startInfo.UseShellExecute = $false -$process = [Diagnostics.Process]::new() -$process.StartInfo = $startInfo -if (-not $process.Start()) { throw 'Could not start csrun.' } -$stdoutTask = $process.StandardOutput.ReadToEndAsync() -$stderrTask = $process.StandardError.ReadToEndAsync() -$process.WaitForExit() -$output = $stdoutTask.GetAwaiter().GetResult() -$diagnostics = $stderrTask.GetAwaiter().GetResult() -Write-Output $output -if ($diagnostics) { [Console]::Error.Write($diagnostics) } -} catch { - [Console]::Error.WriteLine("csrun diagnostics retained in: $engineDirectory") - throw -} finally { - $resolvedTemp = [IO.Path]::TrimEndingDirectorySeparator([IO.Path]::GetFullPath([IO.Path]::GetTempPath())) - $resolvedEngineDirectory = [IO.Path]::GetFullPath($engineDirectory) - if ([IO.Path]::GetDirectoryName($resolvedEngineDirectory) -ne $resolvedTemp -or - [IO.Path]::GetFileName($resolvedEngineDirectory) -cnotmatch '^csrun-[a-f0-9]{32}$') { throw 'Unsafe cleanup path.' } - if ($process -and $process.ExitCode -eq 0) { Remove-Item -LiteralPath $resolvedEngineDirectory -Recurse -Force } -} -if ($process.ExitCode -ne 0) { throw "csrun execution failed with exit code $($process.ExitCode). $diagnostics" } -if ($verifyTests) { Assert-CsrunTestOutput $output } -} \ No newline at end of file diff --git a/.docfx/run-actions/d71e8ed85f1221cb41308b31/docker.ps1 b/.docfx/run-actions/d71e8ed85f1221cb41308b31/docker.ps1 deleted file mode 100644 index 7912d45..0000000 --- a/.docfx/run-actions/d71e8ed85f1221cb41308b31/docker.ps1 +++ /dev/null @@ -1,86 +0,0 @@ -& { -#requires -Version 7.0 -$ErrorActionPreference = 'Stop' -$PSNativeCommandUseErrorActionPreference = $false -$manifest = @' -{ - "dependsOn": [ - "Codebelt.Extensions.Xunit.Hosting.AspNetCore@13.0.0", - "Microsoft.Extensions.Hosting@10.0.15", - "xunit.v3@4.0.3" - ], - "framework": "net10.0", - "frameworkReferences": [ - "Microsoft.AspNetCore.App" - ], - "mode": "test", - "schemaVersion": 1, - "source": "using System.Threading.Tasks;\nusing Codebelt.Extensions.Xunit.Hosting.AspNetCore;\nusing Microsoft.AspNetCore.Builder;\nusing Microsoft.AspNetCore.Http;\nusing Microsoft.Extensions.DependencyInjection;\nusing Xunit;\n\nnamespace RequestPipeline.Tests;\n\npublic sealed class WebHostTestFactoryExample\n{\n public async Task InvokeStatusMiddlewareAsync()\n {\n using var response = await WebHostTestFactory.RunAsync(\n services => services.AddSingleton(new PipelineStatus(\"ready\")),\n app => app.Run(context =>\n {\n var status = context.RequestServices.GetRequiredService();\n return context.Response.WriteAsync(status.Value);\n })).ConfigureAwait(false);\n\n return await response.Content.ReadAsStringAsync().ConfigureAwait(false);\n }\n}\n\npublic sealed record PipelineStatus(string Value);\n\npublic sealed class RunExample\n{\n [Fact]\n public async Task ExercisesExample()\n {\n Assert.Equal(\"ready\", await new WebHostTestFactoryExample().InvokeStatusMiddlewareAsync());\n }\n}" -} -'@ -$OutputEncoding = [Text.UTF8Encoding]::new($false) -[Console]::OutputEncoding = $OutputEncoding -$verifyTests = $true -function Assert-CsrunTestOutput([string] $Output) { - $lines = @($Output -split '\r?\n') - $headers = @($lines | Where-Object { $_ -match '^Test run summary: Passed! - .+\)$' }) - if ($headers.Count -ne 1) { throw 'Expected exactly one completed xUnit test summary.' } - $headerIndex = [Array]::IndexOf($lines, $headers[0]) - $summaryLines = @($lines | Select-Object -Skip ($headerIndex + 1) -First 4) - $counts = @{} - foreach ($line in $summaryLines) { - if ($line -match '^\s*(total|failed|succeeded|skipped):\s*(\d+)\s*$') { $counts[$Matches[1]] = [int]$Matches[2] } - } - if ($counts.Count -ne 4) { throw 'The xUnit test summary counts are incomplete or ambiguous.' } - $failed = $counts.failed - $passed = $counts.succeeded - $skipped = $counts.skipped - $total = $counts.total - if ($total -lt 1 -or $passed -lt 1 -or $failed -ne 0 -or $skipped -ne 0 -or $passed -ne $total) { - throw 'Tests must execute at least once, all pass, and none fail or skip.' - } -} -# Downloads and executes the latest stable csrun release with your permissions. -# Source and release history: https://github.com/codebeltnet/csrun -$engineDirectory = Join-Path ([IO.Path]::GetTempPath()) ('csrun-' + [guid]::NewGuid().ToString('N')) -$null = New-Item -ItemType Directory -Path $engineDirectory -$enginePath = Join-Path $engineDirectory 'csrun.ps1' -$process = $null -try { - $release = Invoke-RestMethod 'https://api.github.com/repos/codebeltnet/csrun/releases/latest' - $assets = @($release.assets | Where-Object name -CEQ 'csrun.ps1') - if ($assets.Count -ne 1 -or $assets[0].digest -notmatch '^sha256:[0-9a-f]{64}$') { - throw "csrun release $($release.tag_name) must publish one csrun.ps1 asset with a SHA-256 digest." - } - $asset = $assets[0] - Invoke-WebRequest $asset.browser_download_url -OutFile $enginePath - $actualHash = (Get-FileHash -LiteralPath $enginePath -Algorithm SHA256).Hash - if ("sha256:$actualHash" -ne $asset.digest) { throw "csrun asset checksum mismatch: $actualHash" } -$enginePayload = [Convert]::ToBase64String([IO.File]::ReadAllBytes($enginePath)) -$containerInput = $enginePayload + "`n" + $manifest -$command = ' -$ErrorActionPreference = "Stop" -$enginePath = Join-Path ([IO.Path]::GetTempPath()) ("csrun-release-" + [guid]::NewGuid().ToString("N") + ".ps1") -$engineBytes = [Convert]::FromBase64String([Console]::In.ReadLine()) -[IO.File]::WriteAllBytes($enginePath, $engineBytes) -$manifest = [Console]::In.ReadToEnd() -& $enginePath -ManifestJson $manifest -exit $LASTEXITCODE -' -$output = (@($containerInput | & docker run --rm -i --entrypoint pwsh 'codebeltnet/csrun:10' -NoProfile -NonInteractive -Command $command) -join [Environment]::NewLine) -$process = [pscustomobject]@{ ExitCode = $LASTEXITCODE } -$diagnostics = '' -Write-Output $output -} catch { - [Console]::Error.WriteLine("csrun diagnostics retained in: $engineDirectory") - throw -} finally { - $resolvedTemp = [IO.Path]::TrimEndingDirectorySeparator([IO.Path]::GetFullPath([IO.Path]::GetTempPath())) - $resolvedEngineDirectory = [IO.Path]::GetFullPath($engineDirectory) - if ([IO.Path]::GetDirectoryName($resolvedEngineDirectory) -ne $resolvedTemp -or - [IO.Path]::GetFileName($resolvedEngineDirectory) -cnotmatch '^csrun-[a-f0-9]{32}$') { throw 'Unsafe cleanup path.' } - if ($process -and $process.ExitCode -eq 0) { Remove-Item -LiteralPath $resolvedEngineDirectory -Recurse -Force } -} -if ($process.ExitCode -ne 0) { throw "csrun execution failed with exit code $($process.ExitCode). $diagnostics" } -if ($verifyTests) { Assert-CsrunTestOutput $output } -} \ No newline at end of file diff --git a/.docfx/run-actions/d71e8ed85f1221cb41308b31/native.ps1 b/.docfx/run-actions/d71e8ed85f1221cb41308b31/native.ps1 deleted file mode 100644 index 1137601..0000000 --- a/.docfx/run-actions/d71e8ed85f1221cb41308b31/native.ps1 +++ /dev/null @@ -1,89 +0,0 @@ -& { -#requires -Version 7.0 -$ErrorActionPreference = 'Stop' -$PSNativeCommandUseErrorActionPreference = $false -$manifest = @' -{ - "dependsOn": [ - "Codebelt.Extensions.Xunit.Hosting.AspNetCore@13.0.0", - "Microsoft.Extensions.Hosting@10.0.15", - "xunit.v3@4.0.3" - ], - "framework": "net10.0", - "frameworkReferences": [ - "Microsoft.AspNetCore.App" - ], - "mode": "test", - "schemaVersion": 1, - "source": "using System.Threading.Tasks;\nusing Codebelt.Extensions.Xunit.Hosting.AspNetCore;\nusing Microsoft.AspNetCore.Builder;\nusing Microsoft.AspNetCore.Http;\nusing Microsoft.Extensions.DependencyInjection;\nusing Xunit;\n\nnamespace RequestPipeline.Tests;\n\npublic sealed class WebHostTestFactoryExample\n{\n public async Task InvokeStatusMiddlewareAsync()\n {\n using var response = await WebHostTestFactory.RunAsync(\n services => services.AddSingleton(new PipelineStatus(\"ready\")),\n app => app.Run(context =>\n {\n var status = context.RequestServices.GetRequiredService();\n return context.Response.WriteAsync(status.Value);\n })).ConfigureAwait(false);\n\n return await response.Content.ReadAsStringAsync().ConfigureAwait(false);\n }\n}\n\npublic sealed record PipelineStatus(string Value);\n\npublic sealed class RunExample\n{\n [Fact]\n public async Task ExercisesExample()\n {\n Assert.Equal(\"ready\", await new WebHostTestFactoryExample().InvokeStatusMiddlewareAsync());\n }\n}" -} -'@ -$OutputEncoding = [Text.UTF8Encoding]::new($false) -[Console]::OutputEncoding = $OutputEncoding -$verifyTests = $true -function Assert-CsrunTestOutput([string] $Output) { - $lines = @($Output -split '\r?\n') - $headers = @($lines | Where-Object { $_ -match '^Test run summary: Passed! - .+\)$' }) - if ($headers.Count -ne 1) { throw 'Expected exactly one completed xUnit test summary.' } - $headerIndex = [Array]::IndexOf($lines, $headers[0]) - $summaryLines = @($lines | Select-Object -Skip ($headerIndex + 1) -First 4) - $counts = @{} - foreach ($line in $summaryLines) { - if ($line -match '^\s*(total|failed|succeeded|skipped):\s*(\d+)\s*$') { $counts[$Matches[1]] = [int]$Matches[2] } - } - if ($counts.Count -ne 4) { throw 'The xUnit test summary counts are incomplete or ambiguous.' } - $failed = $counts.failed - $passed = $counts.succeeded - $skipped = $counts.skipped - $total = $counts.total - if ($total -lt 1 -or $passed -lt 1 -or $failed -ne 0 -or $skipped -ne 0 -or $passed -ne $total) { - throw 'Tests must execute at least once, all pass, and none fail or skip.' - } -} -# Downloads and executes the latest stable csrun release with your permissions. -# Source and release history: https://github.com/codebeltnet/csrun -$engineDirectory = Join-Path ([IO.Path]::GetTempPath()) ('csrun-' + [guid]::NewGuid().ToString('N')) -$null = New-Item -ItemType Directory -Path $engineDirectory -$enginePath = Join-Path $engineDirectory 'csrun.ps1' -$process = $null -try { - $release = Invoke-RestMethod 'https://api.github.com/repos/codebeltnet/csrun/releases/latest' - $assets = @($release.assets | Where-Object name -CEQ 'csrun.ps1') - if ($assets.Count -ne 1 -or $assets[0].digest -notmatch '^sha256:[0-9a-f]{64}$') { - throw "csrun release $($release.tag_name) must publish one csrun.ps1 asset with a SHA-256 digest." - } - $asset = $assets[0] - Invoke-WebRequest $asset.browser_download_url -OutFile $enginePath - $actualHash = (Get-FileHash -LiteralPath $enginePath -Algorithm SHA256).Hash - if ("sha256:$actualHash" -ne $asset.digest) { throw "csrun asset checksum mismatch: $actualHash" } -$startInfo = [Diagnostics.ProcessStartInfo]::new('pwsh') -foreach ($argument in @('-NoProfile','-NonInteractive','-File')) { $startInfo.ArgumentList.Add($argument) } -$startInfo.ArgumentList.Add($enginePath) -$startInfo.ArgumentList.Add('-ManifestJson') -$startInfo.ArgumentList.Add($manifest) -$startInfo.RedirectStandardOutput = $true -$startInfo.RedirectStandardError = $true -$startInfo.UseShellExecute = $false -$process = [Diagnostics.Process]::new() -$process.StartInfo = $startInfo -if (-not $process.Start()) { throw 'Could not start csrun.' } -$stdoutTask = $process.StandardOutput.ReadToEndAsync() -$stderrTask = $process.StandardError.ReadToEndAsync() -$process.WaitForExit() -$output = $stdoutTask.GetAwaiter().GetResult() -$diagnostics = $stderrTask.GetAwaiter().GetResult() -Write-Output $output -if ($diagnostics) { [Console]::Error.Write($diagnostics) } -} catch { - [Console]::Error.WriteLine("csrun diagnostics retained in: $engineDirectory") - throw -} finally { - $resolvedTemp = [IO.Path]::TrimEndingDirectorySeparator([IO.Path]::GetFullPath([IO.Path]::GetTempPath())) - $resolvedEngineDirectory = [IO.Path]::GetFullPath($engineDirectory) - if ([IO.Path]::GetDirectoryName($resolvedEngineDirectory) -ne $resolvedTemp -or - [IO.Path]::GetFileName($resolvedEngineDirectory) -cnotmatch '^csrun-[a-f0-9]{32}$') { throw 'Unsafe cleanup path.' } - if ($process -and $process.ExitCode -eq 0) { Remove-Item -LiteralPath $resolvedEngineDirectory -Recurse -Force } -} -if ($process.ExitCode -ne 0) { throw "csrun execution failed with exit code $($process.ExitCode). $diagnostics" } -if ($verifyTests) { Assert-CsrunTestOutput $output } -} \ No newline at end of file diff --git a/.docfx/run-actions/dd2fa1a038dbc1220b366a53/docker.ps1 b/.docfx/run-actions/dd2fa1a038dbc1220b366a53/docker.ps1 deleted file mode 100644 index 5ff802c..0000000 --- a/.docfx/run-actions/dd2fa1a038dbc1220b366a53/docker.ps1 +++ /dev/null @@ -1,86 +0,0 @@ -& { -#requires -Version 7.0 -$ErrorActionPreference = 'Stop' -$PSNativeCommandUseErrorActionPreference = $false -$manifest = @' -{ - "dependsOn": [ - "Codebelt.Extensions.Xunit.Hosting.AspNetCore@13.0.0", - "Microsoft.Extensions.Hosting@10.0.15", - "xunit.v3@4.0.3" - ], - "framework": "net10.0", - "frameworkReferences": [ - "Microsoft.AspNetCore.App" - ], - "mode": "test", - "schemaVersion": 1, - "source": "using Codebelt.Extensions.Xunit.Hosting.AspNetCore;\nusing Xunit;\n\nnamespace WebFixtureTests;\n\npublic class WebMinimalHostStateGuard\n{\n public bool EnsureFixtureIsReady(IWebMinimalHostFixture fixture)\n {\n return fixture.HasValidState();\n }\n}\n\npublic sealed class RunExample\n{\n [Fact]\n public void ExercisesExample()\n {\n using var fixture = new ManagedWebMinimalHostFixture();\n Assert.False(new WebMinimalHostStateGuard().EnsureFixtureIsReady(fixture));\n using var app = MinimalWebHostTestFactory.Create(hostFixture: fixture);\n Assert.True(new WebMinimalHostStateGuard().EnsureFixtureIsReady(fixture));\n }\n}" -} -'@ -$OutputEncoding = [Text.UTF8Encoding]::new($false) -[Console]::OutputEncoding = $OutputEncoding -$verifyTests = $true -function Assert-CsrunTestOutput([string] $Output) { - $lines = @($Output -split '\r?\n') - $headers = @($lines | Where-Object { $_ -match '^Test run summary: Passed! - .+\)$' }) - if ($headers.Count -ne 1) { throw 'Expected exactly one completed xUnit test summary.' } - $headerIndex = [Array]::IndexOf($lines, $headers[0]) - $summaryLines = @($lines | Select-Object -Skip ($headerIndex + 1) -First 4) - $counts = @{} - foreach ($line in $summaryLines) { - if ($line -match '^\s*(total|failed|succeeded|skipped):\s*(\d+)\s*$') { $counts[$Matches[1]] = [int]$Matches[2] } - } - if ($counts.Count -ne 4) { throw 'The xUnit test summary counts are incomplete or ambiguous.' } - $failed = $counts.failed - $passed = $counts.succeeded - $skipped = $counts.skipped - $total = $counts.total - if ($total -lt 1 -or $passed -lt 1 -or $failed -ne 0 -or $skipped -ne 0 -or $passed -ne $total) { - throw 'Tests must execute at least once, all pass, and none fail or skip.' - } -} -# Downloads and executes the latest stable csrun release with your permissions. -# Source and release history: https://github.com/codebeltnet/csrun -$engineDirectory = Join-Path ([IO.Path]::GetTempPath()) ('csrun-' + [guid]::NewGuid().ToString('N')) -$null = New-Item -ItemType Directory -Path $engineDirectory -$enginePath = Join-Path $engineDirectory 'csrun.ps1' -$process = $null -try { - $release = Invoke-RestMethod 'https://api.github.com/repos/codebeltnet/csrun/releases/latest' - $assets = @($release.assets | Where-Object name -CEQ 'csrun.ps1') - if ($assets.Count -ne 1 -or $assets[0].digest -notmatch '^sha256:[0-9a-f]{64}$') { - throw "csrun release $($release.tag_name) must publish one csrun.ps1 asset with a SHA-256 digest." - } - $asset = $assets[0] - Invoke-WebRequest $asset.browser_download_url -OutFile $enginePath - $actualHash = (Get-FileHash -LiteralPath $enginePath -Algorithm SHA256).Hash - if ("sha256:$actualHash" -ne $asset.digest) { throw "csrun asset checksum mismatch: $actualHash" } -$enginePayload = [Convert]::ToBase64String([IO.File]::ReadAllBytes($enginePath)) -$containerInput = $enginePayload + "`n" + $manifest -$command = ' -$ErrorActionPreference = "Stop" -$enginePath = Join-Path ([IO.Path]::GetTempPath()) ("csrun-release-" + [guid]::NewGuid().ToString("N") + ".ps1") -$engineBytes = [Convert]::FromBase64String([Console]::In.ReadLine()) -[IO.File]::WriteAllBytes($enginePath, $engineBytes) -$manifest = [Console]::In.ReadToEnd() -& $enginePath -ManifestJson $manifest -exit $LASTEXITCODE -' -$output = (@($containerInput | & docker run --rm -i --entrypoint pwsh 'codebeltnet/csrun:10' -NoProfile -NonInteractive -Command $command) -join [Environment]::NewLine) -$process = [pscustomobject]@{ ExitCode = $LASTEXITCODE } -$diagnostics = '' -Write-Output $output -} catch { - [Console]::Error.WriteLine("csrun diagnostics retained in: $engineDirectory") - throw -} finally { - $resolvedTemp = [IO.Path]::TrimEndingDirectorySeparator([IO.Path]::GetFullPath([IO.Path]::GetTempPath())) - $resolvedEngineDirectory = [IO.Path]::GetFullPath($engineDirectory) - if ([IO.Path]::GetDirectoryName($resolvedEngineDirectory) -ne $resolvedTemp -or - [IO.Path]::GetFileName($resolvedEngineDirectory) -cnotmatch '^csrun-[a-f0-9]{32}$') { throw 'Unsafe cleanup path.' } - if ($process -and $process.ExitCode -eq 0) { Remove-Item -LiteralPath $resolvedEngineDirectory -Recurse -Force } -} -if ($process.ExitCode -ne 0) { throw "csrun execution failed with exit code $($process.ExitCode). $diagnostics" } -if ($verifyTests) { Assert-CsrunTestOutput $output } -} \ No newline at end of file diff --git a/.docfx/run-actions/dd2fa1a038dbc1220b366a53/native.ps1 b/.docfx/run-actions/dd2fa1a038dbc1220b366a53/native.ps1 deleted file mode 100644 index 219cd22..0000000 --- a/.docfx/run-actions/dd2fa1a038dbc1220b366a53/native.ps1 +++ /dev/null @@ -1,89 +0,0 @@ -& { -#requires -Version 7.0 -$ErrorActionPreference = 'Stop' -$PSNativeCommandUseErrorActionPreference = $false -$manifest = @' -{ - "dependsOn": [ - "Codebelt.Extensions.Xunit.Hosting.AspNetCore@13.0.0", - "Microsoft.Extensions.Hosting@10.0.15", - "xunit.v3@4.0.3" - ], - "framework": "net10.0", - "frameworkReferences": [ - "Microsoft.AspNetCore.App" - ], - "mode": "test", - "schemaVersion": 1, - "source": "using Codebelt.Extensions.Xunit.Hosting.AspNetCore;\nusing Xunit;\n\nnamespace WebFixtureTests;\n\npublic class WebMinimalHostStateGuard\n{\n public bool EnsureFixtureIsReady(IWebMinimalHostFixture fixture)\n {\n return fixture.HasValidState();\n }\n}\n\npublic sealed class RunExample\n{\n [Fact]\n public void ExercisesExample()\n {\n using var fixture = new ManagedWebMinimalHostFixture();\n Assert.False(new WebMinimalHostStateGuard().EnsureFixtureIsReady(fixture));\n using var app = MinimalWebHostTestFactory.Create(hostFixture: fixture);\n Assert.True(new WebMinimalHostStateGuard().EnsureFixtureIsReady(fixture));\n }\n}" -} -'@ -$OutputEncoding = [Text.UTF8Encoding]::new($false) -[Console]::OutputEncoding = $OutputEncoding -$verifyTests = $true -function Assert-CsrunTestOutput([string] $Output) { - $lines = @($Output -split '\r?\n') - $headers = @($lines | Where-Object { $_ -match '^Test run summary: Passed! - .+\)$' }) - if ($headers.Count -ne 1) { throw 'Expected exactly one completed xUnit test summary.' } - $headerIndex = [Array]::IndexOf($lines, $headers[0]) - $summaryLines = @($lines | Select-Object -Skip ($headerIndex + 1) -First 4) - $counts = @{} - foreach ($line in $summaryLines) { - if ($line -match '^\s*(total|failed|succeeded|skipped):\s*(\d+)\s*$') { $counts[$Matches[1]] = [int]$Matches[2] } - } - if ($counts.Count -ne 4) { throw 'The xUnit test summary counts are incomplete or ambiguous.' } - $failed = $counts.failed - $passed = $counts.succeeded - $skipped = $counts.skipped - $total = $counts.total - if ($total -lt 1 -or $passed -lt 1 -or $failed -ne 0 -or $skipped -ne 0 -or $passed -ne $total) { - throw 'Tests must execute at least once, all pass, and none fail or skip.' - } -} -# Downloads and executes the latest stable csrun release with your permissions. -# Source and release history: https://github.com/codebeltnet/csrun -$engineDirectory = Join-Path ([IO.Path]::GetTempPath()) ('csrun-' + [guid]::NewGuid().ToString('N')) -$null = New-Item -ItemType Directory -Path $engineDirectory -$enginePath = Join-Path $engineDirectory 'csrun.ps1' -$process = $null -try { - $release = Invoke-RestMethod 'https://api.github.com/repos/codebeltnet/csrun/releases/latest' - $assets = @($release.assets | Where-Object name -CEQ 'csrun.ps1') - if ($assets.Count -ne 1 -or $assets[0].digest -notmatch '^sha256:[0-9a-f]{64}$') { - throw "csrun release $($release.tag_name) must publish one csrun.ps1 asset with a SHA-256 digest." - } - $asset = $assets[0] - Invoke-WebRequest $asset.browser_download_url -OutFile $enginePath - $actualHash = (Get-FileHash -LiteralPath $enginePath -Algorithm SHA256).Hash - if ("sha256:$actualHash" -ne $asset.digest) { throw "csrun asset checksum mismatch: $actualHash" } -$startInfo = [Diagnostics.ProcessStartInfo]::new('pwsh') -foreach ($argument in @('-NoProfile','-NonInteractive','-File')) { $startInfo.ArgumentList.Add($argument) } -$startInfo.ArgumentList.Add($enginePath) -$startInfo.ArgumentList.Add('-ManifestJson') -$startInfo.ArgumentList.Add($manifest) -$startInfo.RedirectStandardOutput = $true -$startInfo.RedirectStandardError = $true -$startInfo.UseShellExecute = $false -$process = [Diagnostics.Process]::new() -$process.StartInfo = $startInfo -if (-not $process.Start()) { throw 'Could not start csrun.' } -$stdoutTask = $process.StandardOutput.ReadToEndAsync() -$stderrTask = $process.StandardError.ReadToEndAsync() -$process.WaitForExit() -$output = $stdoutTask.GetAwaiter().GetResult() -$diagnostics = $stderrTask.GetAwaiter().GetResult() -Write-Output $output -if ($diagnostics) { [Console]::Error.Write($diagnostics) } -} catch { - [Console]::Error.WriteLine("csrun diagnostics retained in: $engineDirectory") - throw -} finally { - $resolvedTemp = [IO.Path]::TrimEndingDirectorySeparator([IO.Path]::GetFullPath([IO.Path]::GetTempPath())) - $resolvedEngineDirectory = [IO.Path]::GetFullPath($engineDirectory) - if ([IO.Path]::GetDirectoryName($resolvedEngineDirectory) -ne $resolvedTemp -or - [IO.Path]::GetFileName($resolvedEngineDirectory) -cnotmatch '^csrun-[a-f0-9]{32}$') { throw 'Unsafe cleanup path.' } - if ($process -and $process.ExitCode -eq 0) { Remove-Item -LiteralPath $resolvedEngineDirectory -Recurse -Force } -} -if ($process.ExitCode -ne 0) { throw "csrun execution failed with exit code $($process.ExitCode). $diagnostics" } -if ($verifyTests) { Assert-CsrunTestOutput $output } -} \ No newline at end of file diff --git a/.docfx/run-actions/dfdd064179bf4643e1a0b2bf/docker.ps1 b/.docfx/run-actions/dfdd064179bf4643e1a0b2bf/docker.ps1 deleted file mode 100644 index 2447606..0000000 --- a/.docfx/run-actions/dfdd064179bf4643e1a0b2bf/docker.ps1 +++ /dev/null @@ -1,86 +0,0 @@ -& { -#requires -Version 7.0 -$ErrorActionPreference = 'Stop' -$PSNativeCommandUseErrorActionPreference = $false -$manifest = @' -{ - "dependsOn": [ - "Codebelt.Extensions.Xunit.Hosting.AspNetCore@13.0.0", - "Microsoft.Extensions.Hosting@10.0.15", - "xunit.v3@4.0.3" - ], - "framework": "net10.0", - "frameworkReferences": [ - "Microsoft.AspNetCore.App" - ], - "mode": "test", - "schemaVersion": 1, - "source": "using Codebelt.Extensions.Xunit.Hosting.AspNetCore;\nusing Xunit;\n\nnamespace WebFixtureTests;\n\npublic class WebHostStateGuard\n{\n public bool EnsureFixtureIsReady(IWebHostFixture fixture)\n {\n return fixture.HasValidState();\n }\n}\n\npublic sealed class RunExample\n{\n [Fact]\n public void ExercisesExample()\n {\n using var fixture = new ManagedWebHostFixture();\n Assert.False(new WebHostStateGuard().EnsureFixtureIsReady(fixture));\n using var app = WebHostTestFactory.Create(hostFixture: fixture);\n Assert.True(new WebHostStateGuard().EnsureFixtureIsReady(fixture));\n }\n}" -} -'@ -$OutputEncoding = [Text.UTF8Encoding]::new($false) -[Console]::OutputEncoding = $OutputEncoding -$verifyTests = $true -function Assert-CsrunTestOutput([string] $Output) { - $lines = @($Output -split '\r?\n') - $headers = @($lines | Where-Object { $_ -match '^Test run summary: Passed! - .+\)$' }) - if ($headers.Count -ne 1) { throw 'Expected exactly one completed xUnit test summary.' } - $headerIndex = [Array]::IndexOf($lines, $headers[0]) - $summaryLines = @($lines | Select-Object -Skip ($headerIndex + 1) -First 4) - $counts = @{} - foreach ($line in $summaryLines) { - if ($line -match '^\s*(total|failed|succeeded|skipped):\s*(\d+)\s*$') { $counts[$Matches[1]] = [int]$Matches[2] } - } - if ($counts.Count -ne 4) { throw 'The xUnit test summary counts are incomplete or ambiguous.' } - $failed = $counts.failed - $passed = $counts.succeeded - $skipped = $counts.skipped - $total = $counts.total - if ($total -lt 1 -or $passed -lt 1 -or $failed -ne 0 -or $skipped -ne 0 -or $passed -ne $total) { - throw 'Tests must execute at least once, all pass, and none fail or skip.' - } -} -# Downloads and executes the latest stable csrun release with your permissions. -# Source and release history: https://github.com/codebeltnet/csrun -$engineDirectory = Join-Path ([IO.Path]::GetTempPath()) ('csrun-' + [guid]::NewGuid().ToString('N')) -$null = New-Item -ItemType Directory -Path $engineDirectory -$enginePath = Join-Path $engineDirectory 'csrun.ps1' -$process = $null -try { - $release = Invoke-RestMethod 'https://api.github.com/repos/codebeltnet/csrun/releases/latest' - $assets = @($release.assets | Where-Object name -CEQ 'csrun.ps1') - if ($assets.Count -ne 1 -or $assets[0].digest -notmatch '^sha256:[0-9a-f]{64}$') { - throw "csrun release $($release.tag_name) must publish one csrun.ps1 asset with a SHA-256 digest." - } - $asset = $assets[0] - Invoke-WebRequest $asset.browser_download_url -OutFile $enginePath - $actualHash = (Get-FileHash -LiteralPath $enginePath -Algorithm SHA256).Hash - if ("sha256:$actualHash" -ne $asset.digest) { throw "csrun asset checksum mismatch: $actualHash" } -$enginePayload = [Convert]::ToBase64String([IO.File]::ReadAllBytes($enginePath)) -$containerInput = $enginePayload + "`n" + $manifest -$command = ' -$ErrorActionPreference = "Stop" -$enginePath = Join-Path ([IO.Path]::GetTempPath()) ("csrun-release-" + [guid]::NewGuid().ToString("N") + ".ps1") -$engineBytes = [Convert]::FromBase64String([Console]::In.ReadLine()) -[IO.File]::WriteAllBytes($enginePath, $engineBytes) -$manifest = [Console]::In.ReadToEnd() -& $enginePath -ManifestJson $manifest -exit $LASTEXITCODE -' -$output = (@($containerInput | & docker run --rm -i --entrypoint pwsh 'codebeltnet/csrun:10' -NoProfile -NonInteractive -Command $command) -join [Environment]::NewLine) -$process = [pscustomobject]@{ ExitCode = $LASTEXITCODE } -$diagnostics = '' -Write-Output $output -} catch { - [Console]::Error.WriteLine("csrun diagnostics retained in: $engineDirectory") - throw -} finally { - $resolvedTemp = [IO.Path]::TrimEndingDirectorySeparator([IO.Path]::GetFullPath([IO.Path]::GetTempPath())) - $resolvedEngineDirectory = [IO.Path]::GetFullPath($engineDirectory) - if ([IO.Path]::GetDirectoryName($resolvedEngineDirectory) -ne $resolvedTemp -or - [IO.Path]::GetFileName($resolvedEngineDirectory) -cnotmatch '^csrun-[a-f0-9]{32}$') { throw 'Unsafe cleanup path.' } - if ($process -and $process.ExitCode -eq 0) { Remove-Item -LiteralPath $resolvedEngineDirectory -Recurse -Force } -} -if ($process.ExitCode -ne 0) { throw "csrun execution failed with exit code $($process.ExitCode). $diagnostics" } -if ($verifyTests) { Assert-CsrunTestOutput $output } -} \ No newline at end of file diff --git a/.docfx/run-actions/dfdd064179bf4643e1a0b2bf/native.ps1 b/.docfx/run-actions/dfdd064179bf4643e1a0b2bf/native.ps1 deleted file mode 100644 index 62c8531..0000000 --- a/.docfx/run-actions/dfdd064179bf4643e1a0b2bf/native.ps1 +++ /dev/null @@ -1,89 +0,0 @@ -& { -#requires -Version 7.0 -$ErrorActionPreference = 'Stop' -$PSNativeCommandUseErrorActionPreference = $false -$manifest = @' -{ - "dependsOn": [ - "Codebelt.Extensions.Xunit.Hosting.AspNetCore@13.0.0", - "Microsoft.Extensions.Hosting@10.0.15", - "xunit.v3@4.0.3" - ], - "framework": "net10.0", - "frameworkReferences": [ - "Microsoft.AspNetCore.App" - ], - "mode": "test", - "schemaVersion": 1, - "source": "using Codebelt.Extensions.Xunit.Hosting.AspNetCore;\nusing Xunit;\n\nnamespace WebFixtureTests;\n\npublic class WebHostStateGuard\n{\n public bool EnsureFixtureIsReady(IWebHostFixture fixture)\n {\n return fixture.HasValidState();\n }\n}\n\npublic sealed class RunExample\n{\n [Fact]\n public void ExercisesExample()\n {\n using var fixture = new ManagedWebHostFixture();\n Assert.False(new WebHostStateGuard().EnsureFixtureIsReady(fixture));\n using var app = WebHostTestFactory.Create(hostFixture: fixture);\n Assert.True(new WebHostStateGuard().EnsureFixtureIsReady(fixture));\n }\n}" -} -'@ -$OutputEncoding = [Text.UTF8Encoding]::new($false) -[Console]::OutputEncoding = $OutputEncoding -$verifyTests = $true -function Assert-CsrunTestOutput([string] $Output) { - $lines = @($Output -split '\r?\n') - $headers = @($lines | Where-Object { $_ -match '^Test run summary: Passed! - .+\)$' }) - if ($headers.Count -ne 1) { throw 'Expected exactly one completed xUnit test summary.' } - $headerIndex = [Array]::IndexOf($lines, $headers[0]) - $summaryLines = @($lines | Select-Object -Skip ($headerIndex + 1) -First 4) - $counts = @{} - foreach ($line in $summaryLines) { - if ($line -match '^\s*(total|failed|succeeded|skipped):\s*(\d+)\s*$') { $counts[$Matches[1]] = [int]$Matches[2] } - } - if ($counts.Count -ne 4) { throw 'The xUnit test summary counts are incomplete or ambiguous.' } - $failed = $counts.failed - $passed = $counts.succeeded - $skipped = $counts.skipped - $total = $counts.total - if ($total -lt 1 -or $passed -lt 1 -or $failed -ne 0 -or $skipped -ne 0 -or $passed -ne $total) { - throw 'Tests must execute at least once, all pass, and none fail or skip.' - } -} -# Downloads and executes the latest stable csrun release with your permissions. -# Source and release history: https://github.com/codebeltnet/csrun -$engineDirectory = Join-Path ([IO.Path]::GetTempPath()) ('csrun-' + [guid]::NewGuid().ToString('N')) -$null = New-Item -ItemType Directory -Path $engineDirectory -$enginePath = Join-Path $engineDirectory 'csrun.ps1' -$process = $null -try { - $release = Invoke-RestMethod 'https://api.github.com/repos/codebeltnet/csrun/releases/latest' - $assets = @($release.assets | Where-Object name -CEQ 'csrun.ps1') - if ($assets.Count -ne 1 -or $assets[0].digest -notmatch '^sha256:[0-9a-f]{64}$') { - throw "csrun release $($release.tag_name) must publish one csrun.ps1 asset with a SHA-256 digest." - } - $asset = $assets[0] - Invoke-WebRequest $asset.browser_download_url -OutFile $enginePath - $actualHash = (Get-FileHash -LiteralPath $enginePath -Algorithm SHA256).Hash - if ("sha256:$actualHash" -ne $asset.digest) { throw "csrun asset checksum mismatch: $actualHash" } -$startInfo = [Diagnostics.ProcessStartInfo]::new('pwsh') -foreach ($argument in @('-NoProfile','-NonInteractive','-File')) { $startInfo.ArgumentList.Add($argument) } -$startInfo.ArgumentList.Add($enginePath) -$startInfo.ArgumentList.Add('-ManifestJson') -$startInfo.ArgumentList.Add($manifest) -$startInfo.RedirectStandardOutput = $true -$startInfo.RedirectStandardError = $true -$startInfo.UseShellExecute = $false -$process = [Diagnostics.Process]::new() -$process.StartInfo = $startInfo -if (-not $process.Start()) { throw 'Could not start csrun.' } -$stdoutTask = $process.StandardOutput.ReadToEndAsync() -$stderrTask = $process.StandardError.ReadToEndAsync() -$process.WaitForExit() -$output = $stdoutTask.GetAwaiter().GetResult() -$diagnostics = $stderrTask.GetAwaiter().GetResult() -Write-Output $output -if ($diagnostics) { [Console]::Error.Write($diagnostics) } -} catch { - [Console]::Error.WriteLine("csrun diagnostics retained in: $engineDirectory") - throw -} finally { - $resolvedTemp = [IO.Path]::TrimEndingDirectorySeparator([IO.Path]::GetFullPath([IO.Path]::GetTempPath())) - $resolvedEngineDirectory = [IO.Path]::GetFullPath($engineDirectory) - if ([IO.Path]::GetDirectoryName($resolvedEngineDirectory) -ne $resolvedTemp -or - [IO.Path]::GetFileName($resolvedEngineDirectory) -cnotmatch '^csrun-[a-f0-9]{32}$') { throw 'Unsafe cleanup path.' } - if ($process -and $process.ExitCode -eq 0) { Remove-Item -LiteralPath $resolvedEngineDirectory -Recurse -Force } -} -if ($process.ExitCode -ne 0) { throw "csrun execution failed with exit code $($process.ExitCode). $diagnostics" } -if ($verifyTests) { Assert-CsrunTestOutput $output } -} \ No newline at end of file diff --git a/.docfx/run-actions/e3f79d1c0f2fa85276cee2fb/docker.ps1 b/.docfx/run-actions/e3f79d1c0f2fa85276cee2fb/docker.ps1 deleted file mode 100644 index b68f80f..0000000 --- a/.docfx/run-actions/e3f79d1c0f2fa85276cee2fb/docker.ps1 +++ /dev/null @@ -1,82 +0,0 @@ -& { -#requires -Version 7.0 -$ErrorActionPreference = 'Stop' -$PSNativeCommandUseErrorActionPreference = $false -$manifest = @' -{ - "dependsOn": [ - "Codebelt.Extensions.Xunit.Hosting@13.0.0", - "Microsoft.Extensions.Hosting@10.0.15" - ], - "framework": "net10.0", - "mode": "console", - "schemaVersion": 1, - "source": "using System;\nusing Codebelt.Extensions.Xunit.Hosting;\nusing Microsoft.Extensions.DependencyInjection;\n\nnamespace HostFixtureTests;\n\npublic class MinimalHostFactoryExample\n{\n public void Demonstrate()\n {\n using var host = MinimalHostTestFactory.Create(\n services => services.AddSingleton(new Version(1, 0, 0)));\n var version = host.Host.Services.GetRequiredService();\n Console.WriteLine(version);\n }\n}\n\ninternal static class RunExample\n{\n static void Main()\n {\n new MinimalHostFactoryExample().Demonstrate();\n }\n}" -} -'@ -$OutputEncoding = [Text.UTF8Encoding]::new($false) -[Console]::OutputEncoding = $OutputEncoding -$verifyTests = $false -function Assert-CsrunTestOutput([string] $Output) { - $lines = @($Output -split '\r?\n') - $headers = @($lines | Where-Object { $_ -match '^Test run summary: Passed! - .+\)$' }) - if ($headers.Count -ne 1) { throw 'Expected exactly one completed xUnit test summary.' } - $headerIndex = [Array]::IndexOf($lines, $headers[0]) - $summaryLines = @($lines | Select-Object -Skip ($headerIndex + 1) -First 4) - $counts = @{} - foreach ($line in $summaryLines) { - if ($line -match '^\s*(total|failed|succeeded|skipped):\s*(\d+)\s*$') { $counts[$Matches[1]] = [int]$Matches[2] } - } - if ($counts.Count -ne 4) { throw 'The xUnit test summary counts are incomplete or ambiguous.' } - $failed = $counts.failed - $passed = $counts.succeeded - $skipped = $counts.skipped - $total = $counts.total - if ($total -lt 1 -or $passed -lt 1 -or $failed -ne 0 -or $skipped -ne 0 -or $passed -ne $total) { - throw 'Tests must execute at least once, all pass, and none fail or skip.' - } -} -# Downloads and executes the latest stable csrun release with your permissions. -# Source and release history: https://github.com/codebeltnet/csrun -$engineDirectory = Join-Path ([IO.Path]::GetTempPath()) ('csrun-' + [guid]::NewGuid().ToString('N')) -$null = New-Item -ItemType Directory -Path $engineDirectory -$enginePath = Join-Path $engineDirectory 'csrun.ps1' -$process = $null -try { - $release = Invoke-RestMethod 'https://api.github.com/repos/codebeltnet/csrun/releases/latest' - $assets = @($release.assets | Where-Object name -CEQ 'csrun.ps1') - if ($assets.Count -ne 1 -or $assets[0].digest -notmatch '^sha256:[0-9a-f]{64}$') { - throw "csrun release $($release.tag_name) must publish one csrun.ps1 asset with a SHA-256 digest." - } - $asset = $assets[0] - Invoke-WebRequest $asset.browser_download_url -OutFile $enginePath - $actualHash = (Get-FileHash -LiteralPath $enginePath -Algorithm SHA256).Hash - if ("sha256:$actualHash" -ne $asset.digest) { throw "csrun asset checksum mismatch: $actualHash" } -$enginePayload = [Convert]::ToBase64String([IO.File]::ReadAllBytes($enginePath)) -$containerInput = $enginePayload + "`n" + $manifest -$command = ' -$ErrorActionPreference = "Stop" -$enginePath = Join-Path ([IO.Path]::GetTempPath()) ("csrun-release-" + [guid]::NewGuid().ToString("N") + ".ps1") -$engineBytes = [Convert]::FromBase64String([Console]::In.ReadLine()) -[IO.File]::WriteAllBytes($enginePath, $engineBytes) -$manifest = [Console]::In.ReadToEnd() -& $enginePath -ManifestJson $manifest -exit $LASTEXITCODE -' -$output = (@($containerInput | & docker run --rm -i --entrypoint pwsh 'codebeltnet/csrun:10' -NoProfile -NonInteractive -Command $command) -join [Environment]::NewLine) -$process = [pscustomobject]@{ ExitCode = $LASTEXITCODE } -$diagnostics = '' -Write-Output $output -} catch { - [Console]::Error.WriteLine("csrun diagnostics retained in: $engineDirectory") - throw -} finally { - $resolvedTemp = [IO.Path]::TrimEndingDirectorySeparator([IO.Path]::GetFullPath([IO.Path]::GetTempPath())) - $resolvedEngineDirectory = [IO.Path]::GetFullPath($engineDirectory) - if ([IO.Path]::GetDirectoryName($resolvedEngineDirectory) -ne $resolvedTemp -or - [IO.Path]::GetFileName($resolvedEngineDirectory) -cnotmatch '^csrun-[a-f0-9]{32}$') { throw 'Unsafe cleanup path.' } - if ($process -and $process.ExitCode -eq 0) { Remove-Item -LiteralPath $resolvedEngineDirectory -Recurse -Force } -} -if ($process.ExitCode -ne 0) { throw "csrun execution failed with exit code $($process.ExitCode). $diagnostics" } -if ($verifyTests) { Assert-CsrunTestOutput $output } -} \ No newline at end of file diff --git a/.docfx/run-actions/e3f79d1c0f2fa85276cee2fb/native.ps1 b/.docfx/run-actions/e3f79d1c0f2fa85276cee2fb/native.ps1 deleted file mode 100644 index bf8e874..0000000 --- a/.docfx/run-actions/e3f79d1c0f2fa85276cee2fb/native.ps1 +++ /dev/null @@ -1,85 +0,0 @@ -& { -#requires -Version 7.0 -$ErrorActionPreference = 'Stop' -$PSNativeCommandUseErrorActionPreference = $false -$manifest = @' -{ - "dependsOn": [ - "Codebelt.Extensions.Xunit.Hosting@13.0.0", - "Microsoft.Extensions.Hosting@10.0.15" - ], - "framework": "net10.0", - "mode": "console", - "schemaVersion": 1, - "source": "using System;\nusing Codebelt.Extensions.Xunit.Hosting;\nusing Microsoft.Extensions.DependencyInjection;\n\nnamespace HostFixtureTests;\n\npublic class MinimalHostFactoryExample\n{\n public void Demonstrate()\n {\n using var host = MinimalHostTestFactory.Create(\n services => services.AddSingleton(new Version(1, 0, 0)));\n var version = host.Host.Services.GetRequiredService();\n Console.WriteLine(version);\n }\n}\n\ninternal static class RunExample\n{\n static void Main()\n {\n new MinimalHostFactoryExample().Demonstrate();\n }\n}" -} -'@ -$OutputEncoding = [Text.UTF8Encoding]::new($false) -[Console]::OutputEncoding = $OutputEncoding -$verifyTests = $false -function Assert-CsrunTestOutput([string] $Output) { - $lines = @($Output -split '\r?\n') - $headers = @($lines | Where-Object { $_ -match '^Test run summary: Passed! - .+\)$' }) - if ($headers.Count -ne 1) { throw 'Expected exactly one completed xUnit test summary.' } - $headerIndex = [Array]::IndexOf($lines, $headers[0]) - $summaryLines = @($lines | Select-Object -Skip ($headerIndex + 1) -First 4) - $counts = @{} - foreach ($line in $summaryLines) { - if ($line -match '^\s*(total|failed|succeeded|skipped):\s*(\d+)\s*$') { $counts[$Matches[1]] = [int]$Matches[2] } - } - if ($counts.Count -ne 4) { throw 'The xUnit test summary counts are incomplete or ambiguous.' } - $failed = $counts.failed - $passed = $counts.succeeded - $skipped = $counts.skipped - $total = $counts.total - if ($total -lt 1 -or $passed -lt 1 -or $failed -ne 0 -or $skipped -ne 0 -or $passed -ne $total) { - throw 'Tests must execute at least once, all pass, and none fail or skip.' - } -} -# Downloads and executes the latest stable csrun release with your permissions. -# Source and release history: https://github.com/codebeltnet/csrun -$engineDirectory = Join-Path ([IO.Path]::GetTempPath()) ('csrun-' + [guid]::NewGuid().ToString('N')) -$null = New-Item -ItemType Directory -Path $engineDirectory -$enginePath = Join-Path $engineDirectory 'csrun.ps1' -$process = $null -try { - $release = Invoke-RestMethod 'https://api.github.com/repos/codebeltnet/csrun/releases/latest' - $assets = @($release.assets | Where-Object name -CEQ 'csrun.ps1') - if ($assets.Count -ne 1 -or $assets[0].digest -notmatch '^sha256:[0-9a-f]{64}$') { - throw "csrun release $($release.tag_name) must publish one csrun.ps1 asset with a SHA-256 digest." - } - $asset = $assets[0] - Invoke-WebRequest $asset.browser_download_url -OutFile $enginePath - $actualHash = (Get-FileHash -LiteralPath $enginePath -Algorithm SHA256).Hash - if ("sha256:$actualHash" -ne $asset.digest) { throw "csrun asset checksum mismatch: $actualHash" } -$startInfo = [Diagnostics.ProcessStartInfo]::new('pwsh') -foreach ($argument in @('-NoProfile','-NonInteractive','-File')) { $startInfo.ArgumentList.Add($argument) } -$startInfo.ArgumentList.Add($enginePath) -$startInfo.ArgumentList.Add('-ManifestJson') -$startInfo.ArgumentList.Add($manifest) -$startInfo.RedirectStandardOutput = $true -$startInfo.RedirectStandardError = $true -$startInfo.UseShellExecute = $false -$process = [Diagnostics.Process]::new() -$process.StartInfo = $startInfo -if (-not $process.Start()) { throw 'Could not start csrun.' } -$stdoutTask = $process.StandardOutput.ReadToEndAsync() -$stderrTask = $process.StandardError.ReadToEndAsync() -$process.WaitForExit() -$output = $stdoutTask.GetAwaiter().GetResult() -$diagnostics = $stderrTask.GetAwaiter().GetResult() -Write-Output $output -if ($diagnostics) { [Console]::Error.Write($diagnostics) } -} catch { - [Console]::Error.WriteLine("csrun diagnostics retained in: $engineDirectory") - throw -} finally { - $resolvedTemp = [IO.Path]::TrimEndingDirectorySeparator([IO.Path]::GetFullPath([IO.Path]::GetTempPath())) - $resolvedEngineDirectory = [IO.Path]::GetFullPath($engineDirectory) - if ([IO.Path]::GetDirectoryName($resolvedEngineDirectory) -ne $resolvedTemp -or - [IO.Path]::GetFileName($resolvedEngineDirectory) -cnotmatch '^csrun-[a-f0-9]{32}$') { throw 'Unsafe cleanup path.' } - if ($process -and $process.ExitCode -eq 0) { Remove-Item -LiteralPath $resolvedEngineDirectory -Recurse -Force } -} -if ($process.ExitCode -ne 0) { throw "csrun execution failed with exit code $($process.ExitCode). $diagnostics" } -if ($verifyTests) { Assert-CsrunTestOutput $output } -} \ No newline at end of file diff --git a/.docfx/run-actions/e7dbb5ba733b205469239b03/docker.ps1 b/.docfx/run-actions/e7dbb5ba733b205469239b03/docker.ps1 deleted file mode 100644 index d9e9557..0000000 --- a/.docfx/run-actions/e7dbb5ba733b205469239b03/docker.ps1 +++ /dev/null @@ -1,83 +0,0 @@ -& { -#requires -Version 7.0 -$ErrorActionPreference = 'Stop' -$PSNativeCommandUseErrorActionPreference = $false -$manifest = @' -{ - "dependsOn": [ - "Codebelt.Extensions.Xunit.Hosting@13.0.0", - "Microsoft.Extensions.Hosting@10.0.15", - "xunit.v3@4.0.3" - ], - "framework": "net10.0", - "mode": "test", - "schemaVersion": 1, - "source": "using Codebelt.Extensions.Xunit.Hosting;\nusing Xunit;\n\nnamespace HostFixtureTests;\n\npublic class HostStateGuard\n{\n public bool EnsureFixtureIsReady(IApplicationFixture fixture) where TEntryPoint : class\n {\n return fixture.HasValidState();\n }\n}\n\npublic sealed class RunExample\n{\n [Fact]\n public void ExercisesExample()\n {\n using var fixture = new ManagedApplicationFixture();\n Assert.False(new HostStateGuard().EnsureFixtureIsReady(fixture));\n }\n}" -} -'@ -$OutputEncoding = [Text.UTF8Encoding]::new($false) -[Console]::OutputEncoding = $OutputEncoding -$verifyTests = $true -function Assert-CsrunTestOutput([string] $Output) { - $lines = @($Output -split '\r?\n') - $headers = @($lines | Where-Object { $_ -match '^Test run summary: Passed! - .+\)$' }) - if ($headers.Count -ne 1) { throw 'Expected exactly one completed xUnit test summary.' } - $headerIndex = [Array]::IndexOf($lines, $headers[0]) - $summaryLines = @($lines | Select-Object -Skip ($headerIndex + 1) -First 4) - $counts = @{} - foreach ($line in $summaryLines) { - if ($line -match '^\s*(total|failed|succeeded|skipped):\s*(\d+)\s*$') { $counts[$Matches[1]] = [int]$Matches[2] } - } - if ($counts.Count -ne 4) { throw 'The xUnit test summary counts are incomplete or ambiguous.' } - $failed = $counts.failed - $passed = $counts.succeeded - $skipped = $counts.skipped - $total = $counts.total - if ($total -lt 1 -or $passed -lt 1 -or $failed -ne 0 -or $skipped -ne 0 -or $passed -ne $total) { - throw 'Tests must execute at least once, all pass, and none fail or skip.' - } -} -# Downloads and executes the latest stable csrun release with your permissions. -# Source and release history: https://github.com/codebeltnet/csrun -$engineDirectory = Join-Path ([IO.Path]::GetTempPath()) ('csrun-' + [guid]::NewGuid().ToString('N')) -$null = New-Item -ItemType Directory -Path $engineDirectory -$enginePath = Join-Path $engineDirectory 'csrun.ps1' -$process = $null -try { - $release = Invoke-RestMethod 'https://api.github.com/repos/codebeltnet/csrun/releases/latest' - $assets = @($release.assets | Where-Object name -CEQ 'csrun.ps1') - if ($assets.Count -ne 1 -or $assets[0].digest -notmatch '^sha256:[0-9a-f]{64}$') { - throw "csrun release $($release.tag_name) must publish one csrun.ps1 asset with a SHA-256 digest." - } - $asset = $assets[0] - Invoke-WebRequest $asset.browser_download_url -OutFile $enginePath - $actualHash = (Get-FileHash -LiteralPath $enginePath -Algorithm SHA256).Hash - if ("sha256:$actualHash" -ne $asset.digest) { throw "csrun asset checksum mismatch: $actualHash" } -$enginePayload = [Convert]::ToBase64String([IO.File]::ReadAllBytes($enginePath)) -$containerInput = $enginePayload + "`n" + $manifest -$command = ' -$ErrorActionPreference = "Stop" -$enginePath = Join-Path ([IO.Path]::GetTempPath()) ("csrun-release-" + [guid]::NewGuid().ToString("N") + ".ps1") -$engineBytes = [Convert]::FromBase64String([Console]::In.ReadLine()) -[IO.File]::WriteAllBytes($enginePath, $engineBytes) -$manifest = [Console]::In.ReadToEnd() -& $enginePath -ManifestJson $manifest -exit $LASTEXITCODE -' -$output = (@($containerInput | & docker run --rm -i --entrypoint pwsh 'codebeltnet/csrun:10' -NoProfile -NonInteractive -Command $command) -join [Environment]::NewLine) -$process = [pscustomobject]@{ ExitCode = $LASTEXITCODE } -$diagnostics = '' -Write-Output $output -} catch { - [Console]::Error.WriteLine("csrun diagnostics retained in: $engineDirectory") - throw -} finally { - $resolvedTemp = [IO.Path]::TrimEndingDirectorySeparator([IO.Path]::GetFullPath([IO.Path]::GetTempPath())) - $resolvedEngineDirectory = [IO.Path]::GetFullPath($engineDirectory) - if ([IO.Path]::GetDirectoryName($resolvedEngineDirectory) -ne $resolvedTemp -or - [IO.Path]::GetFileName($resolvedEngineDirectory) -cnotmatch '^csrun-[a-f0-9]{32}$') { throw 'Unsafe cleanup path.' } - if ($process -and $process.ExitCode -eq 0) { Remove-Item -LiteralPath $resolvedEngineDirectory -Recurse -Force } -} -if ($process.ExitCode -ne 0) { throw "csrun execution failed with exit code $($process.ExitCode). $diagnostics" } -if ($verifyTests) { Assert-CsrunTestOutput $output } -} \ No newline at end of file diff --git a/.docfx/run-actions/e7dbb5ba733b205469239b03/native.ps1 b/.docfx/run-actions/e7dbb5ba733b205469239b03/native.ps1 deleted file mode 100644 index f5a0163..0000000 --- a/.docfx/run-actions/e7dbb5ba733b205469239b03/native.ps1 +++ /dev/null @@ -1,86 +0,0 @@ -& { -#requires -Version 7.0 -$ErrorActionPreference = 'Stop' -$PSNativeCommandUseErrorActionPreference = $false -$manifest = @' -{ - "dependsOn": [ - "Codebelt.Extensions.Xunit.Hosting@13.0.0", - "Microsoft.Extensions.Hosting@10.0.15", - "xunit.v3@4.0.3" - ], - "framework": "net10.0", - "mode": "test", - "schemaVersion": 1, - "source": "using Codebelt.Extensions.Xunit.Hosting;\nusing Xunit;\n\nnamespace HostFixtureTests;\n\npublic class HostStateGuard\n{\n public bool EnsureFixtureIsReady(IApplicationFixture fixture) where TEntryPoint : class\n {\n return fixture.HasValidState();\n }\n}\n\npublic sealed class RunExample\n{\n [Fact]\n public void ExercisesExample()\n {\n using var fixture = new ManagedApplicationFixture();\n Assert.False(new HostStateGuard().EnsureFixtureIsReady(fixture));\n }\n}" -} -'@ -$OutputEncoding = [Text.UTF8Encoding]::new($false) -[Console]::OutputEncoding = $OutputEncoding -$verifyTests = $true -function Assert-CsrunTestOutput([string] $Output) { - $lines = @($Output -split '\r?\n') - $headers = @($lines | Where-Object { $_ -match '^Test run summary: Passed! - .+\)$' }) - if ($headers.Count -ne 1) { throw 'Expected exactly one completed xUnit test summary.' } - $headerIndex = [Array]::IndexOf($lines, $headers[0]) - $summaryLines = @($lines | Select-Object -Skip ($headerIndex + 1) -First 4) - $counts = @{} - foreach ($line in $summaryLines) { - if ($line -match '^\s*(total|failed|succeeded|skipped):\s*(\d+)\s*$') { $counts[$Matches[1]] = [int]$Matches[2] } - } - if ($counts.Count -ne 4) { throw 'The xUnit test summary counts are incomplete or ambiguous.' } - $failed = $counts.failed - $passed = $counts.succeeded - $skipped = $counts.skipped - $total = $counts.total - if ($total -lt 1 -or $passed -lt 1 -or $failed -ne 0 -or $skipped -ne 0 -or $passed -ne $total) { - throw 'Tests must execute at least once, all pass, and none fail or skip.' - } -} -# Downloads and executes the latest stable csrun release with your permissions. -# Source and release history: https://github.com/codebeltnet/csrun -$engineDirectory = Join-Path ([IO.Path]::GetTempPath()) ('csrun-' + [guid]::NewGuid().ToString('N')) -$null = New-Item -ItemType Directory -Path $engineDirectory -$enginePath = Join-Path $engineDirectory 'csrun.ps1' -$process = $null -try { - $release = Invoke-RestMethod 'https://api.github.com/repos/codebeltnet/csrun/releases/latest' - $assets = @($release.assets | Where-Object name -CEQ 'csrun.ps1') - if ($assets.Count -ne 1 -or $assets[0].digest -notmatch '^sha256:[0-9a-f]{64}$') { - throw "csrun release $($release.tag_name) must publish one csrun.ps1 asset with a SHA-256 digest." - } - $asset = $assets[0] - Invoke-WebRequest $asset.browser_download_url -OutFile $enginePath - $actualHash = (Get-FileHash -LiteralPath $enginePath -Algorithm SHA256).Hash - if ("sha256:$actualHash" -ne $asset.digest) { throw "csrun asset checksum mismatch: $actualHash" } -$startInfo = [Diagnostics.ProcessStartInfo]::new('pwsh') -foreach ($argument in @('-NoProfile','-NonInteractive','-File')) { $startInfo.ArgumentList.Add($argument) } -$startInfo.ArgumentList.Add($enginePath) -$startInfo.ArgumentList.Add('-ManifestJson') -$startInfo.ArgumentList.Add($manifest) -$startInfo.RedirectStandardOutput = $true -$startInfo.RedirectStandardError = $true -$startInfo.UseShellExecute = $false -$process = [Diagnostics.Process]::new() -$process.StartInfo = $startInfo -if (-not $process.Start()) { throw 'Could not start csrun.' } -$stdoutTask = $process.StandardOutput.ReadToEndAsync() -$stderrTask = $process.StandardError.ReadToEndAsync() -$process.WaitForExit() -$output = $stdoutTask.GetAwaiter().GetResult() -$diagnostics = $stderrTask.GetAwaiter().GetResult() -Write-Output $output -if ($diagnostics) { [Console]::Error.Write($diagnostics) } -} catch { - [Console]::Error.WriteLine("csrun diagnostics retained in: $engineDirectory") - throw -} finally { - $resolvedTemp = [IO.Path]::TrimEndingDirectorySeparator([IO.Path]::GetFullPath([IO.Path]::GetTempPath())) - $resolvedEngineDirectory = [IO.Path]::GetFullPath($engineDirectory) - if ([IO.Path]::GetDirectoryName($resolvedEngineDirectory) -ne $resolvedTemp -or - [IO.Path]::GetFileName($resolvedEngineDirectory) -cnotmatch '^csrun-[a-f0-9]{32}$') { throw 'Unsafe cleanup path.' } - if ($process -and $process.ExitCode -eq 0) { Remove-Item -LiteralPath $resolvedEngineDirectory -Recurse -Force } -} -if ($process.ExitCode -ne 0) { throw "csrun execution failed with exit code $($process.ExitCode). $diagnostics" } -if ($verifyTests) { Assert-CsrunTestOutput $output } -} \ No newline at end of file diff --git a/.docfx/run-actions/f27f77d838407171b56f9073/docker.ps1 b/.docfx/run-actions/f27f77d838407171b56f9073/docker.ps1 deleted file mode 100644 index 9ce0032..0000000 --- a/.docfx/run-actions/f27f77d838407171b56f9073/docker.ps1 +++ /dev/null @@ -1,86 +0,0 @@ -& { -#requires -Version 7.0 -$ErrorActionPreference = 'Stop' -$PSNativeCommandUseErrorActionPreference = $false -$manifest = @' -{ - "dependsOn": [ - "Codebelt.Extensions.Xunit.Hosting.AspNetCore@13.0.0", - "Microsoft.AspNetCore.TestHost@10.0.15" - ], - "framework": "net10.0", - "frameworkReferences": [ - "Microsoft.AspNetCore.App" - ], - "mode": "console", - "schemaVersion": 1, - "sdk": "Microsoft.NET.Sdk.Web", - "source": "// Program.cs\nusing System;\nusing Codebelt.Extensions.Xunit.Hosting.AspNetCore;\nusing Microsoft.AspNetCore.Builder;\nusing Microsoft.AspNetCore.Http;\nusing Microsoft.AspNetCore.TestHost;\nusing Microsoft.Extensions.Hosting;\n\nusing var host = WebHostTestFactory.Create(\n pipelineSetup: app => app.Run(context =>\n context.Response.WriteAsync(\"started on demand\")),\n hostFixture: new SelfManagedWebHostFixture());\n\nawait host.Host.StartAsync().ConfigureAwait(false);\nusing var client = host.Host.GetTestClient();\n\nConsole.WriteLine(await client.GetStringAsync(\"/\").ConfigureAwait(false));" -} -'@ -$OutputEncoding = [Text.UTF8Encoding]::new($false) -[Console]::OutputEncoding = $OutputEncoding -$verifyTests = $false -function Assert-CsrunTestOutput([string] $Output) { - $lines = @($Output -split '\r?\n') - $headers = @($lines | Where-Object { $_ -match '^Test run summary: Passed! - .+\)$' }) - if ($headers.Count -ne 1) { throw 'Expected exactly one completed xUnit test summary.' } - $headerIndex = [Array]::IndexOf($lines, $headers[0]) - $summaryLines = @($lines | Select-Object -Skip ($headerIndex + 1) -First 4) - $counts = @{} - foreach ($line in $summaryLines) { - if ($line -match '^\s*(total|failed|succeeded|skipped):\s*(\d+)\s*$') { $counts[$Matches[1]] = [int]$Matches[2] } - } - if ($counts.Count -ne 4) { throw 'The xUnit test summary counts are incomplete or ambiguous.' } - $failed = $counts.failed - $passed = $counts.succeeded - $skipped = $counts.skipped - $total = $counts.total - if ($total -lt 1 -or $passed -lt 1 -or $failed -ne 0 -or $skipped -ne 0 -or $passed -ne $total) { - throw 'Tests must execute at least once, all pass, and none fail or skip.' - } -} -# Downloads and executes the latest stable csrun release with your permissions. -# Source and release history: https://github.com/codebeltnet/csrun -$engineDirectory = Join-Path ([IO.Path]::GetTempPath()) ('csrun-' + [guid]::NewGuid().ToString('N')) -$null = New-Item -ItemType Directory -Path $engineDirectory -$enginePath = Join-Path $engineDirectory 'csrun.ps1' -$process = $null -try { - $release = Invoke-RestMethod 'https://api.github.com/repos/codebeltnet/csrun/releases/latest' - $assets = @($release.assets | Where-Object name -CEQ 'csrun.ps1') - if ($assets.Count -ne 1 -or $assets[0].digest -notmatch '^sha256:[0-9a-f]{64}$') { - throw "csrun release $($release.tag_name) must publish one csrun.ps1 asset with a SHA-256 digest." - } - $asset = $assets[0] - Invoke-WebRequest $asset.browser_download_url -OutFile $enginePath - $actualHash = (Get-FileHash -LiteralPath $enginePath -Algorithm SHA256).Hash - if ("sha256:$actualHash" -ne $asset.digest) { throw "csrun asset checksum mismatch: $actualHash" } -$enginePayload = [Convert]::ToBase64String([IO.File]::ReadAllBytes($enginePath)) -$containerInput = $enginePayload + "`n" + $manifest -$command = ' -$ErrorActionPreference = "Stop" -$enginePath = Join-Path ([IO.Path]::GetTempPath()) ("csrun-release-" + [guid]::NewGuid().ToString("N") + ".ps1") -$engineBytes = [Convert]::FromBase64String([Console]::In.ReadLine()) -[IO.File]::WriteAllBytes($enginePath, $engineBytes) -$manifest = [Console]::In.ReadToEnd() -& $enginePath -ManifestJson $manifest -exit $LASTEXITCODE -' -$output = (@($containerInput | & docker run --rm -i --entrypoint pwsh 'codebeltnet/csrun:10' -NoProfile -NonInteractive -Command $command) -join [Environment]::NewLine) -$process = [pscustomobject]@{ ExitCode = $LASTEXITCODE } -$diagnostics = '' -Write-Output $output -} catch { - [Console]::Error.WriteLine("csrun diagnostics retained in: $engineDirectory") - throw -} finally { - $resolvedTemp = [IO.Path]::TrimEndingDirectorySeparator([IO.Path]::GetFullPath([IO.Path]::GetTempPath())) - $resolvedEngineDirectory = [IO.Path]::GetFullPath($engineDirectory) - if ([IO.Path]::GetDirectoryName($resolvedEngineDirectory) -ne $resolvedTemp -or - [IO.Path]::GetFileName($resolvedEngineDirectory) -cnotmatch '^csrun-[a-f0-9]{32}$') { throw 'Unsafe cleanup path.' } - if ($process -and $process.ExitCode -eq 0) { Remove-Item -LiteralPath $resolvedEngineDirectory -Recurse -Force } -} -if ($process.ExitCode -ne 0) { throw "csrun execution failed with exit code $($process.ExitCode). $diagnostics" } -if ($verifyTests) { Assert-CsrunTestOutput $output } -} \ No newline at end of file diff --git a/.docfx/run-actions/f27f77d838407171b56f9073/native.ps1 b/.docfx/run-actions/f27f77d838407171b56f9073/native.ps1 deleted file mode 100644 index cb8804c..0000000 --- a/.docfx/run-actions/f27f77d838407171b56f9073/native.ps1 +++ /dev/null @@ -1,89 +0,0 @@ -& { -#requires -Version 7.0 -$ErrorActionPreference = 'Stop' -$PSNativeCommandUseErrorActionPreference = $false -$manifest = @' -{ - "dependsOn": [ - "Codebelt.Extensions.Xunit.Hosting.AspNetCore@13.0.0", - "Microsoft.AspNetCore.TestHost@10.0.15" - ], - "framework": "net10.0", - "frameworkReferences": [ - "Microsoft.AspNetCore.App" - ], - "mode": "console", - "schemaVersion": 1, - "sdk": "Microsoft.NET.Sdk.Web", - "source": "// Program.cs\nusing System;\nusing Codebelt.Extensions.Xunit.Hosting.AspNetCore;\nusing Microsoft.AspNetCore.Builder;\nusing Microsoft.AspNetCore.Http;\nusing Microsoft.AspNetCore.TestHost;\nusing Microsoft.Extensions.Hosting;\n\nusing var host = WebHostTestFactory.Create(\n pipelineSetup: app => app.Run(context =>\n context.Response.WriteAsync(\"started on demand\")),\n hostFixture: new SelfManagedWebHostFixture());\n\nawait host.Host.StartAsync().ConfigureAwait(false);\nusing var client = host.Host.GetTestClient();\n\nConsole.WriteLine(await client.GetStringAsync(\"/\").ConfigureAwait(false));" -} -'@ -$OutputEncoding = [Text.UTF8Encoding]::new($false) -[Console]::OutputEncoding = $OutputEncoding -$verifyTests = $false -function Assert-CsrunTestOutput([string] $Output) { - $lines = @($Output -split '\r?\n') - $headers = @($lines | Where-Object { $_ -match '^Test run summary: Passed! - .+\)$' }) - if ($headers.Count -ne 1) { throw 'Expected exactly one completed xUnit test summary.' } - $headerIndex = [Array]::IndexOf($lines, $headers[0]) - $summaryLines = @($lines | Select-Object -Skip ($headerIndex + 1) -First 4) - $counts = @{} - foreach ($line in $summaryLines) { - if ($line -match '^\s*(total|failed|succeeded|skipped):\s*(\d+)\s*$') { $counts[$Matches[1]] = [int]$Matches[2] } - } - if ($counts.Count -ne 4) { throw 'The xUnit test summary counts are incomplete or ambiguous.' } - $failed = $counts.failed - $passed = $counts.succeeded - $skipped = $counts.skipped - $total = $counts.total - if ($total -lt 1 -or $passed -lt 1 -or $failed -ne 0 -or $skipped -ne 0 -or $passed -ne $total) { - throw 'Tests must execute at least once, all pass, and none fail or skip.' - } -} -# Downloads and executes the latest stable csrun release with your permissions. -# Source and release history: https://github.com/codebeltnet/csrun -$engineDirectory = Join-Path ([IO.Path]::GetTempPath()) ('csrun-' + [guid]::NewGuid().ToString('N')) -$null = New-Item -ItemType Directory -Path $engineDirectory -$enginePath = Join-Path $engineDirectory 'csrun.ps1' -$process = $null -try { - $release = Invoke-RestMethod 'https://api.github.com/repos/codebeltnet/csrun/releases/latest' - $assets = @($release.assets | Where-Object name -CEQ 'csrun.ps1') - if ($assets.Count -ne 1 -or $assets[0].digest -notmatch '^sha256:[0-9a-f]{64}$') { - throw "csrun release $($release.tag_name) must publish one csrun.ps1 asset with a SHA-256 digest." - } - $asset = $assets[0] - Invoke-WebRequest $asset.browser_download_url -OutFile $enginePath - $actualHash = (Get-FileHash -LiteralPath $enginePath -Algorithm SHA256).Hash - if ("sha256:$actualHash" -ne $asset.digest) { throw "csrun asset checksum mismatch: $actualHash" } -$startInfo = [Diagnostics.ProcessStartInfo]::new('pwsh') -foreach ($argument in @('-NoProfile','-NonInteractive','-File')) { $startInfo.ArgumentList.Add($argument) } -$startInfo.ArgumentList.Add($enginePath) -$startInfo.ArgumentList.Add('-ManifestJson') -$startInfo.ArgumentList.Add($manifest) -$startInfo.RedirectStandardOutput = $true -$startInfo.RedirectStandardError = $true -$startInfo.UseShellExecute = $false -$process = [Diagnostics.Process]::new() -$process.StartInfo = $startInfo -if (-not $process.Start()) { throw 'Could not start csrun.' } -$stdoutTask = $process.StandardOutput.ReadToEndAsync() -$stderrTask = $process.StandardError.ReadToEndAsync() -$process.WaitForExit() -$output = $stdoutTask.GetAwaiter().GetResult() -$diagnostics = $stderrTask.GetAwaiter().GetResult() -Write-Output $output -if ($diagnostics) { [Console]::Error.Write($diagnostics) } -} catch { - [Console]::Error.WriteLine("csrun diagnostics retained in: $engineDirectory") - throw -} finally { - $resolvedTemp = [IO.Path]::TrimEndingDirectorySeparator([IO.Path]::GetFullPath([IO.Path]::GetTempPath())) - $resolvedEngineDirectory = [IO.Path]::GetFullPath($engineDirectory) - if ([IO.Path]::GetDirectoryName($resolvedEngineDirectory) -ne $resolvedTemp -or - [IO.Path]::GetFileName($resolvedEngineDirectory) -cnotmatch '^csrun-[a-f0-9]{32}$') { throw 'Unsafe cleanup path.' } - if ($process -and $process.ExitCode -eq 0) { Remove-Item -LiteralPath $resolvedEngineDirectory -Recurse -Force } -} -if ($process.ExitCode -ne 0) { throw "csrun execution failed with exit code $($process.ExitCode). $diagnostics" } -if ($verifyTests) { Assert-CsrunTestOutput $output } -} \ No newline at end of file diff --git a/.docfx/run-actions/f3c0856195727da12ff2925f/docker.ps1 b/.docfx/run-actions/f3c0856195727da12ff2925f/docker.ps1 deleted file mode 100644 index 662bdd0..0000000 --- a/.docfx/run-actions/f3c0856195727da12ff2925f/docker.ps1 +++ /dev/null @@ -1,85 +0,0 @@ -& { -#requires -Version 7.0 -$ErrorActionPreference = 'Stop' -$PSNativeCommandUseErrorActionPreference = $false -$manifest = @' -{ - "dependsOn": [ - "Codebelt.Extensions.Xunit.Hosting.AspNetCore@13.0.0", - "xunit.v3@4.0.3" - ], - "framework": "net10.0", - "frameworkReferences": [ - "Microsoft.AspNetCore.App" - ], - "mode": "test", - "schemaVersion": 1, - "source": "using Codebelt.Extensions.Xunit.Hosting.AspNetCore;\nusing Microsoft.AspNetCore.Http;\nusing Microsoft.Extensions.DependencyInjection;\nusing Xunit;\n\nnamespace WebFixtureTests;\n\npublic class ExampleFixture\n{\n public IServiceCollection ConfigureServices(IServiceCollection services)\n {\n return services.AddFakeHttpContextAccessor(ServiceLifetime.Scoped);\n }\n}\n\npublic sealed class RunExample\n{\n [Fact]\n public void ExercisesExample()\n {\n using var provider = new ExampleFixture().ConfigureServices(new ServiceCollection()).BuildServiceProvider();\n using var scope = provider.CreateScope();\n Assert.IsType(scope.ServiceProvider.GetRequiredService());\n }\n}" -} -'@ -$OutputEncoding = [Text.UTF8Encoding]::new($false) -[Console]::OutputEncoding = $OutputEncoding -$verifyTests = $true -function Assert-CsrunTestOutput([string] $Output) { - $lines = @($Output -split '\r?\n') - $headers = @($lines | Where-Object { $_ -match '^Test run summary: Passed! - .+\)$' }) - if ($headers.Count -ne 1) { throw 'Expected exactly one completed xUnit test summary.' } - $headerIndex = [Array]::IndexOf($lines, $headers[0]) - $summaryLines = @($lines | Select-Object -Skip ($headerIndex + 1) -First 4) - $counts = @{} - foreach ($line in $summaryLines) { - if ($line -match '^\s*(total|failed|succeeded|skipped):\s*(\d+)\s*$') { $counts[$Matches[1]] = [int]$Matches[2] } - } - if ($counts.Count -ne 4) { throw 'The xUnit test summary counts are incomplete or ambiguous.' } - $failed = $counts.failed - $passed = $counts.succeeded - $skipped = $counts.skipped - $total = $counts.total - if ($total -lt 1 -or $passed -lt 1 -or $failed -ne 0 -or $skipped -ne 0 -or $passed -ne $total) { - throw 'Tests must execute at least once, all pass, and none fail or skip.' - } -} -# Downloads and executes the latest stable csrun release with your permissions. -# Source and release history: https://github.com/codebeltnet/csrun -$engineDirectory = Join-Path ([IO.Path]::GetTempPath()) ('csrun-' + [guid]::NewGuid().ToString('N')) -$null = New-Item -ItemType Directory -Path $engineDirectory -$enginePath = Join-Path $engineDirectory 'csrun.ps1' -$process = $null -try { - $release = Invoke-RestMethod 'https://api.github.com/repos/codebeltnet/csrun/releases/latest' - $assets = @($release.assets | Where-Object name -CEQ 'csrun.ps1') - if ($assets.Count -ne 1 -or $assets[0].digest -notmatch '^sha256:[0-9a-f]{64}$') { - throw "csrun release $($release.tag_name) must publish one csrun.ps1 asset with a SHA-256 digest." - } - $asset = $assets[0] - Invoke-WebRequest $asset.browser_download_url -OutFile $enginePath - $actualHash = (Get-FileHash -LiteralPath $enginePath -Algorithm SHA256).Hash - if ("sha256:$actualHash" -ne $asset.digest) { throw "csrun asset checksum mismatch: $actualHash" } -$enginePayload = [Convert]::ToBase64String([IO.File]::ReadAllBytes($enginePath)) -$containerInput = $enginePayload + "`n" + $manifest -$command = ' -$ErrorActionPreference = "Stop" -$enginePath = Join-Path ([IO.Path]::GetTempPath()) ("csrun-release-" + [guid]::NewGuid().ToString("N") + ".ps1") -$engineBytes = [Convert]::FromBase64String([Console]::In.ReadLine()) -[IO.File]::WriteAllBytes($enginePath, $engineBytes) -$manifest = [Console]::In.ReadToEnd() -& $enginePath -ManifestJson $manifest -exit $LASTEXITCODE -' -$output = (@($containerInput | & docker run --rm -i --entrypoint pwsh 'codebeltnet/csrun:10' -NoProfile -NonInteractive -Command $command) -join [Environment]::NewLine) -$process = [pscustomobject]@{ ExitCode = $LASTEXITCODE } -$diagnostics = '' -Write-Output $output -} catch { - [Console]::Error.WriteLine("csrun diagnostics retained in: $engineDirectory") - throw -} finally { - $resolvedTemp = [IO.Path]::TrimEndingDirectorySeparator([IO.Path]::GetFullPath([IO.Path]::GetTempPath())) - $resolvedEngineDirectory = [IO.Path]::GetFullPath($engineDirectory) - if ([IO.Path]::GetDirectoryName($resolvedEngineDirectory) -ne $resolvedTemp -or - [IO.Path]::GetFileName($resolvedEngineDirectory) -cnotmatch '^csrun-[a-f0-9]{32}$') { throw 'Unsafe cleanup path.' } - if ($process -and $process.ExitCode -eq 0) { Remove-Item -LiteralPath $resolvedEngineDirectory -Recurse -Force } -} -if ($process.ExitCode -ne 0) { throw "csrun execution failed with exit code $($process.ExitCode). $diagnostics" } -if ($verifyTests) { Assert-CsrunTestOutput $output } -} \ No newline at end of file diff --git a/.docfx/run-actions/f3c0856195727da12ff2925f/native.ps1 b/.docfx/run-actions/f3c0856195727da12ff2925f/native.ps1 deleted file mode 100644 index 590b9c2..0000000 --- a/.docfx/run-actions/f3c0856195727da12ff2925f/native.ps1 +++ /dev/null @@ -1,88 +0,0 @@ -& { -#requires -Version 7.0 -$ErrorActionPreference = 'Stop' -$PSNativeCommandUseErrorActionPreference = $false -$manifest = @' -{ - "dependsOn": [ - "Codebelt.Extensions.Xunit.Hosting.AspNetCore@13.0.0", - "xunit.v3@4.0.3" - ], - "framework": "net10.0", - "frameworkReferences": [ - "Microsoft.AspNetCore.App" - ], - "mode": "test", - "schemaVersion": 1, - "source": "using Codebelt.Extensions.Xunit.Hosting.AspNetCore;\nusing Microsoft.AspNetCore.Http;\nusing Microsoft.Extensions.DependencyInjection;\nusing Xunit;\n\nnamespace WebFixtureTests;\n\npublic class ExampleFixture\n{\n public IServiceCollection ConfigureServices(IServiceCollection services)\n {\n return services.AddFakeHttpContextAccessor(ServiceLifetime.Scoped);\n }\n}\n\npublic sealed class RunExample\n{\n [Fact]\n public void ExercisesExample()\n {\n using var provider = new ExampleFixture().ConfigureServices(new ServiceCollection()).BuildServiceProvider();\n using var scope = provider.CreateScope();\n Assert.IsType(scope.ServiceProvider.GetRequiredService());\n }\n}" -} -'@ -$OutputEncoding = [Text.UTF8Encoding]::new($false) -[Console]::OutputEncoding = $OutputEncoding -$verifyTests = $true -function Assert-CsrunTestOutput([string] $Output) { - $lines = @($Output -split '\r?\n') - $headers = @($lines | Where-Object { $_ -match '^Test run summary: Passed! - .+\)$' }) - if ($headers.Count -ne 1) { throw 'Expected exactly one completed xUnit test summary.' } - $headerIndex = [Array]::IndexOf($lines, $headers[0]) - $summaryLines = @($lines | Select-Object -Skip ($headerIndex + 1) -First 4) - $counts = @{} - foreach ($line in $summaryLines) { - if ($line -match '^\s*(total|failed|succeeded|skipped):\s*(\d+)\s*$') { $counts[$Matches[1]] = [int]$Matches[2] } - } - if ($counts.Count -ne 4) { throw 'The xUnit test summary counts are incomplete or ambiguous.' } - $failed = $counts.failed - $passed = $counts.succeeded - $skipped = $counts.skipped - $total = $counts.total - if ($total -lt 1 -or $passed -lt 1 -or $failed -ne 0 -or $skipped -ne 0 -or $passed -ne $total) { - throw 'Tests must execute at least once, all pass, and none fail or skip.' - } -} -# Downloads and executes the latest stable csrun release with your permissions. -# Source and release history: https://github.com/codebeltnet/csrun -$engineDirectory = Join-Path ([IO.Path]::GetTempPath()) ('csrun-' + [guid]::NewGuid().ToString('N')) -$null = New-Item -ItemType Directory -Path $engineDirectory -$enginePath = Join-Path $engineDirectory 'csrun.ps1' -$process = $null -try { - $release = Invoke-RestMethod 'https://api.github.com/repos/codebeltnet/csrun/releases/latest' - $assets = @($release.assets | Where-Object name -CEQ 'csrun.ps1') - if ($assets.Count -ne 1 -or $assets[0].digest -notmatch '^sha256:[0-9a-f]{64}$') { - throw "csrun release $($release.tag_name) must publish one csrun.ps1 asset with a SHA-256 digest." - } - $asset = $assets[0] - Invoke-WebRequest $asset.browser_download_url -OutFile $enginePath - $actualHash = (Get-FileHash -LiteralPath $enginePath -Algorithm SHA256).Hash - if ("sha256:$actualHash" -ne $asset.digest) { throw "csrun asset checksum mismatch: $actualHash" } -$startInfo = [Diagnostics.ProcessStartInfo]::new('pwsh') -foreach ($argument in @('-NoProfile','-NonInteractive','-File')) { $startInfo.ArgumentList.Add($argument) } -$startInfo.ArgumentList.Add($enginePath) -$startInfo.ArgumentList.Add('-ManifestJson') -$startInfo.ArgumentList.Add($manifest) -$startInfo.RedirectStandardOutput = $true -$startInfo.RedirectStandardError = $true -$startInfo.UseShellExecute = $false -$process = [Diagnostics.Process]::new() -$process.StartInfo = $startInfo -if (-not $process.Start()) { throw 'Could not start csrun.' } -$stdoutTask = $process.StandardOutput.ReadToEndAsync() -$stderrTask = $process.StandardError.ReadToEndAsync() -$process.WaitForExit() -$output = $stdoutTask.GetAwaiter().GetResult() -$diagnostics = $stderrTask.GetAwaiter().GetResult() -Write-Output $output -if ($diagnostics) { [Console]::Error.Write($diagnostics) } -} catch { - [Console]::Error.WriteLine("csrun diagnostics retained in: $engineDirectory") - throw -} finally { - $resolvedTemp = [IO.Path]::TrimEndingDirectorySeparator([IO.Path]::GetFullPath([IO.Path]::GetTempPath())) - $resolvedEngineDirectory = [IO.Path]::GetFullPath($engineDirectory) - if ([IO.Path]::GetDirectoryName($resolvedEngineDirectory) -ne $resolvedTemp -or - [IO.Path]::GetFileName($resolvedEngineDirectory) -cnotmatch '^csrun-[a-f0-9]{32}$') { throw 'Unsafe cleanup path.' } - if ($process -and $process.ExitCode -eq 0) { Remove-Item -LiteralPath $resolvedEngineDirectory -Recurse -Force } -} -if ($process.ExitCode -ne 0) { throw "csrun execution failed with exit code $($process.ExitCode). $diagnostics" } -if ($verifyTests) { Assert-CsrunTestOutput $output } -} \ No newline at end of file diff --git a/.docfx/run-actions/f5ed7c321a52580d7ce11408/docker.ps1 b/.docfx/run-actions/f5ed7c321a52580d7ce11408/docker.ps1 deleted file mode 100644 index 9cfda59..0000000 --- a/.docfx/run-actions/f5ed7c321a52580d7ce11408/docker.ps1 +++ /dev/null @@ -1,85 +0,0 @@ -& { -#requires -Version 7.0 -$ErrorActionPreference = 'Stop' -$PSNativeCommandUseErrorActionPreference = $false -$manifest = @' -{ - "dependsOn": [ - "Codebelt.Extensions.Xunit.Hosting.AspNetCore@13.0.0" - ], - "framework": "net10.0", - "frameworkReferences": [ - "Microsoft.AspNetCore.App" - ], - "mode": "console", - "schemaVersion": 1, - "sdk": "Microsoft.NET.Sdk.Web", - "source": "using System;\nusing Codebelt.Extensions.Xunit.Hosting.AspNetCore.Http.Features;\n\nnamespace WebFixtureTests;\n\npublic class RequestFeatureExample\n{\n public void Demonstrate()\n {\n var request = new FakeHttpRequestFeature();\n Console.WriteLine(request.Method);\n }\n}\n\ninternal static class RunExample\n{\n static void Main()\n {\n new RequestFeatureExample().Demonstrate();\n }\n}" -} -'@ -$OutputEncoding = [Text.UTF8Encoding]::new($false) -[Console]::OutputEncoding = $OutputEncoding -$verifyTests = $false -function Assert-CsrunTestOutput([string] $Output) { - $lines = @($Output -split '\r?\n') - $headers = @($lines | Where-Object { $_ -match '^Test run summary: Passed! - .+\)$' }) - if ($headers.Count -ne 1) { throw 'Expected exactly one completed xUnit test summary.' } - $headerIndex = [Array]::IndexOf($lines, $headers[0]) - $summaryLines = @($lines | Select-Object -Skip ($headerIndex + 1) -First 4) - $counts = @{} - foreach ($line in $summaryLines) { - if ($line -match '^\s*(total|failed|succeeded|skipped):\s*(\d+)\s*$') { $counts[$Matches[1]] = [int]$Matches[2] } - } - if ($counts.Count -ne 4) { throw 'The xUnit test summary counts are incomplete or ambiguous.' } - $failed = $counts.failed - $passed = $counts.succeeded - $skipped = $counts.skipped - $total = $counts.total - if ($total -lt 1 -or $passed -lt 1 -or $failed -ne 0 -or $skipped -ne 0 -or $passed -ne $total) { - throw 'Tests must execute at least once, all pass, and none fail or skip.' - } -} -# Downloads and executes the latest stable csrun release with your permissions. -# Source and release history: https://github.com/codebeltnet/csrun -$engineDirectory = Join-Path ([IO.Path]::GetTempPath()) ('csrun-' + [guid]::NewGuid().ToString('N')) -$null = New-Item -ItemType Directory -Path $engineDirectory -$enginePath = Join-Path $engineDirectory 'csrun.ps1' -$process = $null -try { - $release = Invoke-RestMethod 'https://api.github.com/repos/codebeltnet/csrun/releases/latest' - $assets = @($release.assets | Where-Object name -CEQ 'csrun.ps1') - if ($assets.Count -ne 1 -or $assets[0].digest -notmatch '^sha256:[0-9a-f]{64}$') { - throw "csrun release $($release.tag_name) must publish one csrun.ps1 asset with a SHA-256 digest." - } - $asset = $assets[0] - Invoke-WebRequest $asset.browser_download_url -OutFile $enginePath - $actualHash = (Get-FileHash -LiteralPath $enginePath -Algorithm SHA256).Hash - if ("sha256:$actualHash" -ne $asset.digest) { throw "csrun asset checksum mismatch: $actualHash" } -$enginePayload = [Convert]::ToBase64String([IO.File]::ReadAllBytes($enginePath)) -$containerInput = $enginePayload + "`n" + $manifest -$command = ' -$ErrorActionPreference = "Stop" -$enginePath = Join-Path ([IO.Path]::GetTempPath()) ("csrun-release-" + [guid]::NewGuid().ToString("N") + ".ps1") -$engineBytes = [Convert]::FromBase64String([Console]::In.ReadLine()) -[IO.File]::WriteAllBytes($enginePath, $engineBytes) -$manifest = [Console]::In.ReadToEnd() -& $enginePath -ManifestJson $manifest -exit $LASTEXITCODE -' -$output = (@($containerInput | & docker run --rm -i --entrypoint pwsh 'codebeltnet/csrun:10' -NoProfile -NonInteractive -Command $command) -join [Environment]::NewLine) -$process = [pscustomobject]@{ ExitCode = $LASTEXITCODE } -$diagnostics = '' -Write-Output $output -} catch { - [Console]::Error.WriteLine("csrun diagnostics retained in: $engineDirectory") - throw -} finally { - $resolvedTemp = [IO.Path]::TrimEndingDirectorySeparator([IO.Path]::GetFullPath([IO.Path]::GetTempPath())) - $resolvedEngineDirectory = [IO.Path]::GetFullPath($engineDirectory) - if ([IO.Path]::GetDirectoryName($resolvedEngineDirectory) -ne $resolvedTemp -or - [IO.Path]::GetFileName($resolvedEngineDirectory) -cnotmatch '^csrun-[a-f0-9]{32}$') { throw 'Unsafe cleanup path.' } - if ($process -and $process.ExitCode -eq 0) { Remove-Item -LiteralPath $resolvedEngineDirectory -Recurse -Force } -} -if ($process.ExitCode -ne 0) { throw "csrun execution failed with exit code $($process.ExitCode). $diagnostics" } -if ($verifyTests) { Assert-CsrunTestOutput $output } -} \ No newline at end of file diff --git a/.docfx/run-actions/f5ed7c321a52580d7ce11408/native.ps1 b/.docfx/run-actions/f5ed7c321a52580d7ce11408/native.ps1 deleted file mode 100644 index 4afa911..0000000 --- a/.docfx/run-actions/f5ed7c321a52580d7ce11408/native.ps1 +++ /dev/null @@ -1,88 +0,0 @@ -& { -#requires -Version 7.0 -$ErrorActionPreference = 'Stop' -$PSNativeCommandUseErrorActionPreference = $false -$manifest = @' -{ - "dependsOn": [ - "Codebelt.Extensions.Xunit.Hosting.AspNetCore@13.0.0" - ], - "framework": "net10.0", - "frameworkReferences": [ - "Microsoft.AspNetCore.App" - ], - "mode": "console", - "schemaVersion": 1, - "sdk": "Microsoft.NET.Sdk.Web", - "source": "using System;\nusing Codebelt.Extensions.Xunit.Hosting.AspNetCore.Http.Features;\n\nnamespace WebFixtureTests;\n\npublic class RequestFeatureExample\n{\n public void Demonstrate()\n {\n var request = new FakeHttpRequestFeature();\n Console.WriteLine(request.Method);\n }\n}\n\ninternal static class RunExample\n{\n static void Main()\n {\n new RequestFeatureExample().Demonstrate();\n }\n}" -} -'@ -$OutputEncoding = [Text.UTF8Encoding]::new($false) -[Console]::OutputEncoding = $OutputEncoding -$verifyTests = $false -function Assert-CsrunTestOutput([string] $Output) { - $lines = @($Output -split '\r?\n') - $headers = @($lines | Where-Object { $_ -match '^Test run summary: Passed! - .+\)$' }) - if ($headers.Count -ne 1) { throw 'Expected exactly one completed xUnit test summary.' } - $headerIndex = [Array]::IndexOf($lines, $headers[0]) - $summaryLines = @($lines | Select-Object -Skip ($headerIndex + 1) -First 4) - $counts = @{} - foreach ($line in $summaryLines) { - if ($line -match '^\s*(total|failed|succeeded|skipped):\s*(\d+)\s*$') { $counts[$Matches[1]] = [int]$Matches[2] } - } - if ($counts.Count -ne 4) { throw 'The xUnit test summary counts are incomplete or ambiguous.' } - $failed = $counts.failed - $passed = $counts.succeeded - $skipped = $counts.skipped - $total = $counts.total - if ($total -lt 1 -or $passed -lt 1 -or $failed -ne 0 -or $skipped -ne 0 -or $passed -ne $total) { - throw 'Tests must execute at least once, all pass, and none fail or skip.' - } -} -# Downloads and executes the latest stable csrun release with your permissions. -# Source and release history: https://github.com/codebeltnet/csrun -$engineDirectory = Join-Path ([IO.Path]::GetTempPath()) ('csrun-' + [guid]::NewGuid().ToString('N')) -$null = New-Item -ItemType Directory -Path $engineDirectory -$enginePath = Join-Path $engineDirectory 'csrun.ps1' -$process = $null -try { - $release = Invoke-RestMethod 'https://api.github.com/repos/codebeltnet/csrun/releases/latest' - $assets = @($release.assets | Where-Object name -CEQ 'csrun.ps1') - if ($assets.Count -ne 1 -or $assets[0].digest -notmatch '^sha256:[0-9a-f]{64}$') { - throw "csrun release $($release.tag_name) must publish one csrun.ps1 asset with a SHA-256 digest." - } - $asset = $assets[0] - Invoke-WebRequest $asset.browser_download_url -OutFile $enginePath - $actualHash = (Get-FileHash -LiteralPath $enginePath -Algorithm SHA256).Hash - if ("sha256:$actualHash" -ne $asset.digest) { throw "csrun asset checksum mismatch: $actualHash" } -$startInfo = [Diagnostics.ProcessStartInfo]::new('pwsh') -foreach ($argument in @('-NoProfile','-NonInteractive','-File')) { $startInfo.ArgumentList.Add($argument) } -$startInfo.ArgumentList.Add($enginePath) -$startInfo.ArgumentList.Add('-ManifestJson') -$startInfo.ArgumentList.Add($manifest) -$startInfo.RedirectStandardOutput = $true -$startInfo.RedirectStandardError = $true -$startInfo.UseShellExecute = $false -$process = [Diagnostics.Process]::new() -$process.StartInfo = $startInfo -if (-not $process.Start()) { throw 'Could not start csrun.' } -$stdoutTask = $process.StandardOutput.ReadToEndAsync() -$stderrTask = $process.StandardError.ReadToEndAsync() -$process.WaitForExit() -$output = $stdoutTask.GetAwaiter().GetResult() -$diagnostics = $stderrTask.GetAwaiter().GetResult() -Write-Output $output -if ($diagnostics) { [Console]::Error.Write($diagnostics) } -} catch { - [Console]::Error.WriteLine("csrun diagnostics retained in: $engineDirectory") - throw -} finally { - $resolvedTemp = [IO.Path]::TrimEndingDirectorySeparator([IO.Path]::GetFullPath([IO.Path]::GetTempPath())) - $resolvedEngineDirectory = [IO.Path]::GetFullPath($engineDirectory) - if ([IO.Path]::GetDirectoryName($resolvedEngineDirectory) -ne $resolvedTemp -or - [IO.Path]::GetFileName($resolvedEngineDirectory) -cnotmatch '^csrun-[a-f0-9]{32}$') { throw 'Unsafe cleanup path.' } - if ($process -and $process.ExitCode -eq 0) { Remove-Item -LiteralPath $resolvedEngineDirectory -Recurse -Force } -} -if ($process.ExitCode -ne 0) { throw "csrun execution failed with exit code $($process.ExitCode). $diagnostics" } -if ($verifyTests) { Assert-CsrunTestOutput $output } -} \ No newline at end of file diff --git a/.docfx/run-actions/ff2e361441bdc3028ab188a9/docker.ps1 b/.docfx/run-actions/ff2e361441bdc3028ab188a9/docker.ps1 deleted file mode 100644 index ccd3895..0000000 --- a/.docfx/run-actions/ff2e361441bdc3028ab188a9/docker.ps1 +++ /dev/null @@ -1,82 +0,0 @@ -& { -#requires -Version 7.0 -$ErrorActionPreference = 'Stop' -$PSNativeCommandUseErrorActionPreference = $false -$manifest = @' -{ - "dependsOn": [ - "Codebelt.Extensions.Xunit.Hosting@13.0.0", - "Microsoft.Extensions.Hosting@10.0.15" - ], - "framework": "net10.0", - "mode": "console", - "schemaVersion": 1, - "source": "using System;\nusing Codebelt.Extensions.Xunit.Hosting;\nusing Microsoft.Extensions.DependencyInjection;\nusing Microsoft.Extensions.Hosting;\n\nnamespace WorkerApp.Tests;\n\npublic sealed class ApplicationHostFactoryExample\n{\n public string GetTestIdentity()\n {\n using IHost host = ApplicationHostFactory.Create(builder =>\n {\n builder.ConfigureServices(services =>\n services.AddSingleton(new WorkerIdentity(\"Test inventory worker\")));\n });\n\n var identity = host.Services.GetRequiredService();\n return identity.Name;\n }\n}\n\npublic sealed record WorkerIdentity(string Name);\n\npublic sealed class WorkerProgram\n{\n public static IHostBuilder CreateHostBuilder(string[] args)\n {\n return Host.CreateDefaultBuilder(args);\n }\n\n public static void Main(string[] args)\n {\n var identity = new ApplicationHostFactoryExample().GetTestIdentity();\n if (identity != \"Test inventory worker\")\n {\n throw new InvalidOperationException(identity);\n }\n\n Console.WriteLine(identity);\n }\n}" -} -'@ -$OutputEncoding = [Text.UTF8Encoding]::new($false) -[Console]::OutputEncoding = $OutputEncoding -$verifyTests = $false -function Assert-CsrunTestOutput([string] $Output) { - $lines = @($Output -split '\r?\n') - $headers = @($lines | Where-Object { $_ -match '^Test run summary: Passed! - .+\)$' }) - if ($headers.Count -ne 1) { throw 'Expected exactly one completed xUnit test summary.' } - $headerIndex = [Array]::IndexOf($lines, $headers[0]) - $summaryLines = @($lines | Select-Object -Skip ($headerIndex + 1) -First 4) - $counts = @{} - foreach ($line in $summaryLines) { - if ($line -match '^\s*(total|failed|succeeded|skipped):\s*(\d+)\s*$') { $counts[$Matches[1]] = [int]$Matches[2] } - } - if ($counts.Count -ne 4) { throw 'The xUnit test summary counts are incomplete or ambiguous.' } - $failed = $counts.failed - $passed = $counts.succeeded - $skipped = $counts.skipped - $total = $counts.total - if ($total -lt 1 -or $passed -lt 1 -or $failed -ne 0 -or $skipped -ne 0 -or $passed -ne $total) { - throw 'Tests must execute at least once, all pass, and none fail or skip.' - } -} -# Downloads and executes the latest stable csrun release with your permissions. -# Source and release history: https://github.com/codebeltnet/csrun -$engineDirectory = Join-Path ([IO.Path]::GetTempPath()) ('csrun-' + [guid]::NewGuid().ToString('N')) -$null = New-Item -ItemType Directory -Path $engineDirectory -$enginePath = Join-Path $engineDirectory 'csrun.ps1' -$process = $null -try { - $release = Invoke-RestMethod 'https://api.github.com/repos/codebeltnet/csrun/releases/latest' - $assets = @($release.assets | Where-Object name -CEQ 'csrun.ps1') - if ($assets.Count -ne 1 -or $assets[0].digest -notmatch '^sha256:[0-9a-f]{64}$') { - throw "csrun release $($release.tag_name) must publish one csrun.ps1 asset with a SHA-256 digest." - } - $asset = $assets[0] - Invoke-WebRequest $asset.browser_download_url -OutFile $enginePath - $actualHash = (Get-FileHash -LiteralPath $enginePath -Algorithm SHA256).Hash - if ("sha256:$actualHash" -ne $asset.digest) { throw "csrun asset checksum mismatch: $actualHash" } -$enginePayload = [Convert]::ToBase64String([IO.File]::ReadAllBytes($enginePath)) -$containerInput = $enginePayload + "`n" + $manifest -$command = ' -$ErrorActionPreference = "Stop" -$enginePath = Join-Path ([IO.Path]::GetTempPath()) ("csrun-release-" + [guid]::NewGuid().ToString("N") + ".ps1") -$engineBytes = [Convert]::FromBase64String([Console]::In.ReadLine()) -[IO.File]::WriteAllBytes($enginePath, $engineBytes) -$manifest = [Console]::In.ReadToEnd() -& $enginePath -ManifestJson $manifest -exit $LASTEXITCODE -' -$output = (@($containerInput | & docker run --rm -i --entrypoint pwsh 'codebeltnet/csrun:10' -NoProfile -NonInteractive -Command $command) -join [Environment]::NewLine) -$process = [pscustomobject]@{ ExitCode = $LASTEXITCODE } -$diagnostics = '' -Write-Output $output -} catch { - [Console]::Error.WriteLine("csrun diagnostics retained in: $engineDirectory") - throw -} finally { - $resolvedTemp = [IO.Path]::TrimEndingDirectorySeparator([IO.Path]::GetFullPath([IO.Path]::GetTempPath())) - $resolvedEngineDirectory = [IO.Path]::GetFullPath($engineDirectory) - if ([IO.Path]::GetDirectoryName($resolvedEngineDirectory) -ne $resolvedTemp -or - [IO.Path]::GetFileName($resolvedEngineDirectory) -cnotmatch '^csrun-[a-f0-9]{32}$') { throw 'Unsafe cleanup path.' } - if ($process -and $process.ExitCode -eq 0) { Remove-Item -LiteralPath $resolvedEngineDirectory -Recurse -Force } -} -if ($process.ExitCode -ne 0) { throw "csrun execution failed with exit code $($process.ExitCode). $diagnostics" } -if ($verifyTests) { Assert-CsrunTestOutput $output } -} \ No newline at end of file diff --git a/.docfx/run-actions/ff2e361441bdc3028ab188a9/native.ps1 b/.docfx/run-actions/ff2e361441bdc3028ab188a9/native.ps1 deleted file mode 100644 index 36eb6bc..0000000 --- a/.docfx/run-actions/ff2e361441bdc3028ab188a9/native.ps1 +++ /dev/null @@ -1,85 +0,0 @@ -& { -#requires -Version 7.0 -$ErrorActionPreference = 'Stop' -$PSNativeCommandUseErrorActionPreference = $false -$manifest = @' -{ - "dependsOn": [ - "Codebelt.Extensions.Xunit.Hosting@13.0.0", - "Microsoft.Extensions.Hosting@10.0.15" - ], - "framework": "net10.0", - "mode": "console", - "schemaVersion": 1, - "source": "using System;\nusing Codebelt.Extensions.Xunit.Hosting;\nusing Microsoft.Extensions.DependencyInjection;\nusing Microsoft.Extensions.Hosting;\n\nnamespace WorkerApp.Tests;\n\npublic sealed class ApplicationHostFactoryExample\n{\n public string GetTestIdentity()\n {\n using IHost host = ApplicationHostFactory.Create(builder =>\n {\n builder.ConfigureServices(services =>\n services.AddSingleton(new WorkerIdentity(\"Test inventory worker\")));\n });\n\n var identity = host.Services.GetRequiredService();\n return identity.Name;\n }\n}\n\npublic sealed record WorkerIdentity(string Name);\n\npublic sealed class WorkerProgram\n{\n public static IHostBuilder CreateHostBuilder(string[] args)\n {\n return Host.CreateDefaultBuilder(args);\n }\n\n public static void Main(string[] args)\n {\n var identity = new ApplicationHostFactoryExample().GetTestIdentity();\n if (identity != \"Test inventory worker\")\n {\n throw new InvalidOperationException(identity);\n }\n\n Console.WriteLine(identity);\n }\n}" -} -'@ -$OutputEncoding = [Text.UTF8Encoding]::new($false) -[Console]::OutputEncoding = $OutputEncoding -$verifyTests = $false -function Assert-CsrunTestOutput([string] $Output) { - $lines = @($Output -split '\r?\n') - $headers = @($lines | Where-Object { $_ -match '^Test run summary: Passed! - .+\)$' }) - if ($headers.Count -ne 1) { throw 'Expected exactly one completed xUnit test summary.' } - $headerIndex = [Array]::IndexOf($lines, $headers[0]) - $summaryLines = @($lines | Select-Object -Skip ($headerIndex + 1) -First 4) - $counts = @{} - foreach ($line in $summaryLines) { - if ($line -match '^\s*(total|failed|succeeded|skipped):\s*(\d+)\s*$') { $counts[$Matches[1]] = [int]$Matches[2] } - } - if ($counts.Count -ne 4) { throw 'The xUnit test summary counts are incomplete or ambiguous.' } - $failed = $counts.failed - $passed = $counts.succeeded - $skipped = $counts.skipped - $total = $counts.total - if ($total -lt 1 -or $passed -lt 1 -or $failed -ne 0 -or $skipped -ne 0 -or $passed -ne $total) { - throw 'Tests must execute at least once, all pass, and none fail or skip.' - } -} -# Downloads and executes the latest stable csrun release with your permissions. -# Source and release history: https://github.com/codebeltnet/csrun -$engineDirectory = Join-Path ([IO.Path]::GetTempPath()) ('csrun-' + [guid]::NewGuid().ToString('N')) -$null = New-Item -ItemType Directory -Path $engineDirectory -$enginePath = Join-Path $engineDirectory 'csrun.ps1' -$process = $null -try { - $release = Invoke-RestMethod 'https://api.github.com/repos/codebeltnet/csrun/releases/latest' - $assets = @($release.assets | Where-Object name -CEQ 'csrun.ps1') - if ($assets.Count -ne 1 -or $assets[0].digest -notmatch '^sha256:[0-9a-f]{64}$') { - throw "csrun release $($release.tag_name) must publish one csrun.ps1 asset with a SHA-256 digest." - } - $asset = $assets[0] - Invoke-WebRequest $asset.browser_download_url -OutFile $enginePath - $actualHash = (Get-FileHash -LiteralPath $enginePath -Algorithm SHA256).Hash - if ("sha256:$actualHash" -ne $asset.digest) { throw "csrun asset checksum mismatch: $actualHash" } -$startInfo = [Diagnostics.ProcessStartInfo]::new('pwsh') -foreach ($argument in @('-NoProfile','-NonInteractive','-File')) { $startInfo.ArgumentList.Add($argument) } -$startInfo.ArgumentList.Add($enginePath) -$startInfo.ArgumentList.Add('-ManifestJson') -$startInfo.ArgumentList.Add($manifest) -$startInfo.RedirectStandardOutput = $true -$startInfo.RedirectStandardError = $true -$startInfo.UseShellExecute = $false -$process = [Diagnostics.Process]::new() -$process.StartInfo = $startInfo -if (-not $process.Start()) { throw 'Could not start csrun.' } -$stdoutTask = $process.StandardOutput.ReadToEndAsync() -$stderrTask = $process.StandardError.ReadToEndAsync() -$process.WaitForExit() -$output = $stdoutTask.GetAwaiter().GetResult() -$diagnostics = $stderrTask.GetAwaiter().GetResult() -Write-Output $output -if ($diagnostics) { [Console]::Error.Write($diagnostics) } -} catch { - [Console]::Error.WriteLine("csrun diagnostics retained in: $engineDirectory") - throw -} finally { - $resolvedTemp = [IO.Path]::TrimEndingDirectorySeparator([IO.Path]::GetFullPath([IO.Path]::GetTempPath())) - $resolvedEngineDirectory = [IO.Path]::GetFullPath($engineDirectory) - if ([IO.Path]::GetDirectoryName($resolvedEngineDirectory) -ne $resolvedTemp -or - [IO.Path]::GetFileName($resolvedEngineDirectory) -cnotmatch '^csrun-[a-f0-9]{32}$') { throw 'Unsafe cleanup path.' } - if ($process -and $process.ExitCode -eq 0) { Remove-Item -LiteralPath $resolvedEngineDirectory -Recurse -Force } -} -if ($process.ExitCode -ne 0) { throw "csrun execution failed with exit code $($process.ExitCode). $diagnostics" } -if ($verifyTests) { Assert-CsrunTestOutput $output } -} \ No newline at end of file diff --git a/.docfx/run-actions/index.json b/.docfx/run-actions/index.json deleted file mode 100644 index 46bec1f..0000000 --- a/.docfx/run-actions/index.json +++ /dev/null @@ -1,692 +0,0 @@ -{ - "examples": [ - { - "id": "e7dbb5ba733b205469239b03", - "file": ".docfx/api/types/Codebelt.Extensions.Xunit.Hosting.ApplicationFixtureExtensions.md", - "uid": "Codebelt.Extensions.Xunit.Hosting.ApplicationFixtureExtensions", - "sourceSha256": "90B08550FC34DE0144BF28F6ADB2577A59AEC596EB8B6060D545A9B56CD34377", - "status": "ready", - "coverage": "Paired", - "reason": null, - "native": "Unverified", - "docker": "Unverified", - "strategy": "standalone", - "executionSourceSha256": "90B08550FC34DE0144BF28F6ADB2577A59AEC596EB8B6060D545A9B56CD34377", - "nativeSha256": "4DE0DB60FDC7F3CAE0D8E0D09DB207BE30F595F2AB1996AACAF932C237F629DA", - "dockerSha256": "8351E14031CD450FB45EE3F66F343365C5311411013063512ADBCC9D3E6B825D", - "fingerprint": "1BABA39EAFFCD3CCCCD1352184B8769095AAC1083AE7C34BEB94E0A749F7F570" - }, - { - "id": "ff2e361441bdc3028ab188a9", - "file": ".docfx/api/types/Codebelt.Extensions.Xunit.Hosting.ApplicationHostFactory.md", - "uid": "Codebelt.Extensions.Xunit.Hosting.ApplicationHostFactory", - "sourceSha256": "42FEDED83B95259C5771DBE3B83C0323599941985C3D71B510F80C1448BB3771", - "status": "ready", - "coverage": "Paired", - "reason": null, - "native": "Unverified", - "docker": "Unverified", - "strategy": "standalone", - "executionSourceSha256": "42FEDED83B95259C5771DBE3B83C0323599941985C3D71B510F80C1448BB3771", - "nativeSha256": "DE1D6A10381B52052B18B4DEC4C9452EB204D815942F2E28CFED09581632E150", - "dockerSha256": "EE0B55D0723058A2719B42EF6464BC3CD7FD187E1EDA7B7F440BD3099762BD74", - "fingerprint": "92F7147B52A0BFA09E4FCA43FCA08AD8665F82A1D3A5718D5809A8315047C895" - }, - { - "id": "90a8cd444bd08a0115613e58", - "file": ".docfx/api/types/Codebelt.Extensions.Xunit.Hosting.ApplicationTestFactory.md", - "uid": "Codebelt.Extensions.Xunit.Hosting.ApplicationTestFactory", - "sourceSha256": "7473E8AE20820AD58942D6212B5A7DCD428922FD0EEF1985E7D05F9CAC6E8D23", - "status": "ready", - "coverage": "Paired", - "reason": null, - "native": "Unverified", - "docker": "Unverified", - "strategy": "repository", - "nativeSha256": "00C7A8327F5EFCE49526FA7525D78890D14EB274111A434BD88D5D2AABA5CA20", - "dockerSha256": "8A5C860C687FAA281F30644370454337777E46FA9BD9EFFC7E57B1A39B659CFF", - "explanation": "The scripts run the maintained worker integration test and verify its registered marker and Development environment.", - "fingerprint": "E8D9055BAF8F4A43CD8C388ABD03961A61E76743EF83E0D3A09632B6FDF0555B" - }, - { - "id": "21b422ce67f920d801901db0", - "file": ".docfx/api/types/Codebelt.Extensions.Xunit.Hosting.AspNetCore.BlockingManagedWebHostFixture.md", - "uid": "Codebelt.Extensions.Xunit.Hosting.AspNetCore.BlockingManagedWebHostFixture", - "sourceSha256": "CD729B010424B55A26B7607AC78059BC5F610C522C2DCF312E7AD6A8A602E7FC", - "status": "ready", - "coverage": "Paired", - "reason": null, - "native": "Unverified", - "docker": "Unverified", - "strategy": "standalone", - "executionSourceSha256": "CD729B010424B55A26B7607AC78059BC5F610C522C2DCF312E7AD6A8A602E7FC", - "nativeSha256": "31C861D2FB151613E0BD98029ABD8BA81DBC534DCAAD0A982D10130AAD83F7C3", - "dockerSha256": "872671B77DCBD4496E7E4D7083E1634B01A56B2AA03AC8AC4040E190D46ECC55", - "fingerprint": "D077B13EEABDD6F498356984B871DC0FE938F12D92B91B76F75B6A479A3C4D77" - }, - { - "id": "d565f9c40d015b247963fdee", - "file": ".docfx/api/types/Codebelt.Extensions.Xunit.Hosting.AspNetCore.HostBuilderApplicationExtensions.md", - "uid": "Codebelt.Extensions.Xunit.Hosting.AspNetCore.HostBuilderApplicationExtensions", - "sourceSha256": "340FBC3BD83E80B5B8AD6FAA66020C285458A08A608961D7D33BFA1B841FEFF4", - "status": "ready", - "coverage": "Paired", - "reason": null, - "native": "Unverified", - "docker": "Unverified", - "strategy": "standalone", - "executionSourceSha256": "340FBC3BD83E80B5B8AD6FAA66020C285458A08A608961D7D33BFA1B841FEFF4", - "nativeSha256": "4CAB1FB584706805F33D5C3AA646B2853778144B1D33C5F69EA3DEBD19485EE1", - "dockerSha256": "9BDB7866F9163C5545D0BFB5794A0AA0203919A8D8B00F23D540026D98F8F9F0", - "fingerprint": "3E4DADD169E201FC40D08DA8B204136D205C2FE35B50B4B4319D1B37C0C3745D" - }, - { - "id": "3a1dbfc0e010519636b7091e", - "file": ".docfx/api/types/Codebelt.Extensions.Xunit.Hosting.AspNetCore.Http.FakeHttpContextAccessor.md", - "uid": "Codebelt.Extensions.Xunit.Hosting.AspNetCore.Http.FakeHttpContextAccessor", - "sourceSha256": "DCFB8604280E9AC15FFABA700B4055745F26AB9AD9E2F25C3A455EB50AEE7376", - "status": "ready", - "coverage": "Paired", - "reason": null, - "native": "Unverified", - "docker": "Unverified", - "strategy": "standalone", - "executionSourceSha256": "DCFB8604280E9AC15FFABA700B4055745F26AB9AD9E2F25C3A455EB50AEE7376", - "nativeSha256": "7F3DF3F66AD015449F60260D41ACCC8393695A6F0942D1935D8ECD49E23A6BE9", - "dockerSha256": "B3728E1458DBA2796585622B3173788A39E8997C45C6C4A4DBEF167B06B9F43C", - "fingerprint": "D28A47B38C5AAC3C9E17BBC1BCDC8E39E697AF4D5D92400E15704AAB52529B8D" - }, - { - "id": "f5ed7c321a52580d7ce11408", - "file": ".docfx/api/types/Codebelt.Extensions.Xunit.Hosting.AspNetCore.Http.Features.FakeHttpRequestFeature.md", - "uid": "Codebelt.Extensions.Xunit.Hosting.AspNetCore.Http.Features.FakeHttpRequestFeature", - "sourceSha256": "A68A4CA3ACD2C8F668D4D343A9B36AB6E84D6CC1B506473700E973B97D053B94", - "status": "ready", - "coverage": "Paired", - "reason": null, - "native": "Unverified", - "docker": "Unverified", - "strategy": "standalone", - "executionSourceSha256": "A68A4CA3ACD2C8F668D4D343A9B36AB6E84D6CC1B506473700E973B97D053B94", - "nativeSha256": "C8A1CA0ABD69A8498D251F76155638B20760427AB79FEBAE64D5553DC85C3C07", - "dockerSha256": "EE34C5CD5FCB7B29AC03464AEF5E15B6D2DCD822B79062F7AF783DBC08B2AEEE", - "fingerprint": "6FCE39E028BF1CCCCC590995F21A8BF654401C3B4860BC91B71346A08417B063" - }, - { - "id": "08b911ef79f0b743282e37c9", - "file": ".docfx/api/types/Codebelt.Extensions.Xunit.Hosting.AspNetCore.Http.Features.FakeHttpResponseFeature.md", - "uid": "Codebelt.Extensions.Xunit.Hosting.AspNetCore.Http.Features.FakeHttpResponseFeature", - "sourceSha256": "7549EF36EB77D3203099D1DFEF5584A8AAEBD3ED8E537D6BF752D3231191C33D", - "status": "ready", - "coverage": "Paired", - "reason": null, - "native": "Unverified", - "docker": "Unverified", - "strategy": "standalone", - "executionSourceSha256": "7549EF36EB77D3203099D1DFEF5584A8AAEBD3ED8E537D6BF752D3231191C33D", - "nativeSha256": "130FF453A10C707D1199665C806B85611375C886F024AA87BAC536E8C0057AAA", - "dockerSha256": "00968DFBD11C62B26CDBDFBD5D0722D623C0FF2F79276587D9431E28D966D054", - "fingerprint": "3909C3B574F4FDA5C486A33E9786550C9AB70788E50BCE93898ED25049158B80" - }, - { - "id": "947406357e3e26b26a71a538", - "file": ".docfx/api/types/Codebelt.Extensions.Xunit.Hosting.AspNetCore.HttpClientExtensions.md", - "uid": "Codebelt.Extensions.Xunit.Hosting.AspNetCore.HttpClientExtensions", - "sourceSha256": "FABF1EB669FF7CC6B2BDB803E7CC6120EF9FE117823C720690A57522435C1468", - "status": "ready", - "coverage": "Paired", - "reason": null, - "native": "Unverified", - "docker": "Unverified", - "strategy": "standalone", - "executionSourceSha256": "FABF1EB669FF7CC6B2BDB803E7CC6120EF9FE117823C720690A57522435C1468", - "nativeSha256": "C890FC1E5741BB76F57978D2C5A0F35D99DBDC8DDF28358B2C03DB811F4D2E7E", - "dockerSha256": "A91F296DCA868E40610A535D8434916C32DBB97224A329694E472095821FAF42", - "fingerprint": "5D485141E98495D6FEBA00ADE1F737A09D14F48C993583D0E80D6CE336192F2F" - }, - { - "id": "4c5e94adccd20cab4da52078", - "file": ".docfx/api/types/Codebelt.Extensions.Xunit.Hosting.AspNetCore.ManagedWebApplicationFixture%601.md", - "uid": "Codebelt.Extensions.Xunit.Hosting.AspNetCore.ManagedWebApplicationFixture`1", - "sourceSha256": "8A75CECB985C8FCE6F9C0C1211311D40867D82B83ED060008D75E7A3F963EFE3", - "status": "ready", - "coverage": "Paired", - "reason": null, - "native": "Unverified", - "docker": "Unverified", - "strategy": "repository", - "nativeSha256": "7CA33C5DA5E344F5D304ACFD4F9D647CD86AF0A16CD8703BE3A5B4C985C249A1", - "dockerSha256": "F480E508DEE48C294129847AF07388A8380B73426101FF17F7F16F2868C9F80D", - "explanation": "The scripts start the maintained ASP.NET Core application through the same fixture and verify its HTTP response.", - "fingerprint": "BDED27159743FF0AFD2F2194AB13DB270C4683784DA246A416B5FB3C7CB72B6D" - }, - { - "id": "927ca9f6a3bf893bc52887f4", - "file": ".docfx/api/types/Codebelt.Extensions.Xunit.Hosting.AspNetCore.ManagedWebHostFixture.md", - "uid": "Codebelt.Extensions.Xunit.Hosting.AspNetCore.ManagedWebHostFixture", - "sourceSha256": "2CC0B80DE03471AD6DD8210B4FDF2FA037751EF8B38AD43B1C611FC553EDA979", - "status": "ready", - "coverage": "Paired", - "reason": null, - "native": "Unverified", - "docker": "Unverified", - "strategy": "standalone", - "executionSourceSha256": "2CC0B80DE03471AD6DD8210B4FDF2FA037751EF8B38AD43B1C611FC553EDA979", - "nativeSha256": "4EF5AC9FAC282678956D5BC6A4AB1905183820457A2197ED1C67CE3A8B9709AA", - "dockerSha256": "DF3CFE553ACDC7C67454233C5383A0E6F50F9FEE4BF947E13C138CB04A3F2F2B", - "fingerprint": "9972E2493E26F0B44F44AADBB8C278447EE93EE1399F2798E0FD2ADDE4753313" - }, - { - "id": "00acdae546dce87b654496e1", - "file": ".docfx/api/types/Codebelt.Extensions.Xunit.Hosting.AspNetCore.ManagedWebMinimalHostFixture.md", - "uid": "Codebelt.Extensions.Xunit.Hosting.AspNetCore.ManagedWebMinimalHostFixture", - "sourceSha256": "9D12413E06F45213763C5BAD14B3B2796097B1F773D18BDA1F8CBF90F7CF1268", - "status": "ready", - "coverage": "Paired", - "reason": null, - "native": "Unverified", - "docker": "Unverified", - "strategy": "standalone", - "executionSourceSha256": "9D12413E06F45213763C5BAD14B3B2796097B1F773D18BDA1F8CBF90F7CF1268", - "nativeSha256": "313D557C16CBC735E1AB28E16FF49CB08EF7E9E606EC6FDDC6B18B3CE2508515", - "dockerSha256": "F1160FDEBD047F6E9C1D4796CABD0DCF9DF3BA4BCD248C9C7CED61B269CD45CD", - "fingerprint": "D263C48D97068DDCD50FF2AB1DCF68DE568B3113557DBE0666CD04EDD2F85855" - }, - { - "id": "1e869fe39c4833386733c21f", - "file": ".docfx/api/types/Codebelt.Extensions.Xunit.Hosting.AspNetCore.MinimalWebHostTestFactory.md", - "uid": "Codebelt.Extensions.Xunit.Hosting.AspNetCore.MinimalWebHostTestFactory", - "sourceSha256": "869F4EDAF75D120A8A7F73B37C8E87002B0B006BABF480ECA0BFDCD5939E1F73", - "status": "ready", - "coverage": "Paired", - "reason": null, - "native": "Unverified", - "docker": "Unverified", - "strategy": "standalone", - "executionSourceSha256": "869F4EDAF75D120A8A7F73B37C8E87002B0B006BABF480ECA0BFDCD5939E1F73", - "nativeSha256": "FB95BAECD391A61E27BDF1B6E86E8FF4FF11B22D250465E93B83A1B3E6F6362D", - "dockerSha256": "C130C15E83B7F1CEAD1245BB3F550AFF71CE3A81537F124EE682E599794CC3C4", - "fingerprint": "264A534ACE258BD3C3E88EF13F175D17B8C33FEE4ACC72E4A7CA5A6A1CC8AA24" - }, - { - "id": "f27f77d838407171b56f9073", - "file": ".docfx/api/types/Codebelt.Extensions.Xunit.Hosting.AspNetCore.SelfManagedWebHostFixture.md", - "uid": "Codebelt.Extensions.Xunit.Hosting.AspNetCore.SelfManagedWebHostFixture", - "sourceSha256": "8C67EA9DD2F57A0DB37E7EE5E5516CE5655B61EE90C4097CFAE7EC8CD9B9F59D", - "status": "ready", - "coverage": "Paired", - "reason": null, - "native": "Unverified", - "docker": "Unverified", - "strategy": "standalone", - "executionSourceSha256": "8C67EA9DD2F57A0DB37E7EE5E5516CE5655B61EE90C4097CFAE7EC8CD9B9F59D", - "nativeSha256": "81A906B0589518110EFAE86BFE6B3348FCE3FCEDAD9E6DCF9A7F9DB93B2B8410", - "dockerSha256": "52DDBC16B9C15011CAD0960BD6BEDEE5E1B5F90BF6031E6F5777A57F5579308E", - "fingerprint": "336B4A0D09DF623D43144C0F8E29EA9DC327B655591B6A77C6EC35C94AADD62A" - }, - { - "id": "3c3b98167b30d6985017ec27", - "file": ".docfx/api/types/Codebelt.Extensions.Xunit.Hosting.AspNetCore.SelfManagedWebMinimalHostFixture.md", - "uid": "Codebelt.Extensions.Xunit.Hosting.AspNetCore.SelfManagedWebMinimalHostFixture", - "sourceSha256": "BD4DED8434BE4E8F5C88402103358DBCC12C4548C89FC48C060587BDB9CE3C5C", - "status": "ready", - "coverage": "Paired", - "reason": null, - "native": "Unverified", - "docker": "Unverified", - "strategy": "standalone", - "executionSourceSha256": "BD4DED8434BE4E8F5C88402103358DBCC12C4548C89FC48C060587BDB9CE3C5C", - "nativeSha256": "A9EA5F93E58E9331D99EEFC4EDBD0FA1A234FA7837578B56EBEE996E9CF52D95", - "dockerSha256": "8D4B344F5739DBD9779CD4F673135837AEE266F4FB139BAEAFD722E89BFB3EF2", - "fingerprint": "45D6B2B661E054208195D3822A130390F4F0E00D09D1DF91BFDAA2169D93F2A2" - }, - { - "id": "f3c0856195727da12ff2925f", - "file": ".docfx/api/types/Codebelt.Extensions.Xunit.Hosting.AspNetCore.ServiceCollectionExtensions.md", - "uid": "Codebelt.Extensions.Xunit.Hosting.AspNetCore.ServiceCollectionExtensions", - "sourceSha256": "FFE4DD6394228DC8E7DF1EF37C5377AF341AD84C0E18D3B83CFE51ED671CC8F0", - "status": "ready", - "coverage": "Paired", - "reason": null, - "native": "Unverified", - "docker": "Unverified", - "strategy": "standalone", - "executionSourceSha256": "FFE4DD6394228DC8E7DF1EF37C5377AF341AD84C0E18D3B83CFE51ED671CC8F0", - "nativeSha256": "F2BEE9D8CB95A6B817174B56B95F8E7FDA659F24772FBEAA9DE9D366499EFA60", - "dockerSha256": "62FF334C87C75812C2253716E8A6DFFA5A752E572C0594C480DBE759505E08F3", - "fingerprint": "BA8E7250D6E7639ABC218267B26D528A2AF4163B18AB0E4F20403CC11148FB14" - }, - { - "id": "549c3e82bd0bcb99e9f05bfa", - "file": ".docfx/api/types/Codebelt.Extensions.Xunit.Hosting.AspNetCore.WebApplicationFixtureExtensions.md", - "uid": "Codebelt.Extensions.Xunit.Hosting.AspNetCore.WebApplicationFixtureExtensions", - "sourceSha256": "9C8A41C5E80934D69DF60798533A7E8BE07CA4210608BBDD2230C757179A8EC5", - "status": "ready", - "coverage": "Paired", - "reason": null, - "native": "Unverified", - "docker": "Unverified", - "strategy": "standalone", - "executionSourceSha256": "9C8A41C5E80934D69DF60798533A7E8BE07CA4210608BBDD2230C757179A8EC5", - "nativeSha256": "CB1E905B217B54C3893A0796CF95ED2F35AD1B082F5065485439B2B0D5D91DE5", - "dockerSha256": "0D53E0C09D1ADD025CD4D50BEB2572B2BFE59DCFF88A55CF4D9C85414FC3C244", - "fingerprint": "EB995FBD5C973FE46D91E992F3356F1FB7B7F3F95B810CC831C25BB60083EBC3" - }, - { - "id": "38b60f4b4c1a588bbefe92f1", - "file": ".docfx/api/types/Codebelt.Extensions.Xunit.Hosting.AspNetCore.WebApplicationTestFactory.md", - "uid": "Codebelt.Extensions.Xunit.Hosting.AspNetCore.WebApplicationTestFactory", - "sourceSha256": "1DB1DAAA9965BF42F736A4BC3788B4261DF4EF52799B83E6F733AB1BD53EA7D3", - "status": "ready", - "coverage": "Paired", - "reason": null, - "native": "Unverified", - "docker": "Unverified", - "strategy": "repository", - "nativeSha256": "69FDA93954B1FD1242343B73F7BDBE189191572F1F84721F6ED6B4517FB83FA6", - "dockerSha256": "D4F431F447435C826AB63A6BC28FF32C489EB19A4F31A956458A4EF9B82B59EB", - "explanation": "The scripts run the maintained integration test, which overrides services and configuration and verifies the results through HTTP endpoints.", - "fingerprint": "829297A6A6D255195BA01DB7F8DC8FF5675B2A7C40E1C817099F1D2F6B772165" - }, - { - "id": "dfdd064179bf4643e1a0b2bf", - "file": ".docfx/api/types/Codebelt.Extensions.Xunit.Hosting.AspNetCore.WebHostFixtureExtensions.md", - "uid": "Codebelt.Extensions.Xunit.Hosting.AspNetCore.WebHostFixtureExtensions", - "sourceSha256": "CEDFFF39E914FF47421AE5A4F37CA1564DCAC8252903585B3B53DB069663492B", - "status": "ready", - "coverage": "Paired", - "reason": null, - "native": "Unverified", - "docker": "Unverified", - "strategy": "standalone", - "executionSourceSha256": "CEDFFF39E914FF47421AE5A4F37CA1564DCAC8252903585B3B53DB069663492B", - "nativeSha256": "AB5F11B6455048AB8A913B28B56EE0B9066456F66A6A765EB40BFC28E33FFA0A", - "dockerSha256": "0A3B147AB81262F151FA38ED1A42514797F1148B86101022DBBEC20356A8AE2E", - "fingerprint": "110EDB7870A95DD8C2BA7F53DBBB927175DECF3D08F5D44B0BB54FF6AF5AD045" - }, - { - "id": "d71e8ed85f1221cb41308b31", - "file": ".docfx/api/types/Codebelt.Extensions.Xunit.Hosting.AspNetCore.WebHostTestFactory.md", - "uid": "Codebelt.Extensions.Xunit.Hosting.AspNetCore.WebHostTestFactory", - "sourceSha256": "F2DCAE2A6B67B77ADED3A2B726B4ABA20276D3C0FBDFB57F153447D8312005EE", - "status": "ready", - "coverage": "Paired", - "reason": null, - "native": "Unverified", - "docker": "Unverified", - "strategy": "standalone", - "executionSourceSha256": "F2DCAE2A6B67B77ADED3A2B726B4ABA20276D3C0FBDFB57F153447D8312005EE", - "nativeSha256": "4395294663D1EABA0514999B70FCCBA79F45D11CEEF9AAFF4F9E3D1C8F821251", - "dockerSha256": "915DB06EF218173F65642FB4705527B6D5E51E84250CDBF3465A700C28191130", - "fingerprint": "2FC31107F86602B357FA65E9398D455F724268C87F2BF2A29EA2D811E45DACBA" - }, - { - "id": "dd2fa1a038dbc1220b366a53", - "file": ".docfx/api/types/Codebelt.Extensions.Xunit.Hosting.AspNetCore.WebMinimalHostFixtureExtensions.md", - "uid": "Codebelt.Extensions.Xunit.Hosting.AspNetCore.WebMinimalHostFixtureExtensions", - "sourceSha256": "F30F392FC9E68CBA4BCCB949F0CF36307DCC6A0FFF2DEA05F4641ACB4EA13900", - "status": "ready", - "coverage": "Paired", - "reason": null, - "native": "Unverified", - "docker": "Unverified", - "strategy": "standalone", - "executionSourceSha256": "F30F392FC9E68CBA4BCCB949F0CF36307DCC6A0FFF2DEA05F4641ACB4EA13900", - "nativeSha256": "BE4CBA9D128D88F26DD18A33AC2D09A139BBF0C580F90D302426C832F4CC8DD3", - "dockerSha256": "8D64AF7C519A8413BC1C161D043A9B0AEB2852FF201A1655521CEDD7FA9A5917", - "fingerprint": "5890C6FABD20CB7382698233228136AA4568648889D27615B34045506C335200" - }, - { - "id": "1130af506703020850fdadea", - "file": ".docfx/api/types/Codebelt.Extensions.Xunit.Hosting.GenericHostFixtureExtensions.md", - "uid": "Codebelt.Extensions.Xunit.Hosting.GenericHostFixtureExtensions", - "sourceSha256": "6DA99A91947A5C64953DDD8F7B42EC74AE39C3EDFBF9F2DB69A31B9B2D0B90AC", - "status": "ready", - "coverage": "Paired", - "reason": null, - "native": "Unverified", - "docker": "Unverified", - "strategy": "standalone", - "executionSourceSha256": "6DA99A91947A5C64953DDD8F7B42EC74AE39C3EDFBF9F2DB69A31B9B2D0B90AC", - "nativeSha256": "F4D79D2A5B2B52462AF433796E36F27BE2160C8F478EB54545FC3409C746294D", - "dockerSha256": "A82D197296B23978BC16D3BD52C94A3414DED8655C65979F37A90761C4E769CA", - "fingerprint": "700A6049B9F2E6A1C8213A33092ED449B4F4B3C91A1954BAD94509D95D75A34D" - }, - { - "id": "9cdeb08f8ba8f3b361a98c58", - "file": ".docfx/api/types/Codebelt.Extensions.Xunit.Hosting.HostTestFactory.md", - "uid": "Codebelt.Extensions.Xunit.Hosting.HostTestFactory", - "sourceSha256": "DBB1A94CF50D0C71616D4482DFD2FF1A4D5F8EA387340B6D4C98A5A4F84E6652", - "status": "ready", - "coverage": "Paired", - "reason": null, - "native": "Unverified", - "docker": "Unverified", - "strategy": "standalone", - "executionSourceSha256": "DBB1A94CF50D0C71616D4482DFD2FF1A4D5F8EA387340B6D4C98A5A4F84E6652", - "nativeSha256": "E006BE44A9936D50BABC7FD9588D88D5AFF0867620E70C39C0211959EB3E9986", - "dockerSha256": "5DC664410B9F74D7B95B1779EE0944E004D0E086D0A869A2983876918C803155", - "fingerprint": "B7876A355FD35F53A4358AF0B9ED49CB603AEAFA56C2F3E45646758202A12D44" - }, - { - "id": "513a785b0e0abbe2284270b9", - "file": ".docfx/api/types/Codebelt.Extensions.Xunit.Hosting.LoggerExtensions.md", - "uid": "Codebelt.Extensions.Xunit.Hosting.LoggerExtensions", - "sourceSha256": "D2C65C928AF86623AF7F8B754C254F1A64B7FEB61F6168559FD1FC1862A08DEB", - "status": "ready", - "coverage": "Paired", - "reason": null, - "native": "Unverified", - "docker": "Unverified", - "strategy": "standalone", - "executionSourceSha256": "D2C65C928AF86623AF7F8B754C254F1A64B7FEB61F6168559FD1FC1862A08DEB", - "nativeSha256": "1AE855A54C56279F55ED6C4C5400688083A06CBC1D9A7143DB54BFC67187526A", - "dockerSha256": "ABF4E0E98596EA711DF07C0F8C2D5DA4D044B80D560A2897429E09F2C6D672F9", - "fingerprint": "B8F9DA134B445F92CECA956D84A4FA864AF6F6FFA94F8C17E4730F358632BE61" - }, - { - "id": "1ec9196292addaca42a7eef1", - "file": ".docfx/api/types/Codebelt.Extensions.Xunit.Hosting.ManagedApplicationFixture%601.md", - "uid": "Codebelt.Extensions.Xunit.Hosting.ManagedApplicationFixture`1", - "sourceSha256": "47B0C1FBA94E7B43C8753D0A8242801B328E6B463B6EEDAEB640D4F8A262633E", - "status": "ready", - "coverage": "Paired", - "reason": null, - "native": "Unverified", - "docker": "Unverified", - "strategy": "repository", - "nativeSha256": "CBC8F4768833FBF5B62523F466C1763AB20C52424852F49F2CCDA2C276B2A727", - "dockerSha256": "AF143DDB933F4589D3E33A489DA0483A40A05C470ADFBD6033B32A33A9EF7107", - "explanation": "The scripts run this test in its original application and test projects.", - "fingerprint": "C6F81EE75B4F5776C3CB88C0790CCE40A8B0FB14EB2795E34BA071A24C053D00" - }, - { - "id": "aa478d74f298d8c98e6cd1bf", - "file": ".docfx/api/types/Codebelt.Extensions.Xunit.Hosting.ManagedHostFixture.md", - "uid": "Codebelt.Extensions.Xunit.Hosting.ManagedHostFixture", - "sourceSha256": "6F9E6E2F82AB916A7A36CC2259AA97366A800843E8B1913EE7C2D79580861DA8", - "status": "ready", - "coverage": "Paired", - "reason": null, - "native": "Unverified", - "docker": "Unverified", - "strategy": "standalone", - "executionSourceSha256": "6F9E6E2F82AB916A7A36CC2259AA97366A800843E8B1913EE7C2D79580861DA8", - "nativeSha256": "EF304F357CADAA92BAFAE377C398A55E38DFDB48A2EC353243C80D4E81E77B9B", - "dockerSha256": "2F749D571D43DB8120BB7FA70FE171034D04095A7838ADDB508A39F42F808EC6", - "fingerprint": "CA30DC883593BFA97EAA8943231C79E90CD16CD297DA30AA78CE90A18E337389" - }, - { - "id": "6a59b7744a7d9994ffc04782", - "file": ".docfx/api/types/Codebelt.Extensions.Xunit.Hosting.ManagedMinimalHostFixture.md", - "uid": "Codebelt.Extensions.Xunit.Hosting.ManagedMinimalHostFixture", - "sourceSha256": "D0D64093FAF614E7658650534934F6771BB45486D43E7A241D573347840E6DBE", - "status": "ready", - "coverage": "Paired", - "reason": null, - "native": "Unverified", - "docker": "Unverified", - "strategy": "standalone", - "executionSourceSha256": "D0D64093FAF614E7658650534934F6771BB45486D43E7A241D573347840E6DBE", - "nativeSha256": "3E9A37ABCAA30C862A5FE6DF7354F02887711F8CB6F13144948B67C4859CB4C7", - "dockerSha256": "D092406830169606E94AFB3E260AC9150F5FD8537D97949AEAADCF2390EB8335", - "fingerprint": "5A8BC97B33361F12BDB4ACB1E3200DC5D7DBDA9EA79EC375A66E64F6CB7C6FF6" - }, - { - "id": "becb2fe7446fc1571dc86953", - "file": ".docfx/api/types/Codebelt.Extensions.Xunit.Hosting.MinimalHostFixtureExtensions.md", - "uid": "Codebelt.Extensions.Xunit.Hosting.MinimalHostFixtureExtensions", - "sourceSha256": "47A5CB15CC0563C81176ADE58748B75704DA88BCA3549BEF914BD63CED52125C", - "status": "ready", - "coverage": "Paired", - "reason": null, - "native": "Unverified", - "docker": "Unverified", - "strategy": "standalone", - "executionSourceSha256": "47A5CB15CC0563C81176ADE58748B75704DA88BCA3549BEF914BD63CED52125C", - "nativeSha256": "A01D226ACD37BD7A84079360C6D08F781F79071FDEB150509E7D6488D71EF6CD", - "dockerSha256": "2C48C5E7520D3260315548203BCB81821BCC4CB4AFFD04F40C008A43AEC443E3", - "fingerprint": "F8BC0F8D737E91FFF677EA9DEA538B892A8F4BAABF47CC0DBABCA4B1A0EE6438" - }, - { - "id": "e3f79d1c0f2fa85276cee2fb", - "file": ".docfx/api/types/Codebelt.Extensions.Xunit.Hosting.MinimalHostTestFactory.md", - "uid": "Codebelt.Extensions.Xunit.Hosting.MinimalHostTestFactory", - "sourceSha256": "45A7CCD7F1EF9A48A33565AEAC7B5A005AD4AA11E12ADD506911B10614205E87", - "status": "ready", - "coverage": "Paired", - "reason": null, - "native": "Unverified", - "docker": "Unverified", - "strategy": "standalone", - "executionSourceSha256": "45A7CCD7F1EF9A48A33565AEAC7B5A005AD4AA11E12ADD506911B10614205E87", - "nativeSha256": "652AA1DF3EFE2C767DC6BB49231655D70C5FB692176C2D4EE44A2C0F7E544351", - "dockerSha256": "D1A74874F6ECC77D3805F95937912E8CD5332354451F6352EE1E1844EC00ED9A", - "fingerprint": "DF06A1017F8A03A4E0AA021AE4F640FC50B3E62741CDAC93AE81F4B141E4CE64" - }, - { - "id": "515575be5bb7683cac9903a5", - "file": ".docfx/api/types/Codebelt.Extensions.Xunit.Hosting.SelfManagedHostFixture.md", - "uid": "Codebelt.Extensions.Xunit.Hosting.SelfManagedHostFixture", - "sourceSha256": "7B4FC8E01BFCFACAF488EB329E5F50B3F9EEB7F42BF26D59D54C6F69754FB32B", - "status": "ready", - "coverage": "Paired", - "reason": null, - "native": "Unverified", - "docker": "Unverified", - "strategy": "standalone", - "executionSourceSha256": "7B4FC8E01BFCFACAF488EB329E5F50B3F9EEB7F42BF26D59D54C6F69754FB32B", - "nativeSha256": "EC33997C2955527BE5B6D6DFE7A319EFBF797949CF91787E71215B0FF76BEB10", - "dockerSha256": "DEA080C70296E4B0AA6331EFB197A7B56CB5AF3F94E56E29B6BBA19E3EC999DC", - "fingerprint": "F48F89EE3931E463919D79B831586F4F9798EE12378580840DC0DA3F0743DD87" - }, - { - "id": "b4149382f121a5ffc3c057df", - "file": ".docfx/api/types/Codebelt.Extensions.Xunit.Hosting.SelfManagedMinimalHostFixture.md", - "uid": "Codebelt.Extensions.Xunit.Hosting.SelfManagedMinimalHostFixture", - "sourceSha256": "E1641265DF178540A21BD769CA1A9CD162901D03813C9D723B18349652B19A6B", - "status": "ready", - "coverage": "Paired", - "reason": null, - "native": "Unverified", - "docker": "Unverified", - "strategy": "standalone", - "executionSourceSha256": "E1641265DF178540A21BD769CA1A9CD162901D03813C9D723B18349652B19A6B", - "nativeSha256": "2EFA535B23B695DC37AD2B57EA35F34E1C74BFF3A6F1D0412533A44A83D8CB47", - "dockerSha256": "0E4457B530E5F0A88699557320B075D67AA1EDCF6C29E23DF65F47703783DE10", - "fingerprint": "61BC9501333A2EB14D92E8690516F50E2EC76E35BB255C4C75655F51F8CF2C0D" - }, - { - "id": "18b0746bf3da1d84f81b5274", - "file": ".docfx/api/types/Codebelt.Extensions.Xunit.Hosting.ServiceCollectionExtensions.md", - "uid": "Codebelt.Extensions.Xunit.Hosting.ServiceCollectionExtensions", - "sourceSha256": "96463CFB4DADE2AA027CBD21C1A8E380C83914669832CEE2C447DEDDCCAFC9C6", - "status": "ready", - "coverage": "Paired", - "reason": null, - "native": "Unverified", - "docker": "Unverified", - "strategy": "standalone", - "executionSourceSha256": "96463CFB4DADE2AA027CBD21C1A8E380C83914669832CEE2C447DEDDCCAFC9C6", - "nativeSha256": "04DFB6C123D4F64BBFD676004301C230C4890079AEE786268DE55F29FD9A0524", - "dockerSha256": "315963205760A4F53E6741B1E7644845BB86E126E2966B24B0CB2CC7C575784A", - "fingerprint": "4201A700A1FA92753B76E2C7099670B9723441B88BF131C021EEB25DCD5397F6" - }, - { - "id": "5e35a33e56470f93afbedf19", - "file": ".docfx/api/types/Codebelt.Extensions.Xunit.Hosting.ServiceProviderExtensions.md", - "uid": "Codebelt.Extensions.Xunit.Hosting.ServiceProviderExtensions", - "sourceSha256": "C9C4438BD3D356FA0C39F5F86FAF6E984D9A1253A0A5D8EAEAD280AAAB31569B", - "status": "ready", - "coverage": "Paired", - "reason": null, - "native": "Unverified", - "docker": "Unverified", - "strategy": "standalone", - "executionSourceSha256": "C9C4438BD3D356FA0C39F5F86FAF6E984D9A1253A0A5D8EAEAD280AAAB31569B", - "nativeSha256": "1F1F4DF2A749538293F3C8ED001011A8DD138AF5B0165BB074014F88C912D5AE", - "dockerSha256": "AF7459ACD9413EA459C895D20B663CD31C98627630C8EC2C8A7607F12269E0EE", - "fingerprint": "7E28693772859804C7B2AE8894C1F71A9CBA13E576832E0710E91B8BA2FDEF86" - }, - { - "id": "9a558a9a581c6b11ccb28057", - "file": ".docfx/api/types/Codebelt.Extensions.Xunit.Hosting.XunitTestLoggerEntry.md", - "uid": "Codebelt.Extensions.Xunit.Hosting.XunitTestLoggerEntry", - "sourceSha256": "5DBC97E4CD56C7D3072FE73E9BBA6F90326CFE7952A57823024464DA85802D3C", - "status": "ready", - "coverage": "Paired", - "reason": null, - "native": "Unverified", - "docker": "Unverified", - "strategy": "standalone", - "executionSourceSha256": "5DBC97E4CD56C7D3072FE73E9BBA6F90326CFE7952A57823024464DA85802D3C", - "nativeSha256": "0BE3FB9403B1DF69B5184F36076B931DFA28079CFC50831E6572D9F5D39F2FD5", - "dockerSha256": "D30CC9E29A61B6855437B25AA6CC9334E5100058EA557D6ECC237021E5F16A2C", - "fingerprint": "BC422D634237902A39DCE1A68C10E1A3BC9373A9C48211DCD15F145516495597" - }, - { - "id": "a31971b360a8c557b87f6684", - "file": ".docfx/api/types/Codebelt.Extensions.Xunit.InMemoryTestStore%601.md", - "uid": "Codebelt.Extensions.Xunit.InMemoryTestStore`1", - "sourceSha256": "71987946D4476C5106392E6DB007FE7B11CFE39D4EAA4CA1B04539D1EC7C7F7C", - "status": "ready", - "coverage": "Paired", - "reason": null, - "native": "Unverified", - "docker": "Unverified", - "strategy": "standalone", - "executionSourceSha256": "71987946D4476C5106392E6DB007FE7B11CFE39D4EAA4CA1B04539D1EC7C7F7C", - "nativeSha256": "48ECDD07B2B3FBF009FF56420A84B8E4BDA50E4BD11037D5449EF2E0753940CD", - "dockerSha256": "14610BFC498745D5F0F65A479E1F0948FEEFAD88ECE5E1CA9E908DD9E66D5A06", - "fingerprint": "D5911042EA2FB574417E1EB82A2DA5AF78C46C2B08252AACDFAEB6F27B64C733" - }, - { - "id": "812efaa205554c7bdcd80831", - "file": ".docfx/api/types/Codebelt.Extensions.Xunit.PriorityAttribute.md", - "uid": "Codebelt.Extensions.Xunit.PriorityAttribute", - "sourceSha256": "93FF0CA8DBB21BE3475B9DED2131644055C82C6BF81A6D5F51DE91564C44FD78", - "status": "ready", - "coverage": "Paired", - "reason": null, - "native": "Unverified", - "docker": "Unverified", - "strategy": "standalone", - "executionSourceSha256": "93FF0CA8DBB21BE3475B9DED2131644055C82C6BF81A6D5F51DE91564C44FD78", - "nativeSha256": "1FCF507A856F3FA1FCCD3D9EED5EC665166C6400C97531F8453D486293EF865E", - "dockerSha256": "21E060673DAD81133E5A4E64B1933DBC2F470B58D305124D84C36EAA036A13A3", - "fingerprint": "F2A918013C78A09A9F54561EFE5AB411D8D243D7DE0107F8480AA79B55B300AA" - }, - { - "id": "782f24d34260070258f6d164", - "file": ".docfx/api/types/Codebelt.Extensions.Xunit.PriorityTestMethodOrderer.md", - "uid": "Codebelt.Extensions.Xunit.PriorityTestMethodOrderer", - "sourceSha256": "8A21672EB35CB508A5A70D51D8813A009DE6C9B7099E766FDA6BBF8A6DA360BF", - "status": "ready", - "coverage": "Paired", - "reason": null, - "native": "Unverified", - "docker": "Unverified", - "strategy": "standalone", - "executionSourceSha256": "8A21672EB35CB508A5A70D51D8813A009DE6C9B7099E766FDA6BBF8A6DA360BF", - "nativeSha256": "3C454C6B5D05CFC25A6F25BCCAAA17399BB0C80101FDBBFACC7432C957693C76", - "dockerSha256": "1481D2DEF8DAD9F63BA7D6A63F2E38FDF949305C39AC9F5EECE536F2323C468A", - "fingerprint": "A2FF981D09ACB0024CB724A2BD47C52FDCFDF7D4514AC4C7E7FF5C6EA9CC2A76" - }, - { - "id": "545543e49c6bf054a9e06186", - "file": ".docfx/api/types/Codebelt.Extensions.Xunit.TestOutputHelperAccessor.md", - "uid": "Codebelt.Extensions.Xunit.TestOutputHelperAccessor", - "sourceSha256": "4C6461C6EBDE9468850148117F4972F3C9C25E6F22138521AAB7852B60162109", - "status": "ready", - "coverage": "Paired", - "reason": null, - "native": "Unverified", - "docker": "Unverified", - "strategy": "standalone", - "executionSourceSha256": "4C6461C6EBDE9468850148117F4972F3C9C25E6F22138521AAB7852B60162109", - "nativeSha256": "E295F5790E2B3AA6ED42E8FDAF044206BFC67C86181A3CB0BF99ADE740A00AD0", - "dockerSha256": "4EDE36D0EF2CAE28C9F28038DEF44F2A252586F7E00B4BFDD3CD31C4AD12FC29", - "fingerprint": "AC583D390F9AF07204935640F985FD019DCFE3F46B992BCCB960CF149A00BC05" - }, - { - "id": "45fcccef5fc861315b50c55e", - "file": ".docfx/api/types/Codebelt.Extensions.Xunit.TestOutputHelperExtensions.md", - "uid": "Codebelt.Extensions.Xunit.TestOutputHelperExtensions", - "sourceSha256": "BE11774854DE0AF823285BDCAD5BF6B02FD6CFF9D1673B10C6F0CE3D043E5799", - "status": "ready", - "coverage": "Paired", - "reason": null, - "native": "Unverified", - "docker": "Unverified", - "strategy": "standalone", - "executionSourceSha256": "BE11774854DE0AF823285BDCAD5BF6B02FD6CFF9D1673B10C6F0CE3D043E5799", - "nativeSha256": "C5D9FE38737F8405E2A24F62E0BE1123CE726946DC2B470ABC66885A3A7D0FE3", - "dockerSha256": "E85250AB23232BBC8A39A415D29851684E1E5840D6BB74E9F9E163DCB88E2D27", - "fingerprint": "202AD27A002509FFDB47270EEF56FF4F9F0D984B6F10A4EAF63B43B41C74F282" - }, - { - "id": "578d467fd203f66cc41b0364", - "file": ".docfx/api/types/Codebelt.Extensions.Xunit.TestOutputHelperExtensions.md", - "uid": "Codebelt.Extensions.Xunit.TestOutputHelperExtensions.WriteLines(Xunit.ITestOutputHelper,System.Object[])", - "sourceSha256": "985FBA10ABE737D5BEE72A19B028BCA6739A84C7B790695AEEC66BCC73BE7713", - "status": "ready", - "coverage": "Paired", - "reason": null, - "native": "Unverified", - "docker": "Unverified", - "strategy": "standalone", - "executionSourceSha256": "985FBA10ABE737D5BEE72A19B028BCA6739A84C7B790695AEEC66BCC73BE7713", - "nativeSha256": "EB8430E3CB36D238D0A3FB224FB3964F25AB50BE7A58E6A6281D8F6383E15FE7", - "dockerSha256": "D48979DD608DC5AF7114556E34565563A73881D76F48CF0332749E07B14A02B0", - "fingerprint": "D431B184DFEF46EC133B1A4262BC6206EB416457A369B3E3829D9FF347988F92" - }, - { - "id": "10457ac34cce1cbadb26aee1", - "file": ".docfx/api/types/Codebelt.Extensions.Xunit.TestOutputHelperExtensions.md", - "uid": "Codebelt.Extensions.Xunit.TestOutputHelperExtensions.WriteLines``1(Xunit.ITestOutputHelper,``0[])", - "sourceSha256": "32E90B18345F4AF2EDBA67EDA4F5D6B231292147F40B9B541243F22A2DE71426", - "status": "ready", - "coverage": "Paired", - "reason": null, - "native": "Unverified", - "docker": "Unverified", - "strategy": "standalone", - "executionSourceSha256": "32E90B18345F4AF2EDBA67EDA4F5D6B231292147F40B9B541243F22A2DE71426", - "nativeSha256": "9D0818019F4175B95983A9A7E26083327E94FCE332DD048D52C0A64F8A8CDBC4", - "dockerSha256": "D5885F41A9F6571A9DC3EDA2B4A70C043F7BBA64ECBC9C396902AF9E51E3F861", - "fingerprint": "7FA9A89BFA46E211F8ED3828265F18FEA26501F62BF39626F36111718268B943" - }, - { - "id": "0308118a47b5c02daa7b32be", - "file": ".docfx/api/types/Codebelt.Extensions.Xunit.TestOutputHelperExtensions.md", - "uid": "Codebelt.Extensions.Xunit.TestOutputHelperExtensions.WriteLines``1(Xunit.ITestOutputHelper,System.Collections.Generic.IEnumerable{``0})", - "sourceSha256": "6BF4CBD17324584A087D6EF92F873474DD288AA42EAB5DB33665CADCFEF49734", - "status": "ready", - "coverage": "Paired", - "reason": null, - "native": "Unverified", - "docker": "Unverified", - "strategy": "standalone", - "executionSourceSha256": "6BF4CBD17324584A087D6EF92F873474DD288AA42EAB5DB33665CADCFEF49734", - "nativeSha256": "C516047E808D34DE61362463930D041534EDCB37E1259A39D0389BCB678E25AC", - "dockerSha256": "6E87D2E82F764DBD8CB4F85B93252FEFCAB8412D2A96420F152334A3FEF08A2F", - "fingerprint": "ABD62270C56A09E35C9D0661558F886AE9AE1701277F5B066E2CC47ECD457C32" - }, - { - "id": "038a1c806225b412a6f986c1", - "file": ".docfx/api/types/Codebelt.Extensions.Xunit.WildcardOptions.md", - "uid": "Codebelt.Extensions.Xunit.WildcardOptions", - "sourceSha256": "9E421444D2AB0A979A150637043D0070DCB60D5517C3E595AB902F7C3A7A17E9", - "status": "ready", - "coverage": "Paired", - "reason": null, - "native": "Unverified", - "docker": "Unverified", - "strategy": "standalone", - "executionSourceSha256": "9E421444D2AB0A979A150637043D0070DCB60D5517C3E595AB902F7C3A7A17E9", - "nativeSha256": "32DBA22B6B9B7D8747E9A56E40246D796B1B839C9CBCC199D050020AEF20577F", - "dockerSha256": "3696C9F661DEF0F6756F83F6ADE46D0FCCDE062EE72CE2D25DE3083AC2CB889A", - "fingerprint": "E748694BBF63611BC8E483D9F5AB3C9E915224B68C75FE22BF6A7B39F7F0DF39" - } - ] -} diff --git a/.gitignore b/.gitignore index 03ef557..79d58eb 100644 --- a/.gitignore +++ b/.gitignore @@ -367,6 +367,7 @@ FodyWeavers.xsd /.docfx/api/**/*.yml /.docfx/**/*.manifest /.docfx/.vscode/docfx-assistant +/.docfx/run-actions/ ### VisualStudioCode ### .vscode/* From 2cee198e1ecd14150ddc61095ea8a2cc58e90f62 Mon Sep 17 00:00:00 2001 From: gimlichael Date: Sat, 21 Nov 2026 00:57:38 +0100 Subject: [PATCH 06/12] =?UTF-8?q?=F0=9F=94=A7=20improve=20error=20handling?= =?UTF-8?q?=20for=20missing=20run-actions=20manifest?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .docfx/BuildRunActions.ps1 | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/.docfx/BuildRunActions.ps1 b/.docfx/BuildRunActions.ps1 index b698540..5aa1223 100644 --- a/.docfx/BuildRunActions.ps1 +++ b/.docfx/BuildRunActions.ps1 @@ -9,7 +9,11 @@ $PSNativeCommandUseErrorActionPreference = $false Set-StrictMode -Version Latest if (-not (Test-Path -LiteralPath $ManifestPath -PathType Leaf)) { - throw "Run-actions manifest not found: $ManifestPath" + if ($PSBoundParameters.ContainsKey('ManifestPath')) { + throw "Run-actions manifest not found: $ManifestPath" + } + Write-Host "No run-actions manifest found at $ManifestPath; skipping." + return } $CsrunTestVerificationTemplate = @' From 8c4f1ea9286db9e5aa66ad2345f0c508755e31db Mon Sep 17 00:00:00 2001 From: gimlichael Date: Sat, 21 Nov 2026 01:20:33 +0100 Subject: [PATCH 07/12] =?UTF-8?q?=E2=9C=A8=20add=20onCopyFailure=20callbac?= =?UTF-8?q?k=20to=20createAction=20for=20better=20error=20handling?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .docfx/templates/modern/public/run-actions.js | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/.docfx/templates/modern/public/run-actions.js b/.docfx/templates/modern/public/run-actions.js index 7106777..6f57db6 100644 --- a/.docfx/templates/modern/public/run-actions.js +++ b/.docfx/templates/modern/public/run-actions.js @@ -40,7 +40,7 @@ function previewScript(script, label) { dialog.showModal(); } -function createAction(link, report) { +function createAction(link, report, onCopyFailure) { const transport = link.dataset.transport; const label = transport === 'native' ? 'Native' : 'Docker'; const name = 'Copy ' + label + ' run script'; @@ -97,21 +97,22 @@ function createAction(link, report) { report(label + ' script copied.', true); } } catch { + if (!preview) onCopyFailure?.(); report('Could not ' + (preview ? 'preview ' : 'copy ') + label + ' script.'); } finally { pending = false; } } - button.addEventListener('click', event => act(event.shiftKey)); + button.addEventListener('click', event => { void act(event.shiftKey); }); button.addEventListener('contextmenu', event => { event.preventDefault(); - act(true); + void act(true); }); button.addEventListener('keydown', event => { if (event.shiftKey && event.key === 'Enter') { event.preventDefault(); - act(true); + void act(true); } }); return button; @@ -144,7 +145,7 @@ export function enhanceRunActions(root = document) { } function attachToolbar(pre, links, assets) { - if (links.hasAttribute('data-enhanced')) return; + if ('enhanced' in links.dataset) return; const toolbar = document.createElement('span'); toolbar.className = 'docfx-run-toolbar'; toolbar.setAttribute('role', 'group'); @@ -159,7 +160,7 @@ function attachToolbar(pre, links, assets) { status.textContent = message; if (message) clearStatus = setTimeout(() => { status.textContent = ''; }, 3000); } - toolbar.append(...assets.map(link => createAction(link, report))); + toolbar.append(...assets.map(link => createAction(link, report, () => { links.hidden = false; }))); // Keep our nodes before DocFX's Lit render range, which replaces the original anchor on copy. pre.prepend(toolbar, status); pre.classList.add('docfx-runnable'); From 4d6eff105ea03eeac7b969a0a976114c6a41698a Mon Sep 17 00:00:00 2001 From: gimlichael Date: Sat, 21 Nov 2026 02:59:51 +0100 Subject: [PATCH 08/12] =?UTF-8?q?=E2=99=BB=EF=B8=8F=20clean=20up=20stale?= =?UTF-8?q?=20run-action=20scripts=20based=20on=20expected=20scripts=20tra?= =?UTF-8?q?cking?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .docfx/BuildRunActions.ps1 | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/.docfx/BuildRunActions.ps1 b/.docfx/BuildRunActions.ps1 index 5aa1223..7a2680b 100644 --- a/.docfx/BuildRunActions.ps1 +++ b/.docfx/BuildRunActions.ps1 @@ -233,6 +233,7 @@ $doc = Get-Content -LiteralPath $ManifestPath -Raw | ConvertFrom-Json -AsHashtab if ($doc.schemaVersion -ne 1) { throw "Unsupported run-actions manifest schemaVersion: $($doc.schemaVersion)" } $examples = @($doc.examples) $utf8NoBom = [Text.UTF8Encoding]::new($false) +$expectedScripts = [Collections.Generic.HashSet[string]]::new([StringComparer]::Ordinal) $written = 0 foreach ($example in $examples) { @@ -257,8 +258,26 @@ foreach ($example in $examples) { $null = [IO.Directory]::CreateDirectory($dir) [IO.File]::WriteAllText($path, $scriptText, $utf8NoBom) } + $null = $expectedScripts.Add("$id/$transport.ps1") $written++ } } +if (Test-Path -LiteralPath $OutputRoot -PathType Container) { + foreach ($exampleDir in @(Get-ChildItem -LiteralPath $OutputRoot -Directory)) { + if ($exampleDir.Name -cnotmatch '^[a-f0-9]{24}$' -or + ($exampleDir.Attributes -band [IO.FileAttributes]::ReparsePoint)) { continue } + foreach ($name in @('native.ps1', 'docker.ps1')) { + if ($expectedScripts.Contains("$($exampleDir.Name)/$name")) { continue } + $stalePath = Join-Path $exampleDir.FullName $name + if (Test-Path -LiteralPath $stalePath -PathType Leaf) { + Remove-Item -LiteralPath $stalePath -Force + } + } + if (-not @(Get-ChildItem -LiteralPath $exampleDir.FullName -Force).Count) { + Remove-Item -LiteralPath $exampleDir.FullName + } + } +} + Write-Host "Materialized $written run-action script(s) for $($examples.Count) example(s) into $OutputRoot." From e17597073cf094ad48d7ede40fabfe8bef45df4a Mon Sep 17 00:00:00 2001 From: aicia-bot Date: Sat, 21 Nov 2026 03:43:47 +0100 Subject: [PATCH 09/12] =?UTF-8?q?=F0=9F=93=9D=20document=20availability=20?= =?UTF-8?q?include=20placement=20for=20api=20pages?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Availability includes belong on namespace overview pages only. The AGENTS.md rule now states that includes are never allowed on type pages or other files under .docfx/api/, and that only DocFX Markdown under that folder may be modified, so the agent guidance matches how the docs are structured. --- AGENTS.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/AGENTS.md b/AGENTS.md index 4a50ad3..d9043a2 100644 --- a/AGENTS.md +++ b/AGENTS.md @@ -322,7 +322,7 @@ Both namespace overwrite files and type overwrite files are required deliverable `docfx.json` must keep namespace and type overwrite files in separate subdirectories. `build.overwrite` must include both `api/namespaces/**/*.md` (for namespace pages) and `api/types/**/*.md` (for type pages). `build.content` must exclude both `api/namespaces/**` and `api/types/**` to prevent overwrite Markdown from being treated as conceptual content. Do not use `api/**/*.md` under `build.overwrite` or `build.content`. -Availability must be documented by referencing the appropriate include file when one exists, or by adding explicit availability text when no suitable include exists. Availability must reflect the actual target frameworks, conditional compilation, and project configuration. +Availability must be documented on namespace overview pages under `.docfx/api/namespaces/*` by referencing the appropriate `[!INCLUDE ...]` file when one exists, or by adding explicit availability text when no suitable include exists. Under `.docfx/api/`, `[!INCLUDE ...]` directives are only allowed in `.docfx/api/namespaces/*` — never on type pages (`.docfx/api/types/*`), never in other files under `.docfx/api/`, and never after examples. Only modify DocFX Markdown files under `.docfx/api/`; leave Markdown files outside `.docfx/api/` untouched. Availability must reflect the actual target frameworks, conditional compilation, and project configuration. For conditionally compiled APIs, choose the executable test framework from the asset that contains the API. Inspect the preprocessor condition, project TFMs, package `lib/` assets, and resolved consumer asset before changing a sample. For APIs under `NETSTANDARD2_0` or `NETSTANDARD2_0_OR_GREATER`, when modern `lib/netX.0/` assets also exist, use `net48` (or another supported .NET Framework target from `net462` onward) so the consumer selects `lib/netstandard2.0/`. Never use `netstandard*` as an executable target, and never use a modern `netX.0` target when it selects an asset where the API is absent. For other TFM guards, select a runnable consumer TFM that resolves to the containing asset and confirm that selection from restore or build evidence. From 798a7ef9fa511efadccb968e4867cec6aa3b5cbe Mon Sep 17 00:00:00 2001 From: aicia-bot Date: Sat, 21 Nov 2026 03:43:47 +0100 Subject: [PATCH 10/12] =?UTF-8?q?=F0=9F=94=A5=20remove=20availability=20in?= =?UTF-8?q?clude=20from=20api=20type=20pages?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Type overwrite pages must not contain availability includes, since those are only permitted on namespace overview pages. Removing the include from the six affected type pages brings them in line with that rule. --- .../types/Codebelt.Extensions.Xunit.InMemoryTestStore%601.md | 2 -- .docfx/api/types/Codebelt.Extensions.Xunit.PriorityAttribute.md | 2 -- .../Codebelt.Extensions.Xunit.PriorityTestMethodOrderer.md | 2 -- .../types/Codebelt.Extensions.Xunit.TestOutputHelperAccessor.md | 2 -- .../Codebelt.Extensions.Xunit.TestOutputHelperExtensions.md | 2 -- .docfx/api/types/Codebelt.Extensions.Xunit.WildcardOptions.md | 2 -- 6 files changed, 12 deletions(-) diff --git a/.docfx/api/types/Codebelt.Extensions.Xunit.InMemoryTestStore%601.md b/.docfx/api/types/Codebelt.Extensions.Xunit.InMemoryTestStore%601.md index bb877f0..d9459b4 100644 --- a/.docfx/api/types/Codebelt.Extensions.Xunit.InMemoryTestStore%601.md +++ b/.docfx/api/types/Codebelt.Extensions.Xunit.InMemoryTestStore%601.md @@ -37,5 +37,3 @@ public sealed class RunExample - -[!INCLUDE [availability-default](../../includes/availability-default.md)] diff --git a/.docfx/api/types/Codebelt.Extensions.Xunit.PriorityAttribute.md b/.docfx/api/types/Codebelt.Extensions.Xunit.PriorityAttribute.md index 11044a2..1f29891 100644 --- a/.docfx/api/types/Codebelt.Extensions.Xunit.PriorityAttribute.md +++ b/.docfx/api/types/Codebelt.Extensions.Xunit.PriorityAttribute.md @@ -38,5 +38,3 @@ public class InitializationTest : Test - -[!INCLUDE [availability-default](../../includes/availability-default.md)] diff --git a/.docfx/api/types/Codebelt.Extensions.Xunit.PriorityTestMethodOrderer.md b/.docfx/api/types/Codebelt.Extensions.Xunit.PriorityTestMethodOrderer.md index bf4b088..ff42450 100644 --- a/.docfx/api/types/Codebelt.Extensions.Xunit.PriorityTestMethodOrderer.md +++ b/.docfx/api/types/Codebelt.Extensions.Xunit.PriorityTestMethodOrderer.md @@ -40,5 +40,3 @@ public class CacheLifecycleTest : Test - -[!INCLUDE [availability-default](../../includes/availability-default.md)] diff --git a/.docfx/api/types/Codebelt.Extensions.Xunit.TestOutputHelperAccessor.md b/.docfx/api/types/Codebelt.Extensions.Xunit.TestOutputHelperAccessor.md index 41e5bc6..72aabcb 100644 --- a/.docfx/api/types/Codebelt.Extensions.Xunit.TestOutputHelperAccessor.md +++ b/.docfx/api/types/Codebelt.Extensions.Xunit.TestOutputHelperAccessor.md @@ -28,5 +28,3 @@ public class OutputAccessorTest : Test - -[!INCLUDE [availability-default](../../includes/availability-default.md)] diff --git a/.docfx/api/types/Codebelt.Extensions.Xunit.TestOutputHelperExtensions.md b/.docfx/api/types/Codebelt.Extensions.Xunit.TestOutputHelperExtensions.md index 345ea72..c77d208 100644 --- a/.docfx/api/types/Codebelt.Extensions.Xunit.TestOutputHelperExtensions.md +++ b/.docfx/api/types/Codebelt.Extensions.Xunit.TestOutputHelperExtensions.md @@ -29,8 +29,6 @@ public class OutputLinesTest : Test -[!INCLUDE [availability-default](../../includes/availability-default.md)] - --- uid: Codebelt.Extensions.Xunit.TestOutputHelperExtensions.WriteLines(Xunit.ITestOutputHelper,System.Object[]) example: diff --git a/.docfx/api/types/Codebelt.Extensions.Xunit.WildcardOptions.md b/.docfx/api/types/Codebelt.Extensions.Xunit.WildcardOptions.md index fee7104..4449660 100644 --- a/.docfx/api/types/Codebelt.Extensions.Xunit.WildcardOptions.md +++ b/.docfx/api/types/Codebelt.Extensions.Xunit.WildcardOptions.md @@ -28,5 +28,3 @@ public class WildcardExampleTest : Test - -[!INCLUDE [availability-default](../../includes/availability-default.md)] From 4699abd3c6fa17c5dc70f06bc897ecbe3c43476b Mon Sep 17 00:00:00 2001 From: gimlichael Date: Sat, 21 Nov 2026 04:12:49 +0100 Subject: [PATCH 11/12] =?UTF-8?q?=E2=9C=A8=20add=20missing=20closing=20bra?= =?UTF-8?q?ce=20to=20WebApplicationTestTest=20class?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ....Xunit.Hosting.AspNetCore.ManagedWebApplicationFixture%601.md | 1 + 1 file changed, 1 insertion(+) diff --git a/.docfx/api/types/Codebelt.Extensions.Xunit.Hosting.AspNetCore.ManagedWebApplicationFixture%601.md b/.docfx/api/types/Codebelt.Extensions.Xunit.Hosting.AspNetCore.ManagedWebApplicationFixture%601.md index 49b7d72..5dca623 100644 --- a/.docfx/api/types/Codebelt.Extensions.Xunit.Hosting.AspNetCore.ManagedWebApplicationFixture%601.md +++ b/.docfx/api/types/Codebelt.Extensions.Xunit.Hosting.AspNetCore.ManagedWebApplicationFixture%601.md @@ -39,6 +39,7 @@ public class WebApplicationTestTest : WebApplicationTest From 6ceaab03109302b94e5e62687fb16c15486a2850 Mon Sep 17 00:00:00 2001 From: gimlichael Date: Sat, 21 Nov 2026 04:12:53 +0100 Subject: [PATCH 12/12] =?UTF-8?q?=E2=9C=A8=20refactor=20program=20structur?= =?UTF-8?q?e=20for=20better=20readability=20and=20organization?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ...ng.AspNetCore.SelfManagedWebHostFixture.md | 24 +++++++++++++------ 1 file changed, 17 insertions(+), 7 deletions(-) diff --git a/.docfx/api/types/Codebelt.Extensions.Xunit.Hosting.AspNetCore.SelfManagedWebHostFixture.md b/.docfx/api/types/Codebelt.Extensions.Xunit.Hosting.AspNetCore.SelfManagedWebHostFixture.md index f036a2f..df3397e 100644 --- a/.docfx/api/types/Codebelt.Extensions.Xunit.Hosting.AspNetCore.SelfManagedWebHostFixture.md +++ b/.docfx/api/types/Codebelt.Extensions.Xunit.Hosting.AspNetCore.SelfManagedWebHostFixture.md @@ -9,21 +9,31 @@ Use `SelfManagedWebHostFixture` when a conventional test pipeline must exist bef ```csharp // Program.cs using System; +using System.Net.Http; +using System.Threading.Tasks; using Codebelt.Extensions.Xunit.Hosting.AspNetCore; using Microsoft.AspNetCore.Builder; using Microsoft.AspNetCore.Http; using Microsoft.AspNetCore.TestHost; using Microsoft.Extensions.Hosting; -using var host = WebHostTestFactory.Create( - pipelineSetup: app => app.Run(context => - context.Response.WriteAsync("started on demand")), - hostFixture: new SelfManagedWebHostFixture()); +namespace Codebelt.Extensions.Xunit.Hosting.AspNetCore; -await host.Host.StartAsync().ConfigureAwait(false); -using var client = host.Host.GetTestClient(); +public class Program +{ + public static async Task Main(string[] args) + { + using var host = WebHostTestFactory.Create( + pipelineSetup: app => app.Run(context => + context.Response.WriteAsync("started on demand")), + hostFixture: new SelfManagedWebHostFixture()); -Console.WriteLine(await client.GetStringAsync("/").ConfigureAwait(false)); + await host.Host.StartAsync().ConfigureAwait(false); + using var client = host.Host.GetTestClient(); + + Console.WriteLine(await client.GetStringAsync("/").ConfigureAwait(false)); + } +} ```