IEngineConfigurationTypeMemberBuilder IEngineConfigurationTypeBuilder.SetupProperty(string propertyName) { MemberInfo info = mType.GetProperty(propertyName); if (info == null) { throw new ArgumentException("Property does not exist", propertyName); } var memberBuilder = new EngineConfigurationTypeMemberBuilder(ReflectionHelper.GetMember(info), this); mMembers.Add(memberBuilder); return memberBuilder; }
IEngineConfigurationTypeMemberBuilder IEngineConfigurationTypeBuilder.SetupField(string fieldName) { FieldInfo info = mType.GetField(fieldName); if (info == null) { throw new ArgumentException("Field does not exist", fieldName); } var memberBuilder = new EngineConfigurationTypeMemberBuilder(ReflectionHelper.GetMember(info), this); mMembers.Add(memberBuilder); return memberBuilder; }
public void Generic_Default_ReturnsTypeBuilder() { EngineConfigurationTypeBuilder<SimpleUser> configuration = new EngineConfigurationTypeBuilder<SimpleUser>(); EngineConfigurationTypeMemberBuilder<SimpleUser, string> propertyConfiguration = new EngineConfigurationTypeMemberBuilder<SimpleUser, string>(null, configuration); IEngineConfigurationTypeBuilder<SimpleUser> returnedConfiguration = propertyConfiguration.Default(); Assert.AreEqual(configuration, returnedConfiguration); }
public void Generic_Default_ResetsSource() { EngineConfigurationTypeBuilder<SimpleUser> configuration = new EngineConfigurationTypeBuilder<SimpleUser>(); EngineConfigurationTypeMemberBuilder<SimpleUser, string> propertyConfiguration = new EngineConfigurationTypeMemberBuilder<SimpleUser, string>(null, configuration); propertyConfiguration.Use<SimpleDataSource>(); propertyConfiguration.Default(); Assert.AreEqual(0, propertyConfiguration.GetDatasources().Count()); }
public void Generic_GetConfigurationMember_ReturnsConfigurationMember() { EngineConfigurationTypeBuilder<SimpleUser> configuration = new EngineConfigurationTypeBuilder<SimpleUser>(); EngineTypeMember member = ReflectionHelper.GetMember<SimpleUser>(x => x.EmailAddress); EngineConfigurationTypeMemberBuilder<SimpleUser, string> propertyConfiguration = new EngineConfigurationTypeMemberBuilder<SimpleUser, string>( member, configuration); EngineTypeMember returnMember = propertyConfiguration.GetConfigurationMember(); Assert.AreEqual(member, returnMember); }
public void Generic_GetConfigurationAction_Invalid_ReturnsNULL() { EngineConfigurationTypeBuilder<SimpleUser> configuration = new EngineConfigurationTypeBuilder<SimpleUser>(); EngineTypeMember member = ReflectionHelper.GetMember<SimpleUser>(x => x.EmailAddress); EngineConfigurationTypeMemberBuilder<SimpleUser, string> propertyConfiguration = new EngineConfigurationTypeMemberBuilder<SimpleUser, string>( member, configuration); IEngineConfigurationDatasource returnAction = propertyConfiguration.GetDatasources().FirstOrDefault(); Assert.Null(returnAction); }
IEngineConfigurationTypeMemberBuilder IEngineConfigurationTypeBuilder.SetupField(string fieldName) { FieldInfo info = mType.GetField(fieldName); if (info == null) { throw new ArgumentException("Field does not exist", fieldName); } var memberBuilder = new EngineConfigurationTypeMemberBuilder(ReflectionHelper.GetMember(info), this); mMembers.Add(memberBuilder); return(memberBuilder); }
IEngineConfigurationTypeMemberBuilder IEngineConfigurationTypeBuilder.SetupProperty(string propertyName) { MemberInfo info = mType.GetProperty(propertyName); if (info == null) { throw new ArgumentException("Property does not exist", propertyName); } var memberBuilder = new EngineConfigurationTypeMemberBuilder(ReflectionHelper.GetMember(info), this); mMembers.Add(memberBuilder); return(memberBuilder); }
public IEngineConfigurationTypeMemberBuilder <TPoco, TMember> Setup <TMember>(Expression <Func <TPoco, TMember> > expression) { // Get the member this set up is for EngineTypeMember member = ReflectionHelper.GetMember(expression); // Create the configuration builder var configuration = new EngineConfigurationTypeMemberBuilder <TPoco, TMember>(member, this); // Store it in the local list this.RegisterTypeMemberProvider(configuration); // And return it return((IEngineConfigurationTypeMemberBuilder <TPoco, TMember>)configuration); }
public IEngineConfigurationTypeBuilder SetupMethod(string methodName, MethodInvocationContext context) { DatasourceFactory[] factories = context.GetArguments().ToArray(); MethodInfo info = mType.GetMethods(BindingFlags.Public | BindingFlags.Instance).Where(x => x.Name == methodName && x.GetParameters().Length == factories.Length) .FirstOrDefault(); if (info == null) { throw new ArgumentException("Method does not exist", methodName); } var memberBuilder = new EngineConfigurationTypeMemberBuilder(ReflectionHelper.GetMember(info), this); mMembers.Add(memberBuilder); memberBuilder.SetDatasources(factories); return(this); }
public IEngineConfigurationTypeBuilder SetupMethod(string methodName, MethodInvocationContext context) { DatasourceFactory[] factories = context.GetArguments().ToArray(); MethodInfo info = mType.GetMethods(BindingFlags.Public | BindingFlags.Instance).Where(x => x.Name == methodName && x.GetParameters().Length == factories.Length) .FirstOrDefault(); if (info == null) { throw new ArgumentException("Method does not exist", methodName); } var memberBuilder = new EngineConfigurationTypeMemberBuilder(ReflectionHelper.GetMember(info), this); mMembers.Add(memberBuilder); memberBuilder.SetDatasources(factories); return this; }
public void Generic_UseWithArgs_ReturnsTypeBuilder() { EngineConfigurationTypeBuilder<SimpleUser> configuration = new EngineConfigurationTypeBuilder<SimpleUser>(); EngineConfigurationTypeMemberBuilder<SimpleUser, string> propertyConfiguration = new EngineConfigurationTypeMemberBuilder<SimpleUser, string>(null, configuration); IEngineConfigurationTypeBuilder<SimpleUser> returnedConfiguration = propertyConfiguration.Use<SimpleDataSource>(0,1,10); Assert.AreEqual(configuration, returnedConfiguration); }
public void NotGeneric_Use_ReturnsTypeBuilder() { EngineConfigurationTypeBuilder configuration = new EngineConfigurationTypeBuilder(typeof(SimpleUser)); EngineConfigurationTypeMemberBuilder propertyConfiguration = new EngineConfigurationTypeMemberBuilder(null, configuration); IEngineConfigurationTypeBuilder returnedConfiguration = propertyConfiguration.Use(typeof(SimpleDataSource)); Assert.AreEqual(configuration, returnedConfiguration); }
public void NotGeneric_UseInvalidDataSource_ThrowsArgumentException() { EngineConfigurationTypeBuilder configuration = new EngineConfigurationTypeBuilder(typeof(SimpleUser)); EngineConfigurationTypeMemberBuilder propertyConfiguration = new EngineConfigurationTypeMemberBuilder(null, configuration); Assert.Throws<ArgumentException>(() => { propertyConfiguration.Use(typeof(SimpleUser)); }); }
public void NotGeneric_Default_ResetsSource() { EngineConfigurationTypeBuilder configuration = new EngineConfigurationTypeBuilder(typeof(SimpleUser)); EngineConfigurationTypeMemberBuilder propertyConfiguration = new EngineConfigurationTypeMemberBuilder(null, configuration); propertyConfiguration.Use(typeof(SimpleDataSource)); propertyConfiguration.Default(); Assert.AreEqual(0, propertyConfiguration.GetDatasources().Count()); }