#region CPL License
/*
Nuclex Framework
Copyright (C) 2002-2009 Nuclex Development Labs
This library is free software; you can redistribute it and/or
modify it under the terms of the IBM Common Public License as
published by the IBM Corporation; either version 1.0 of the
License, or (at your option) any later version.
This library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
IBM Common Public License for more details.
You should have received a copy of the IBM Common Public
License along with this library
*/
#endregion
#if UNITTEST
using System;
using System.IO;
using NUnit.Framework;
namespace Nuclex.Support.Plugins {
/// Unit Test for the employer class
[TestFixture]
public class EmployerTest {
#region class TestEmployer
/// Dummy implementation for testing the employer class
private class TestEmployer : Employer {
/// Employs the specified plugin type
/// Type to be employed
public override void Employ(Type type) { }
}
#endregion // class TestEmployer
#region class NoDefaultConstructor
/// Test class that doesn't have a default constructor
private class NoDefaultConstructor {
/// Initializes a new instance of the test class
/// Dummy argument so this is no default constructor
public NoDefaultConstructor(int dummy) { }
}
#endregion // class NoDefaultConstructor
#region class NonPublicDefaultConstructor
/// Test class that has a non-public default constructor
private class NonPublicDefaultConstructor {
/// Initializes a new instance of the test class
protected NonPublicDefaultConstructor() { }
}
#endregion // class NonPublicDefaultConstructor
#region class PublicDefaultConstructor
/// Test class that has a public default constructor
private class PublicDefaultConstructor {
/// Initializes a new instance of the test class
public PublicDefaultConstructor() { }
}
#endregion // class PublicDefaultConstructor
/// Tests whether the employer can detect a default constructor
[Test]
public void TestEmployerDefaultConstructorDetection() {
TestEmployer testEmployer = new TestEmployer();
Assert.IsFalse(testEmployer.CanEmploy(typeof(NoDefaultConstructor)));
Assert.IsFalse(testEmployer.CanEmploy(typeof(NonPublicDefaultConstructor)));
Assert.IsTrue(testEmployer.CanEmploy(typeof(PublicDefaultConstructor)));
}
}
} // namespace Nuclex.Support.Plugins
#endif // UNITTEST