public void SetupFixture() { ClassDef.ClassDefs.Clear(); var typeSource = new AssemblyTypeSource(typeof(Person)); ClassDef.ClassDefs.Add(new AllClassesAutoMapper(typeSource).Map()); }
/// <summary> /// Clears the loaded class definitions and reloads them. Usually this only needs /// to be done once per test fixture, except if there are individual tests that /// modify the class definitions. /// </summary> public static void RefreshClassDefs() { ClassDef.ClassDefs.Clear(); // ClassDefCol classDefs = new XmlClassDefsLoader(BOBroker.GetClassDefsXml(), new DtdLoader()).LoadClassDefs(); var assemblyTypeSource = new AssemblyTypeSource(typeof(Car)); var loader = new ReflectionClassDefLoader(assemblyTypeSource); ClassDef.ClassDefs.Add(loader.LoadClassDefs()); }
public void Test_GetTypes_ShouldReturnObjectThatOnlyImplementsIBo() { //---------------Set up test pack------------------- Assembly thisAssembly = Assembly.GetExecutingAssembly(); AssemblyTypeSource typeSource = new AssemblyTypeSource(thisAssembly); //---------------Assert Precondition---------------- //---------------Execute Test ---------------------- var bos = typeSource.GetTypes(); //---------------Test Result ----------------------- bos.ShouldContain(typeof(FakeBoShouldBeLoadedOnlyImplementingInterfaceShouldBeLoaded).ToTypeWrapper(), "Object Implementing IBO should be loaded"); }
public void Test_GetTypes_WhenExtDll_ShouldNotReturnInterface() { //---------------Set up test pack------------------- Assembly thisAssembly = typeof(FakeExtBoShouldBeLoaded).Assembly; AssemblyTypeSource typeSource = new AssemblyTypeSource(thisAssembly); //---------------Assert Precondition---------------- //---------------Execute Test ---------------------- var bos = typeSource.GetTypes(); //---------------Test Result ----------------------- bos.ShouldNotContain(typeof(IFakeExtBoInterfaceShouldNotBeLoaded).ToTypeWrapper(), "Interface should not be loaded"); }
public void Test_GetTypes_WhenExtDll_ShouldReturnNormalBo() { //---------------Set up test pack------------------- Assembly thisAssembly = typeof(FakeExtBoShouldBeLoaded).Assembly; AssemblyTypeSource typeSource = new AssemblyTypeSource(thisAssembly); //---------------Assert Precondition---------------- //---------------Execute Test ---------------------- var bos = typeSource.GetTypes(); //---------------Test Result ----------------------- bos.ShouldContain(typeof(FakeExtBoShouldBeLoaded).ToTypeWrapper(), "Object Implementing IBO should be loaded"); }
public void Test_GetTypes_WhenExtDll_ShouldNotReturnGenericClasses() { //---------------Set up test pack------------------- AssemblyTypeSource typeSource = new AssemblyTypeSource(typeof(FakeExtBoShouldBeLoaded)); //---------------Assert Precondition---------------- //---------------Execute Test ---------------------- var bos = typeSource.GetTypes(); //---------------Test Result ----------------------- Assert.IsNotNull(bos); Assert.GreaterOrEqual(bos.Count(), 2); bos.ShouldNotContain(typeof(FakeExtGenericBOShouldNotBeLoaded <string>).ToTypeWrapper(), "Generic classes should not be loaded"); }
public void Test_GetTypes_WhenExtDll_WhenConstructWithType_ShouldReturnNormalBo() { //---------------Set up test pack------------------- Assembly thisAssembly = typeof(FakeExtBoShouldBeLoaded).Assembly; AssemblyTypeSource typeSource = new AssemblyTypeSource(typeof(FakeExtBoShouldBeLoaded)); var expectedBos = TypesImplementing <IBusinessObject>(thisAssembly); //---------------Assert Precondition---------------- //---------------Execute Test ---------------------- var bos = typeSource.GetTypes(); //---------------Test Result ----------------------- Assert.AreEqual(2, bos.Count()); bos.ShouldContain(typeof(FakeExtBoShouldBeLoaded).ToTypeWrapper(), "Object Implementing IBO should be loaded"); bos.ItemsShouldBeEqual(expectedBos); }
public void Test_GetTypes_WhenExtDll_ShouldNotReturnAbstractClasses() { //---------------Set up test pack------------------- Assembly thisAssembly = typeof(FakeExtBoShouldBeLoaded).Assembly; AssemblyTypeSource typeSource = new AssemblyTypeSource(thisAssembly); //---------------Assert Precondition---------------- //---------------Execute Test ---------------------- var bos = typeSource.GetTypes(); //---------------Test Result ----------------------- Assert.IsNotNull(bos); Assert.GreaterOrEqual(bos.Count(), 2); bos.ShouldNotContain(typeof(FakeExtAbstractBoInterfaceShouldNotBeLoaded).ToTypeWrapper(), "Abstract classes should not be loaded"); }
public void Test_GetAllTypesImplementingIBo_ShouldNotReturnGenericClasses() { //---------------Set up test pack------------------- Assembly thisAssembly = Assembly.GetExecutingAssembly(); AssemblyTypeSource typeSource = new AssemblyTypeSource(thisAssembly); //---------------Assert Precondition---------------- //---------------Execute Test ---------------------- var bos = typeSource.GetTypes(); //---------------Test Result ----------------------- Assert.IsNotNull(bos); Assert.GreaterOrEqual(bos.Count(), 5); bos.ShouldContain(typeof(FakeBoShouldBeLoaded).ToTypeWrapper()); bos.ShouldNotContain(typeof(FakeGenericBOShouldNotBeLoaded <string>).ToTypeWrapper(), "Generic classes should not be loaded"); }
public void Test_GetTypes_ShouldReturnAllTypesImplementingIBoInterface() { //---------------Set up test pack------------------- Assembly thisAssembly = Assembly.GetExecutingAssembly(); AssemblyTypeSource typeSource = new AssemblyTypeSource(thisAssembly); var expectedBos = TypesImplementing <IBusinessObject>(); //---------------Assert Precondition---------------- Assert.GreaterOrEqual(expectedBos.Count(), 2); //---------------Execute Test ---------------------- var bos = typeSource.GetTypes(); //---------------Test Result ----------------------- Assert.IsNotNull(bos); bos.ItemsShouldBeEqual(expectedBos); }
public void Test_GetTypes_WhenExtDll_WithNullWhereClause_ShouldRetAllClasses() { //---------------Set up test pack------------------- Assembly thisAssembly = typeof(FakeExtBoShouldBeLoaded).Assembly; AssemblyTypeSource typeSource = new AssemblyTypeSource(thisAssembly, null); //---------------Assert Precondition---------------- //---------------Execute Test ---------------------- var bos = typeSource.GetTypes(); //---------------Test Result ----------------------- Assert.IsNotNull(bos); Assert.AreEqual(2, bos.Count()); bos.ShouldContain(typeof(FakeExtBoShouldBeLoaded).ToTypeWrapper()); bos.ShouldContain(typeof(FakeExtBoOnlyImplementingInterfaceShouldBeLoaded).ToTypeWrapper(), "Abstract classes should be loaded"); }
public void TestAccept_LoadClassDefs_ShouldLoadAllClassDefs() { //---------------Set up test pack------------------- ITypeSource source = new AssemblyTypeSource(typeof(FakeExtBoShouldBeLoaded)); IClassDefsLoader loader = new ReflectionClassDefLoader(source); //---------------Assert Precondition---------------- //---------------Execute Test ---------------------- var defs = loader.LoadClassDefs(); //---------------Test Result ----------------------- AllClassesAutoMapper allClassesAutoMapper = new AllClassesAutoMapper(source); var expectedDefs = allClassesAutoMapper.Map(); Assert.IsNotNull(defs); defs.ShouldHaveCount(expectedDefs.Count); defs.ShouldContain(expectedDefs, "Should contain all elements loaded via the mapper"); }
public void Test_GetTypes_WhenExtDll_ShouldReturnObjectThatOnlyImplementsIBo() { //---------------Set up test pack------------------- Assembly thisAssembly = typeof(FakeExtBoShouldBeLoaded).Assembly; AssemblyTypeSource typeSource = new AssemblyTypeSource(thisAssembly); //---------------Assert Precondition---------------- //---------------Execute Test ---------------------- var bos = typeSource.GetTypes(); //---------------Test Result ----------------------- bos.ShouldContain(typeof(FakeExtBoOnlyImplementingInterfaceShouldBeLoaded).ToTypeWrapper(), "Object Implementing IBO should be loaded"); }