private IPostprocessComposer <Ticket> ApplyAllCustomisations( IFixture fixture, ICustomizationComposer <Ticket> composer) => customisations.Aggregate( (IPostprocessComposer <Ticket>)composer, (c, f) => f(fixture, c));
public static IPostprocessComposer <T> FromFactory <T>( this ICustomizationComposer <T> composer, object methodParameters) { return(composer.FromFactory( new MethodInvoker(new PartiallySpecifiedMethodQuery(new ModestConstructorQuery(), new Parameters(methodParameters))))); }
/// <summary> /// Returns a new <see cref="BehaviorComposer{T}"/> that decorates the new composer, but /// otherwise preserves other state information of the instance (such as the /// <see cref="Behaviors"/>. /// </summary> /// <param name="newComposer">The new composer to decorate.</param> /// <returns> /// A new <see cref="BehaviorComposer{T}"/> that decorates <paramref name="newComposer"/>. /// </returns> public BehaviorComposer <T> With(ICustomizationComposer <T> newComposer) { if (newComposer == null) { throw new ArgumentNullException("newComposer"); } return(new BehaviorComposer <T>(newComposer, this.Behaviors)); }
public void InitializedWithArrayConstructorHasCorrectComposer() { // Fixture setup var expectedComposer = new DelegatingComposer <object>(); var sut = new BehaviorComposer <object>(expectedComposer); // Exercise system ICustomizationComposer <object> result = sut.Composer; // Verify outcome Assert.Equal(expectedComposer, result); // Teardown }
/// <summary> /// Initializes a new instance of the <see cref="BehaviorComposer<T>"/> class. /// </summary> /// <param name="composer">The composer to decorate.</param> /// <param name="behaviors"> /// The behaviors which will be applied when <see cref="Compose"/> is invoked. /// </param> public BehaviorComposer(ICustomizationComposer <T> composer, params ISpecimenBuilderTransformation[] behaviors) { if (composer == null) { throw new ArgumentNullException("composer"); } if (behaviors == null) { throw new ArgumentNullException("behaviors"); } this.composer = composer; this.behaviors = behaviors; }
public static IPostprocessComposer <T> With <T>( this ICustomizationComposer <T> ob, Expression <Func <T, string> > propertyPicker, int minimumLength, int maximumLength) { var me = (MemberExpression)propertyPicker.Body; var name = me.Member.Name; var generator = new ConstrainedStringGenerator( minimumLength, maximumLength); var value = generator.CreateaAnonymous(name); return(ob.With(propertyPicker, value)); }
protected virtual IPostprocessComposer <CipherAttachment.MetaData> ComposerAction(IFixture fixture, ICustomizationComposer <CipherAttachment.MetaData> composer) { return(composer.With(d => d.Size, fixture.Create <long>()).Without(d => d.SizeString)); }
protected override IPostprocessComposer <CipherAttachment.MetaData> ComposerAction(IFixture fixture, ICustomizationComposer <CipherAttachment.MetaData> composer) => base.ComposerAction(fixture, composer).Without(d => d.Key);
protected override IPostprocessComposer <CipherAttachment.MetaData> ComposerAction(IFixture fixture, ICustomizationComposer <CipherAttachment.MetaData> composer) => base.ComposerAction(fixture, composer).With(d => d.ContainerName, (string)null);
/// <summary> /// Initializes a new instance of the <see cref="BehaviorComposer<T>"/> class. /// </summary> /// <param name="composer">The composer to decorate.</param> /// <param name="behaviors"> /// The behaviors which will be applied when <see cref="Compose"/> is invoked. /// </param> public BehaviorComposer(ICustomizationComposer <T> composer, IEnumerable <ISpecimenBuilderTransformation> behaviors) : this(composer, behaviors.ToArray()) { }
public static IPostprocessComposer <T> With <T, TProperty>( this ICustomizationComposer <T> @this, Expression <Func <T, TProperty> > propertyPicker, Func <Faker, TProperty> valueFactory) => @this.With(propertyPicker, () => valueFactory(faker));
private IPostprocessComposer <Size> ConfigureDefaults(ICustomizationComposer <Size> composer) => composer .With(size => size.Width, NumberValueFactories.NonNegative) .With(size => size.Height, NumberValueFactories.NonNegative);