Fixed a typo; fixed a bug in the plug-in library that would see generic types deriving from a required base class as suitable whereas they cannot be instantiated without a generic argument; added unit tests that reproduce the errors

git-svn-id: file:///srv/devel/repo-conversion/nusu@171 d2e56fa2-650e-0410-a79f-9358c0239efd
This commit is contained in:
Markus Ewald 2009-09-01 19:11:19 +00:00
parent 35b1ca742d
commit 6ef2fdb789
5 changed files with 56 additions and 3 deletions

View file

@ -50,6 +50,16 @@ namespace Nuclex.Support.Plugins {
#endregion // class Derived
#region class GenericDerived
/// <summary>
/// Generic class derived from the abstract base to serve as concrete product
/// for testing the factory employer
/// </summary>
private class GenericDerived<SomeType> : Base { }
#endregion // class GenericDerived
#region class Unrelated
/// <summary>Unrelated class used to test the factory employer</summary>
@ -112,6 +122,19 @@ namespace Nuclex.Support.Plugins {
);
}
/// <summary>
/// Tests whether the factory employer throws an exception when it is asked to
/// employ a class that requires generic parameters for instantiation
/// </summary>
[Test]
public void TestThrowOnEmployGenericClass() {
FactoryEmployer<Base> testEmployer = new FactoryEmployer<Base>();
Assert.Throws<ArgumentException>(
delegate() { testEmployer.Employ(typeof(GenericDerived<>)); }
);
}
/// <summary>
/// Tests whether the factory employer can employ a class derived from the product
/// </summary>