27 lines
933 B
C#
27 lines
933 B
C#
using System.Text.Json;
|
|
using VolcanicCore.Api.Registries;
|
|
using VolcanicCore.Core;
|
|
|
|
namespace VolcanicCore.Tests;
|
|
|
|
public class ConnectionProviderRegistryTests
|
|
{
|
|
private sealed class FakeProvider : IConnectionProvider
|
|
{
|
|
public string Id => "test.provider";
|
|
public string DisplayName => "Fake";
|
|
public JsonSchema ConfigSchema => new(JsonDocument.Parse("{}").RootElement);
|
|
public IReadOnlySet<string> SecretFields => new HashSet<string>();
|
|
public Task<object> OpenAsync(JsonElement config, CancellationToken ct) => Task.FromResult<object>(new());
|
|
public Task CloseAsync(object handle) => Task.CompletedTask;
|
|
}
|
|
|
|
[Fact]
|
|
public void Registers_and_looks_up_by_id()
|
|
{
|
|
var reg = new ConnectionProviderRegistry(new IConnectionProvider[] { new FakeProvider() });
|
|
Assert.Single(reg.All);
|
|
Assert.Same(reg.All[0], reg.Get("test.provider"));
|
|
}
|
|
}
|