Use system time in Orleans test silo
This commit is contained in:
parent
d7aa3fcbb9
commit
6c0a6be872
|
|
@ -1,8 +1,6 @@
|
||||||
using Microsoft.Extensions.DependencyInjection;
|
using Microsoft.Extensions.DependencyInjection;
|
||||||
using Microsoft.Extensions.Logging;
|
|
||||||
using Orleans.Hosting;
|
using Orleans.Hosting;
|
||||||
using Orleans.TestingHost;
|
using Orleans.TestingHost;
|
||||||
using Vanguard.Rules.Cards;
|
|
||||||
using Vanguard.Rules.Engine;
|
using Vanguard.Rules.Engine;
|
||||||
using Vanguard.Server.Configuration;
|
using Vanguard.Server.Configuration;
|
||||||
using Vanguard.Server.Matches;
|
using Vanguard.Server.Matches;
|
||||||
|
|
@ -14,17 +12,14 @@ namespace Vanguard.Server.Tests;
|
||||||
|
|
||||||
public class OrleansMatchTests
|
public class OrleansMatchTests
|
||||||
{
|
{
|
||||||
private static readonly DateTimeOffset Start = new(2026, 10, 21, 12, 0, 0, TimeSpan.Zero);
|
|
||||||
|
|
||||||
[Fact]
|
[Fact]
|
||||||
public async Task Grain_Initializes_Attaches_And_Submits_Intent()
|
public async Task Grain_Initializes_Attaches_And_Submits_Intent()
|
||||||
{
|
{
|
||||||
var time = new FakeTimeProvider(Start);
|
|
||||||
var connections = new MatchConnectionRegistry();
|
var connections = new MatchConnectionRegistry();
|
||||||
var results = new RecordingResultSink();
|
var results = new RecordingResultSink();
|
||||||
|
|
||||||
var builder = new TestClusterBuilder();
|
var builder = new TestClusterBuilder();
|
||||||
SiloConfigurator.Set(time, connections, results);
|
SiloConfigurator.Set(connections, results);
|
||||||
builder.AddSiloBuilderConfigurator<SiloConfigurator>();
|
builder.AddSiloBuilderConfigurator<SiloConfigurator>();
|
||||||
var cluster = builder.Build();
|
var cluster = builder.Build();
|
||||||
|
|
||||||
|
|
@ -80,36 +75,26 @@ public class OrleansMatchTests
|
||||||
|
|
||||||
private sealed class SiloConfigurator : ISiloConfigurator
|
private sealed class SiloConfigurator : ISiloConfigurator
|
||||||
{
|
{
|
||||||
private static FakeTimeProvider _time = null!;
|
|
||||||
private static IMatchConnectionRegistry _connections = null!;
|
private static IMatchConnectionRegistry _connections = null!;
|
||||||
private static IMatchResultSink _results = null!;
|
private static IMatchResultSink _results = null!;
|
||||||
|
|
||||||
public static void Set(
|
public static void Set(
|
||||||
FakeTimeProvider time,
|
|
||||||
IMatchConnectionRegistry connections,
|
IMatchConnectionRegistry connections,
|
||||||
IMatchResultSink results)
|
IMatchResultSink results)
|
||||||
{
|
{
|
||||||
_time = time;
|
|
||||||
_connections = connections;
|
_connections = connections;
|
||||||
_results = results;
|
_results = results;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void Configure(ISiloBuilder siloBuilder)
|
public void Configure(ISiloBuilder siloBuilder)
|
||||||
{
|
{
|
||||||
siloBuilder.ConfigureLogging(logging =>
|
|
||||||
{
|
|
||||||
logging.ClearProviders();
|
|
||||||
logging.AddConsole();
|
|
||||||
logging.SetMinimumLevel(LogLevel.Debug);
|
|
||||||
});
|
|
||||||
|
|
||||||
siloBuilder.ConfigureServices(services =>
|
siloBuilder.ConfigureServices(services =>
|
||||||
{
|
{
|
||||||
var options = ServerTestData.SmallOptions();
|
var options = ServerTestData.SmallOptions();
|
||||||
|
|
||||||
services.AddSingleton(ServerTestData.Catalog);
|
services.AddSingleton(ServerTestData.Catalog);
|
||||||
services.AddSingleton(options);
|
services.AddSingleton(options);
|
||||||
services.AddSingleton<TimeProvider>(_time);
|
services.AddSingleton(TimeProvider.System);
|
||||||
services.AddSingleton<IMatchResultSink>(_results);
|
services.AddSingleton<IMatchResultSink>(_results);
|
||||||
services.AddSingleton<IMatchStore, NullMatchStore>();
|
services.AddSingleton<IMatchStore, NullMatchStore>();
|
||||||
services.AddSingleton<IMatchConnectionRegistry>(_connections);
|
services.AddSingleton<IMatchConnectionRegistry>(_connections);
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue