public ComposableCustomizationOptions(IFixture fixture, ICustomization customization) { _customizations = new List <ICustomization> { customization }; _fixture = fixture; }
/// <summary> /// Initializes a new instance of the <see cref="WithCustomizationAttribute"/> class. /// </summary> /// <param name="customizationType">Type of the customization.</param> /// <exception cref="ArgumentNullException">customizationType</exception> /// <exception cref="ArgumentException">customizationType or customizationType</exception> public WithCustomizationAttribute(Type customizationType) { if (customizationType == null) { throw new ArgumentNullException("customizationType"); } if (!typeof(ICustomization).IsAssignableFrom(customizationType)) { throw new ArgumentException(string.Format( CultureInfo.CurrentCulture, "{0} is not compatible with ICustomization. Please supply a Type which implements ICustomization.", customizationType), "customizationType"); } var ctor = customizationType.GetConstructor(Type.EmptyTypes); if (ctor == null) { throw new ArgumentException( string.Format( CultureInfo.CurrentCulture, "{0} has no default constructor. Please supply a a Type that implements ICustomization and has a default constructor.", customizationType), "customizationType"); } _customization = (ICustomization)ctor.Invoke(null); }
/// <summary> /// Initializes a new instance of the <see cref="DefaultDataAttribute"/> class with default customization /// and others to apply. /// </summary> /// <param name="defaultCustomization">The default <see cref="ICustomization"/> instance.</param> /// <param name="customizationTypes">Other <see cref="ICustomization"/> types to apply.</param> public DefaultDataAttribute(ICustomization defaultCustomization, params Type[] customizationTypes) : this(defaultCustomization) { this.Fixture.Customize( new CompositeCustomization( customizationTypes.Select(t => (ICustomization)Activator.CreateInstance(t, null)))); }
public void Applies_customization_to_target(ICustomization <TestType> customization, TestType target) { var customizations = new[] { customization }; CustomizationExtensions.ApplyTo(customizations, target); Mock.Get(customization).Verify(p => p.Customize(target), Times.Once()); }
/// <summary> /// Applies a customization. /// </summary> /// <param name="customization">The customization to apply.</param> /// <returns> /// The current instance. /// </returns> public IFixture Customize(ICustomization customization) { if (customization == null) { throw new ArgumentNullException(nameof(customization)); } customization.Customize(this); return(this); }
public AutoDataAttribute(ICustomization customization) : this(() => new Fixture { Behaviors = { new OmitOnRecursionBehavior(), }, }.Customize(customization)) { }
private void CustomizeFixture(ParameterInfo parameter) { foreach (Attribute attribute in parameter.GetCustomAttributes()) { switch (attribute) { case IParameterCustomizationSource source: IFixture fixture = _fixture.Value; ICustomization customization = source.GetCustomization(parameter); fixture.Customize(customization); break; } } }
public void GivenMemberAutoMockData_WhenShareFixtureIsSetToTrue_ThenSameFixturePerDataRowIsUsed(int index, ICustomization customization, IFixture fixture) { // Arrange var expectedCostomizationsCount = 20; // Act var customizations = fixture.Customize(customization); // Assert fixture.Customizations.Should().HaveCount(expectedCostomizationsCount + index); }
/// <summary> /// Initializes a new instance of the <see cref="DefaultDataAttribute"/> class with default customization. /// </summary> /// <param name="defaultCustomization">The default <see cref="ICustomization"/> instance.</param> public DefaultDataAttribute(ICustomization defaultCustomization) : base(new Fixture().Customize(defaultCustomization)) { }
public IFixture BuildWith(ICustomization autoFixtureCustomization) { return(_autoFixtureCache.GetOrAdd(autoFixtureCustomization.GetType(), type => new Fixture().Customize(autoFixtureCustomization))); }
/// <summary> /// Initializes a new instance of the <see cref="DefaultDataAttribute"/> class with default customization /// and others to apply. /// </summary> /// <param name="defaultCustomization">The default <see cref="ICustomization"/> instance.</param> /// <param name="customizationTypes">Other <see cref="ICustomization"/> types to apply.</param> public DefaultDataAttribute(ICustomization defaultCustomization, params Type[] customizationTypes) { _defaultCustomization = defaultCustomization; _customizationTypes = customizationTypes; }
public void ClearCustomization() { _customization = null; }
protected AutoDataAttribute(IEnumerable <ISpecimenBuilderTransformation> transformations, ICustomization customization) : this(new Fixtures(new EngineParts(transformations.Open()), customization)) { }
public IFixture BuildWith(ICustomization autoFixtureCustomization) { return autoFixtureCache.GetOrAdd(autoFixtureCustomization.GetType(), type => new Fixture().Customize(autoFixtureCustomization)); }
protected CustomDataSourceAttribute(ICustomization customization) : base(() => new Fixture().Customize(new CompositeCustomization( new AutoMoqCustomization(), customization))) { }
public Fixtures(DefaultRelays relays, ICustomization customization) { _relays = relays; _customization = customization; }
public PageRendererDataAttribute(ICustomization customization, params object[] values) : base(new AutoDataAttribute(new Fixture().Customize(customization)), values) { }
public TemplateDataAttribute(ICustomization customization, params object[] values) : base(new AutoDataAttribute(new Fixture().Customize(customization)), values) { }
public static IComposableCustomizationOptions Compose(this IFixture fixture, ICustomization customization) { fixture = fixture ?? throw new ArgumentNullException(nameof(fixture)); return(new ComposableCustomizationOptions(fixture, customization)); }
protected void EnableCustomization(ICustomization customization) { customization.Customize(FixtureRepository); }
IFixture IFixture.Customize(ICustomization customization) => throw new NotSupportedException();
public IFixture Customize(ICustomization customization) { throw new NotImplementedException(); }
/// <inheritdoc /> public void AddCustomization(ICustomization customization) { _fixture.Customize(customization); }
public void GivenMemberAutoMockData_WhenShareFixtureIsSetToFalse_ThenUniqueFixturePerDataRowIsCreated(ICustomization customization, IFixture fixture) { // Arrange var expectedCostomizationsCount = 20; // Act var customizations = fixture.Customize(customization); // Assert fixture.Customizations.Should().HaveCount(expectedCostomizationsCount); }
/// <summary> /// Customize Fixture behavior /// </summary> /// <param name="fixture"></param> /// <param name="customization"></param> public static void EnableCustomization(this IFixture fixture, ICustomization customization) { customization.Customize(fixture); }
/// <summary> /// Constructor /// </summary> public OmitAutoPropertiesTrueCompositeCustomization(ICustomization customization) : base(new OmitAutoPropertiesTrueCustomization(), customization) { }
protected ControllerDataSourceAttribute(ICustomization customization) : base(new CompositeCustomization(customization, new ControllerCustomization())) { }
protected AutoDataAttribute(ICustomization customization, params ISpecimenBuilderTransformation[] transformations) : this(transformations, customization) { }
protected AccountDataSourceAttribute(ICustomization customization) : base(new CompositeCustomization(new AccountCustomization(), customization)) { }
public IFixture Customize(ICustomization customization) { return(this.OnCustomize(customization)); }
public void SetCustomization(ICustomization customization) { _customization = customization; }