sharee.bike-App/TestTINKLib/Fixtures/ObjectTests/Services/TestServicesContainerMutable.cs

46 lines
1.3 KiB
C#
Raw Normal View History

2022-08-30 15:42:25 +02:00
using System;
2021-07-12 21:31:46 +02:00
using System.Collections.Generic;
2022-08-30 15:42:25 +02:00
using NUnit.Framework;
2021-07-12 21:31:46 +02:00
using TINK.Services;
namespace TestTINKLib.Fixtures.ObjectTests.Services
{
2022-09-06 16:08:19 +02:00
[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"));
}
2021-07-12 21:31:46 +02:00
2022-09-06 16:08:19 +02:00
[Test]
public void TestCtorExceptionDupes()
{
Assert.That(() => new ServicesContainerMutableT<object>(new List<object> { new A(), new B(), new A() }, typeof(B).FullName), Throws.InstanceOf<Exception>());
}
2021-07-12 21:31:46 +02:00
2022-09-06 16:08:19 +02:00
[Test]
public void TestCtorExceptionActiveNotFound()
{
Assert.That(() => new ServicesContainerMutableT<object>(new List<object> { new A(), new B() }, "C"), Throws.InstanceOf<ArgumentException>());
}
2021-07-12 21:31:46 +02:00
2022-09-06 16:08:19 +02:00
[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"));
}
2021-07-12 21:31:46 +02:00
2022-09-06 16:08:19 +02:00
private class A
{ }
2021-07-12 21:31:46 +02:00
2022-09-06 16:08:19 +02:00
private class B
{ }
}
2021-07-12 21:31:46 +02:00
}