public void Specified_Interface_Must_Be_Evaluated_With_Proper_Service_Pack(Type type) { const string NamePostfix = "_Connect"; var matcher = new ServiceMatcher(type, TypeCategories.Class, NamePostfix); var servicePack = matcher.Pack(); AssertMatchTypeMappedCorrectly(type, servicePack, NamePostfix); }
public void Specified_Test_Dto_Type_Must_Be_Evaluated_With_Correct_Service_Pack(Type type) { var dtoType = type; var matcher = new ServiceMatcher(dtoType, TypeCategories.Dto); var complexDtoServicePack = matcher.Pack(); AssertMatchedPropertyHasProperProperties(type, complexDtoServicePack.MatchType); AssertOnHavingAllRelatedTypes(complexDtoServicePack, dtoType); }
public void All_Types_Member_Involved_In_Specified_Interface_Must_Be_Attributed_With_Specified_Attribute() { var interfaceType = typeof(IComplexInterface); var attributeType = typeof(SomeAttribute); var ctorParams = new Dictionary <Type, object> { { typeof(string), "attributeName" } }; var props = new Dictionary <string, object> { { "Index", 879 } }; var matcher = new ServiceMatcher(interfaceType, TypeCategories.Interface); matcher.SetAttributeForAllInvolvedTypeMembers(attributeType, ctorParams, props); var servicePack = matcher.Pack(); AssertOnAllInvolvedTypeMembersHasAttribute(servicePack, attributeType, props); }
public void Specified_Interface_Must_Be_Attributed_Correctly_For_All_Methods() { var interfaceType = typeof(ISimpleInterface); var attributeType = typeof(SomeAttribute); var ctorParams = new Dictionary <Type, object> { { typeof(string), "attributeName" } }; var props = new Dictionary <string, object> { { "Index", 879 } }; var matcher = new ServiceMatcher(interfaceType, TypeCategories.Class); matcher.SetAttributeForAllMembers(attributeType, ctorParams, props); var servicePack = matcher.Pack(); AssertOnHavingAttributeOnAllMethods(servicePack.MatchType, attributeType, props); }
public void Generated_Type_Must_Have_The_Specified_Generic_Return_Type() { var targetType = typeof(IGenericReturn); var methodName1 = nameof(IGenericReturn.SimpleDtoGenericReturnType); var methodName2 = nameof(IGenericReturn.StringGenericReturnType); var matcher = new ServiceMatcher(targetType, TypeCategories.Interface); var servicePack = matcher.Pack(); AssertOnMethodHasTheSpecifiedReturnType( type: targetType, methodName: methodName1, servicePack: servicePack); AssertOnMethodHasTheSpecifiedReturnType( type: targetType, methodName: methodName2, servicePack: servicePack); }
private static ServicePack CreateServicePack( Type type, TypeCategories typeCategory, string typePostfix, IList <AttributePack> onType, IList <AttributePack> forAllmembers, IList <AttributePack> forAllInvolvedTypes, IList <AttributePack> forAllInvolvedTypeMembers, IDictionary <string, Type> extraCtorParams = null, IOptimizationPackage optimizationPackage = null, bool allMethodsVoid = false, params Type[] interfaces) { var matcher = new ServiceMatcher(type, typeCategory, typePostfix, extraCtorParams, interfaces: interfaces, allMethodsVoid: allMethodsVoid, optimizationPackage: optimizationPackage); SetOnTypeAttributes(matcher, onType); SetForAllmembersAttributes(matcher, forAllmembers); SetForAllInvolvedTypesAttributes(matcher, forAllInvolvedTypes); SetForAllInvolvedTypeMembersAttributes(matcher, forAllInvolvedTypeMembers); return(matcher.Pack()); }
public void Specified_Simple_Dto_Must_Be_Evaluated_With_Correct_Service_Pack() { var simpleDtoType = typeof(SimpleDto); var attributeType = typeof(SomeAttribute); var ctorParamsValuesMapping = new Dictionary <Type, object> { { typeof(string), "Hello" }, }; var propertiesValuesMapping = new Dictionary <string, object> { { nameof(SomeAttribute.Index), 5 }, }; var matcher = new ServiceMatcher(simpleDtoType, TypeCategories.Dto); matcher.SetAttributeOnType( attributeType, ctorParamsValuesMapping, propertiesValuesMapping); matcher.SetAttributeForAllMembers( attributeType, ctorParamsValuesMapping, propertiesValuesMapping); var simpleDtoServicePack = matcher.Pack(); AssertMatchedPropertyHasProperProperties(simpleDtoType, simpleDtoServicePack.MatchType); AssertOnHavingAllRelatedTypes(simpleDtoServicePack, simpleDtoType); AssertOnHavingAttributeOnType(simpleDtoServicePack.MatchType, attributeType, propertiesValuesMapping); AssertOnHavingAttributeOnAllProperties(simpleDtoServicePack.MatchType, attributeType, propertiesValuesMapping); }
public void All_Types_Must_Be_Packed_Within_A_Module_Builder() { var asmName = new AssemblyName("SomeName"); var asmBuilder = AppDomain.CurrentDomain.DefineDynamicAssembly(asmName, AssemblyBuilderAccess.Run); var moduleBuilder = asmBuilder.DefineDynamicModule("DynamicModule"); var testType1 = typeof(IComplexInterface); var testType2 = typeof(IComplexInterface); IGlobalTypeContainer typeContainer = new TestGlobalTypeContainer(); var optPack = new TestOptimizationPackage() { moduleBuilder = moduleBuilder, typeContainer = typeContainer }; var matcher1 = new ServiceMatcher(testType1, TypeCategories.Interface, optimizationPackage: optPack); var matcher2 = new ServiceMatcher(testType2, TypeCategories.Dto, optimizationPackage: optPack); var packed1 = matcher1.Pack(); var packed2 = matcher2.Pack(); }