sharee.bike-App/TestTINKLib/Fixtures/ObjectTests/Services/TestServicesContainerMutable.cs
Anja Müller-Meißner 0468955d49 Version 3.0.338
2022-09-08 09:55:14 +02:00

45 lines
1.3 KiB
C#

using System;
using System.Collections.Generic;
using NUnit.Framework;
using TINK.Services;
namespace TestTINKLib.Fixtures.ObjectTests.Services
{
[TestFixture]
public class TestServicesContainerMutable
{
[Test]
public void TestCtor()
{
var container = new ServicesContainerMutableT<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 ServicesContainerMutableT<object>(new List<object> { new A(), new B(), new A() }, typeof(B).FullName), Throws.InstanceOf<Exception>());
}
[Test]
public void TestCtorExceptionActiveNotFound()
{
Assert.That(() => new ServicesContainerMutableT<object>(new List<object> { new A(), new B() }, "C"), Throws.InstanceOf<ArgumentException>());
}
[Test]
public void TestSetActive()
{
var container = new ServicesContainerMutableT<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
{ }
}
}