-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathCoreServicesInstallerEditModeTests.cs
More file actions
47 lines (44 loc) · 1.69 KB
/
CoreServicesInstallerEditModeTests.cs
File metadata and controls
47 lines (44 loc) · 1.69 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
using System;
using CoreAI.Composition;
using CoreAI.Infrastructure.Logging;
using CoreAI.Infrastructure.Messaging;
using CoreAI.Messaging;
using NUnit.Framework;
using VContainer;
namespace CoreAI.Tests.EditMode
{
/// <summary>
/// Ensures <see cref="CoreServicesInstaller.RegisterCore"/> builds on all targets (incl. WebGL/IL2CPP):
/// <see cref="IAiGameCommandSink"/> must resolve without VContainer constructor analysis on
/// <see cref="MessagePipeAiCommandSink"/>.
/// </summary>
/// <remarks>
/// No <c>[TearDown]</c>: <c>GlobalMessagePipe.SetProvider(null)</c> is invalid (MessagePipe always resolves
/// <c>EventFactory</c> from the argument). The next <c>RegisterCore</c> build replaces the static provider;
/// <see cref="CoreAI.Logging.Log.Instance"/> is refreshed in the same callback.
/// </remarks>
public sealed class CoreServicesInstallerEditModeTests
{
[Test]
public void RegisterCore_Builds_AndResolves_IAiGameCommandSink_As_MessagePipeSink()
{
ContainerBuilder builder = new();
builder.Register<DefaultGameLogSettings>(Lifetime.Singleton).As<IGameLogSettings>();
builder.RegisterCore();
IObjectResolver container = builder.Build();
try
{
IAiGameCommandSink sink = container.Resolve<IAiGameCommandSink>();
Assert.That(sink, Is.Not.Null);
Assert.That(sink, Is.InstanceOf<MessagePipeAiCommandSink>());
}
finally
{
if (container is IDisposable disposable)
{
disposable.Dispose();
}
}
}
}
}