sharee.bike-App/TestTINKLib/Fixtures/ObjectTests/Services/TestServicesContainerMutable.cs
2021-07-12 21:31:46 +02:00

46 lines
1.5 KiB
C#

using NUnit.Framework;
using System;
using System.Collections.Generic;
using TINK.Services;
namespace TestTINKLib.Fixtures.ObjectTests.Services
{
[TestFixture]
public class TestServicesContainerMutable
{
[Test]
public void TestCtor()
{
var container = new ServicesContainerMutable<object>(new List<object> { new A(), new B() }, typeof(B).FullName);
Assert.That(container.Active.GetType().FullName, Is.EqualTo("TestTINKLib.Fixtures.ObjectTests.Services.TestServicesContainerMutable+B"));
}
[Test]
public void TestCtorExceptionDupes()
{
Assert.That(() => new ServicesContainerMutable<object>(new List<object> { new A(), new B(), new A() }, typeof(B).FullName), Throws.InstanceOf<Exception>());
}
[Test]
public void TestCtorExceptionActiveNotFound()
{
Assert.That(() => new ServicesContainerMutable<object>(new List<object> { new A(), new B() }, "C"), Throws.InstanceOf<ArgumentException>());
}
[Test]
public void TestSetActive()
{
var container = new ServicesContainerMutable<object>(new List<object> { new A(), new B() }, typeof(B).FullName);
container.SetActive(typeof(A).FullName);
Assert.That(container.Active.GetType().FullName, Is.EqualTo("TestTINKLib.Fixtures.ObjectTests.Services.TestServicesContainerMutable+A"));
}
private class A
{ }
private class B
{ }
}
}