public void TypeChecker(bool derivedTypes) { // Arrange var matchObject = new ChildClass1(); var noMatch = new ChildClass2(); var sameTypeCheck = ReflectionTool.TypePredicate(typeof(ChildClass1), derivedTypes); var derivedTypeCheck = ReflectionTool.TypePredicate(typeof(BaseClass), derivedTypes); // Act var isSame = sameTypeCheck(matchObject); var different = sameTypeCheck(noMatch); var isDerived = derivedTypeCheck(matchObject); // Assert Assert.IsTrue(isSame, "Comparison for the same type must always return true"); Assert.IsFalse(different, "Comparison for incompatible types must return false"); Assert.AreEqual(derivedTypes, isDerived, "Comparison for derived types should only work if configured that way"); }