![]() |
VOOZH | about |
dotnet add package GeoLibrary.ORiN3.Provider.TestBaseLib --version 1.0.0
NuGet\Install-Package GeoLibrary.ORiN3.Provider.TestBaseLib -Version 1.0.0
<PackageReference Include="GeoLibrary.ORiN3.Provider.TestBaseLib" Version="1.0.0" />
<PackageVersion Include="GeoLibrary.ORiN3.Provider.TestBaseLib" Version="1.0.0" />Directory.Packages.props
<PackageReference Include="GeoLibrary.ORiN3.Provider.TestBaseLib" />Project file
paket add GeoLibrary.ORiN3.Provider.TestBaseLib --version 1.0.0
#r "nuget: GeoLibrary.ORiN3.Provider.TestBaseLib, 1.0.0"
#:package GeoLibrary.ORiN3.Provider.TestBaseLib@1.0.0
#addin nuget:?package=GeoLibrary.ORiN3.Provider.TestBaseLib&version=1.0.0Install as a Cake Addin
#tool nuget:?package=GeoLibrary.ORiN3.Provider.TestBaseLib&version=1.0.0Install as a Cake Tool
TestBaseLib is a library that provides utilities and base classes for testing ORiN3 providers. It includes the ProviderTestFixture class, which simplifies the setup and teardown of test environments for ORiN3 provider implementations.
The ProviderTestFixture class is a generic fixture class designed to manage the lifecycle of ORiN3 provider test environments. Below is an example of how to use it in a test class.
When testing ORiN3 providers, it is important to disable certain checks to avoid unnecessary dependencies during the test process.
Ensure that similar configurations are applied in your test RootObject implementations to streamline the testing process.
ProviderTestFixtureProviderTestFixture to Your Test Class:IClassFixture<ProviderTestFixture<T>> interface in your test class, where T is the test class itself.InitAsync<S> method to initialize the test environment with a specific RootObject implementation. Replace S with the type of the RootObject you want to test._fixture.Root to access the initialized RootObject and perform operations.IDisposable interface in your test class to clean up resources, such as CancellationTokenSource.ProviderTestFixtureInitAsync<S>(ITestOutputHelper outputHelper, CancellationToken token, uint timeoutIntervalMilliseconds = 1000000)RootObject implementation.outputHelper: The ITestOutputHelper instance for logging test output.token: A CancellationToken to manage the initialization process.timeoutIntervalMilliseconds: (Optional) Timeout interval for initialization.S: The type of the RootObject to initialize.Dispose()This project is licensed under the .
ProviderTestFixture in a Test Classusing GeoLibrary.ORiN3.Provider.TestBaseLib;
using Xunit.Abstractions;
internal class SomeProviderRootForTest : SomeProviderRoot
{
static SomeProviderRootForTest()
{
AuthorityCheckEnabled = false;
}
}
public class SomeProviderTest : IClassFixture<ProviderTestFixture<SomeProviderTest>>, IDisposable
{
private readonly ITestOutputHelper _output;
private readonly ProviderTestFixture<SomeProviderTest> _fixture;
private readonly CancellationTokenSource _tokenSource = new(10000);
public SomeProviderTest(ProviderTestFixture<SomeProviderTest> fixture, ITestOutputHelper output)
{
_fixture = fixture;
_output = output;
// Initialize the test environment with a specific RootObject implementation
_fixture.InitAsync<SomeProviderRootForTest>(_output, _tokenSource.Token).Wait();
}
public void Dispose()
{
// Dispose of resources
_tokenSource.Dispose();
GC.SuppressFinalize(this);
}
[Fact]
public async Task ExampleTest()
{
// Arrange
var controller = await _fixture.Root.CreateControllerAsync(
name: "ExampleController",
typeName: "ExampleNamespace.ExampleController, ExampleAssembly",
option: "{\"@Version\":\"1.0.0\",\"ExampleOption\":\"value\"}",
token: _tokenSource.Token);
// Act
var result = await controller.ExecuteAsync("ExampleCommand", new Dictionary<string, object?>(), _tokenSource.Token);
// Assert
Assert.NotNull(result);
}
}
TestBaseLib は ORiN3 プロバイダのテストに必要なユーティリティやベースクラスを提供するライブラリです。ProviderTestFixture クラスを利用することで、ORiN3 プロバイダ実装のテスト環境の構築と解体を簡単に行えます。
ProviderTestFixture クラスは、ORiN3 プロバイダのテスト環境のライフサイクルを管理する汎用的なフィクスチャクラスです。以下に使用例を示します。
ORiN3 プロバイダのテスト時には、不要な依存関係を避けるために一部のチェックを無効にすることが重要です。
テスト用の RootObject 実装にも同様の設定を適用することで、テストの効率化が図れます。
ProviderTestFixture を追加:IClassFixture<ProviderTestFixture<T>> を実装してください。ここで T は自身のテストクラス型です。InitAsync<S> メソッドを使用し、指定の RootObject 実装でテスト環境を初期化します。S はテスト対象の RootObject 型です。_fixture.Root を使って初期化された RootObject にアクセスし、操作を行います。IDisposable を実装し、CancellationTokenSource などのリソースを明示的に解放します。ProviderTestFixtureInitAsync<S>(ITestOutputHelper outputHelper, CancellationToken token, uint timeoutIntervalMilliseconds = 1000000)RootObject 実装でテスト環境を初期化します。outputHelper: テスト出力用の ITestOutputHelper インスタンス。token: 初期化を制御する CancellationToken。timeoutIntervalMilliseconds: (任意)初期化のタイムアウト(ミリ秒)。S: 初期化する RootObject の型。Dispose()このプロジェクトは のもとでライセンスされています。
使用例: ProviderTestFixture を用いたテストクラス (※ C#コードは英語版を参照してください。)
| Product | Versions Compatible and additional computed target framework versions. |
|---|---|
| .NET | net8.0 net8.0 is compatible. net8.0-android net8.0-android was computed. net8.0-browser net8.0-browser was computed. net8.0-ios net8.0-ios was computed. net8.0-maccatalyst net8.0-maccatalyst was computed. net8.0-macos net8.0-macos was computed. net8.0-tvos net8.0-tvos was computed. net8.0-windows net8.0-windows was computed. net9.0 net9.0 was computed. net9.0-android net9.0-android was computed. net9.0-browser net9.0-browser was computed. net9.0-ios net9.0-ios was computed. net9.0-maccatalyst net9.0-maccatalyst was computed. net9.0-macos net9.0-macos was computed. net9.0-tvos net9.0-tvos was computed. net9.0-windows net9.0-windows was computed. net10.0 net10.0 was computed. net10.0-android net10.0-android was computed. net10.0-browser net10.0-browser was computed. net10.0-ios net10.0-ios was computed. net10.0-maccatalyst net10.0-maccatalyst was computed. net10.0-macos net10.0-macos was computed. net10.0-tvos net10.0-tvos was computed. net10.0-windows net10.0-windows was computed. |
This package is not used by any NuGet packages.
This package is not used by any popular GitHub repositories.
| Version | Downloads | Last Updated |
|---|---|---|
| 1.0.0 | 234 | 5/9/2025 |
First release.