public void GetTypesImplementingType_PassTypeWithExistingImplementationWithFlagIsTrue_ReturnTypes() { var typeLoader = new Kusnadi.Utils.TypeLoader(); typeLoader.LoadFromCurrentAppDomain(); //implementing normal class, return also the type var types = typeLoader.GetTypesImplementingType <ClassA>(true); Assert.AreEqual(3, types.Count()); Assert.IsTrue(types.Any(item => item.Name == "ConcreteConcreteClassA" || item.Name == "ConcreteClassA" || item.Name == "ClassA")); types = typeLoader.GetTypesImplementingType <ConcreteClassA>(true); Assert.AreEqual(2, types.Count()); Assert.IsTrue(types.Any(item => item.Name == "ConcreteConcreteClassA" || item.Name == "ConcreteClassA")); types = typeLoader.GetTypesImplementingType <ConcreteConcreteClassA>(true); Assert.AreEqual(1, types.Count()); Assert.IsTrue(types.First().Name == "ConcreteConcreteClassA"); //implementing abtract, return only implementation type types = typeLoader.GetTypesImplementingType <AbstractA>(true); Assert.AreEqual(1, types.Count()); Assert.IsTrue(types.First().Name == "ConcreteAbstractA"); //implementing interface, return only implemtation type types = typeLoader.GetTypesImplementingType <InterfaceA>(true); Assert.AreEqual(1, types.Count()); Assert.IsTrue(types.First().Name == "ConcreteInterfaceA"); }
public void GetTypesImplementingType_PassTypeWithNoExistingImplementation_ReturnEmpty() { var typeLoader = new Kusnadi.Utils.TypeLoader(); //pass non existing implementation Types, with class var types = typeLoader.GetTypesImplementingType <ClassB>(); Assert.AreEqual(0, types.Count()); //pass non existing implementation Types, interface types = typeLoader.GetTypesImplementingType <InterfaceB>(); Assert.AreEqual(0, types.Count()); //pass non existing implementation Types, with abstract class types = typeLoader.GetTypesImplementingType <AbstractB>(); Assert.AreEqual(0, types.Count()); }