Removed ConcreteType property from IAbstractFactory<> interface (it was a really strange decision to add it in the first place, luckily it hasn't crept anywhere so far); provided a non-generic abstract factory interface; the factories returned by the factory employer now implement the non-generic factory interface
git-svn-id: file:///srv/devel/repo-conversion/nusu@139 d2e56fa2-650e-0410-a79f-9358c0239efd
This commit is contained in:
parent
41dcfa34d0
commit
4e2beb71b8
3 changed files with 46 additions and 17 deletions
|
@ -69,6 +69,23 @@ namespace Nuclex.Support.Plugins {
|
|||
Assert.IsFalse(testEmployer.CanEmploy(typeof(Unrelated)));
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Tests whether the factory employer can use the non-generic IAbstractFactory
|
||||
/// interface instead of its generic variant
|
||||
/// </summary>
|
||||
[Test]
|
||||
public void TestNonGenericCreateInstance() {
|
||||
FactoryEmployer<Base> testEmployer = new FactoryEmployer<Base>();
|
||||
testEmployer.Employ(typeof(Derived));
|
||||
|
||||
Assert.That(testEmployer.Factories.Count, Is.AtLeast(1));
|
||||
|
||||
IAbstractFactory factory = testEmployer.Factories[0] as IAbstractFactory;
|
||||
Assert.IsNotNull(factory);
|
||||
|
||||
Assert.IsInstanceOf<Derived>(factory.CreateInstance());
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Tests whether the factory employer throws an exception when it is asked to
|
||||
/// employ an abstract class
|
||||
|
@ -105,7 +122,6 @@ namespace Nuclex.Support.Plugins {
|
|||
testEmployer.Employ(typeof(Derived));
|
||||
|
||||
Assert.AreEqual(1, testEmployer.Factories.Count);
|
||||
Assert.AreEqual(typeof(Derived), testEmployer.Factories[0].ConcreteType);
|
||||
Assert.IsInstanceOf<Derived>(testEmployer.Factories[0].CreateInstance());
|
||||
}
|
||||
|
||||
|
@ -120,7 +136,6 @@ namespace Nuclex.Support.Plugins {
|
|||
testEmployer.Employ(typeof(Unrelated));
|
||||
|
||||
Assert.AreEqual(1, testEmployer.Factories.Count);
|
||||
Assert.AreEqual(typeof(Unrelated), testEmployer.Factories[0].ConcreteType);
|
||||
Assert.IsInstanceOf<Unrelated>(testEmployer.Factories[0].CreateInstance());
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue