public void NonGeneric_Setup_WithField_ReturnsMemberConfiguration() { IEngineConfigurationTypeBuilder configuration = new EngineConfigurationTypeBuilder(typeof(SimpleFieldClass)); IEngineConfigurationTypeMemberBuilder memberConfiguration = configuration.SetupField("SomeField"); Assert.NotNull(memberConfiguration); }
public static IEngineConfigurationTypeBuilder <TPoco> Collection <TPoco, TCollection>( this IEngineConfigurationTypeMemberBuilder <TPoco, TCollection> memberConfig, int min, int max) where TCollection : IEnumerable { var collectionType = typeof(TCollection); Type collectionContentType = null; // We need to find the base collection type (we only support generic collections of X for the moment) collectionContentType = GetCollectionContentType(collectionType); if (collectionContentType == null) { throw new ArgumentException("Unable to find collection type, only collections of type IEnumerable<T> are supported", "TCollection"); } // So this will give us AutoSource<Y> var autoSourceType = typeof(AutoSource <>).MakeGenericType(collectionContentType); //// And this will give us FlexibleEnumerableSource<AutoSource<Y>, X<Y>, Y> var enumerableSourceType = typeof(FlexibleEnumerableSource <, ,>).MakeGenericType( autoSourceType, collectionType, collectionContentType ); // I can't believe I'm doing this, if anybody can give us a good method definition that just_works and // negates the need for this tomfoolery I'm all ears var method = memberConfig.GetType().GetMethod("Use", System.Reflection.BindingFlags.Public | System.Reflection.BindingFlags.Instance, null, new[] { typeof(Object[]) }, null); var genericMethod = method.MakeGenericMethod(new[] { enumerableSourceType }); return((IEngineConfigurationTypeBuilder <TPoco>)genericMethod.Invoke(memberConfig, new object[] { new object[] { min, max } })); }
public void NonGeneric_Setup_WithProperty_ReturnsMemberConfiguration() { IEngineConfigurationTypeBuilder configuration = new EngineConfigurationTypeBuilder(typeof(SimplePropertyClass)); IEngineConfigurationTypeMemberBuilder memberConfiguration = configuration.SetupProperty("SomeProperty"); Assert.NotNull(memberConfiguration); }
public void Generic_Setup_WithField_ReturnsMemberConfiguration() { EngineConfigurationTypeBuilder <SimpleFieldClass> configuration = new EngineConfigurationTypeBuilder <SimpleFieldClass>(); IEngineConfigurationTypeMemberBuilder <SimpleFieldClass, String> memberConfiguration = configuration.Setup(x => x.SomeField); Assert.NotNull(memberConfiguration); }
public static IEngineConfigurationTypeBuilder <TPoco> FromParent <TPoco, TMember>(this IEngineConfigurationTypeMemberBuilder <TPoco, TMember> memberConfig) { return(memberConfig.Use <ParentSource <TMember> >()); }
/// <summary> /// Sets the value of a member directly /// </summary> public static IEngineConfigurationTypeBuilder <TPoco> Value <TPoco, TMember>(this IEngineConfigurationTypeMemberBuilder <TPoco, TMember> memberConfig, TMember value) { return(memberConfig.Use <ValueSource <TMember> >(value)); }
/// <summary> /// Declares that this string member should have a random length between min and max /// </summary> public static IEngineConfigurationTypeBuilder <TPoco> Random <TPoco>(this IEngineConfigurationTypeMemberBuilder <TPoco, string> memberConfig, int minLength, int maxLength) { return(memberConfig.Use <RandomStringSource>(minLength, maxLength)); }