mirror of
https://github.com/space-wizards/RobustToolbox.git
synced 2026-02-14 19:29:36 +01:00
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.
44 lines
865 B
C#
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
|
|
{
|
|
|
|
}
|
|
}
|