Files
RobustToolbox/Robust.Shared.Tests/IoC/DependencyCollectionTest.cs
PJB3005 788e9386fd Split up test project
Robust.UnitTesting was both ALL tests for RT, and also API surface for content tests.

Tests are now split into separate projects as appropriate, and the API side has also been split off.
2025-12-16 01:36:53 +01:00

44 lines
865 B
C#

using NUnit.Framework;
using Robust.Shared.IoC;
namespace Robust.Shared.Tests.IoC;
[TestFixture]
[TestOf(typeof(DependencyCollection))]
[Parallelizable]
internal sealed class DependencyCollectionTest
{
/// <summary>
/// Tests that registering two interfaces with the same implementation results in a single instance being shared.
/// </summary>
[Test]
public void TestRegisterSameImplementation()
{
var deps = new DependencyCollection();
deps.Register<IA, C>();
deps.Register<IB, C>();
deps.BuildGraph();
var a = deps.Resolve<IA>();
var b = deps.Resolve<IB>();
Assert.That(a, Is.EqualTo(b), () => "A & B instances must be reference equal");
}
private interface IA
{
}
private interface IB
{
}
private sealed class C : IA, IB
{
}
}