sharee.bike-App/TestShareeLib/Services/TestServicesContainerMutable.cs
Anja Müller-Meißner 573fe77e12 Version 3.0.337
2022-08-30 15:42:25 +02:00

69 lines
1.8 KiB
C#

using System;
using System.Collections.Generic;
using NUnit.Framework;
using TINK.Services;
namespace TestShareeLib.Services
{
[TestFixture]
public class TestServicesContainerMutable
{
[Test]
public void TestCtor()
{
var typeA = new MyTypeA();
var typeB = new MyTypeB();
var serviceContainer = new ServicesContainerMutableT<object>(
new List<object> { typeA, typeB, typeB },
typeA.GetType().FullName);
Assert.That(
serviceContainer,
Is.EqualTo(new List<object> { typeA, typeB }).AsCollection);
Assert.That(
serviceContainer.Active,
Is.EqualTo(typeA));
}
[Test]
public void TestSetActive()
{
var typeA = new MyTypeA();
var typeB = new MyTypeB();
var serviceContainer = new ServicesContainerMutableT<object>(
new List<object> { typeA, typeB },
typeA.GetType().FullName);
serviceContainer.SetActive(typeB.GetType().FullName);
Assert.That(
serviceContainer.Active,
Is.EqualTo(typeB));
}
[Test]
public void TestSetActiveNotExists()
{
var typeA = new MyTypeA();
var typeB = new MyTypeB();
var serviceContainer = new ServicesContainerMutableT<object>(
new List<object> { typeA, typeB },
typeA.GetType().FullName);
Assert.That(
() => serviceContainer.SetActive(new MyTypeC().GetType().FullName),
Throws.TypeOf<ArgumentException>());
}
private class MyTypeA { }
private class MyTypeB { }
private class MyTypeC { }
}
}