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