public void Test_MapClassesForType_ShouldMapAllClassesForTheTypesAssembly() { //---------------Set up test pack------------------- Type type = typeof(FakeExtBoShouldBeLoaded); //---------------Assert Precondition---------------- //---------------Execute Test ---------------------- ClassDefCol classDefCol = type.MapClasses(); //---------------Test Result ----------------------- Assert.AreEqual(2, classDefCol.Count); classDefCol.ShouldContain(def => def.ClassName == "FakeExtBoShouldBeLoaded"); classDefCol.ShouldContain(def => def.ClassName == "FakeExtBoOnlyImplementingInterfaceShouldBeLoaded"); }
public void Test_Map_WhenHaveTwoClassesShouldMapBoth() { //---------------Set up test pack------------------- Type type1 = typeof(FakeBOWithNoRelationship); Type type2 = typeof(FakeBoNoProps); FakeTypeSource source = new FakeTypeSource( new[] { type1, type2 }); AllClassesAutoMapper allClassesAutoMapper = new AllClassesAutoMapper(source); //---------------Assert Precondition---------------- Assert.AreEqual(2, source.GetTypes().Count()); //---------------Execute Test ---------------------- ClassDefCol classDefCol = allClassesAutoMapper.Map(); //---------------Test Result ----------------------- Assert.IsNotNull(classDefCol); Assert.AreEqual(2, classDefCol.Count); classDefCol.ShouldContain(def => def.ClassName == type1.Name); classDefCol.ShouldContain(def => def.ClassName == type2.Name); }
public void Test_MapClassesForTypeWithWhereClause_ShouldMapAllClassesForTheTypesAssemblyMatchingClause() { //---------------Set up test pack------------------- Type type = typeof(FakeExtBoShouldBeLoaded); //---------------Assert Precondition---------------- //---------------Execute Test ---------------------- ClassDefCol classDefCol = type.MapClasses(type1 => !type1.Name.Contains("OnlyImplementing")); //---------------Test Result ----------------------- classDefCol.ShouldContain(def => def.ClassName == "FakeExtBoShouldBeLoaded"); classDefCol.ShouldNotContain(def => def.ClassName == "FakeExtBoOnlyImplementingInterfaceShouldBeLoaded"); Assert.AreEqual(1, classDefCol.Count); }