FastMoq
Search Results for

    Show / Hide Table of Contents

    Class PropertySetterCaptureExtensions

    Provides first-party helpers for capturing interface property assignments without relying on provider-specific SetupSet(...) behavior.

    Inheritance
    object
    PropertySetterCaptureExtensions
    Inherited Members
    object.Equals(object)
    object.Equals(object, object)
    object.GetHashCode()
    object.GetType()
    object.MemberwiseClone()
    object.ReferenceEquals(object, object)
    object.ToString()
    Namespace: FastMoq.Extensions
    Assembly: FastMoq.Core.dll
    Syntax
    public static class PropertySetterCaptureExtensions

    Methods

    AddPropertySetterCapture<TService, TValue>(Mocker, Expression<Func<TService, TValue>>, PropertyValueCapture<TValue>, bool)

    Replaces the current interface registration with a proxy that records assignments to the selected property into the supplied capture instance while forwarding unrelated members to the previously resolved instance.

    Declaration
    public static PropertyValueCapture<TValue> AddPropertySetterCapture<TService, TValue>(this Mocker mocker, Expression<Func<TService, TValue>> propertyExpression, PropertyValueCapture<TValue> capture, bool replace = true) where TService : class
    Parameters
    Type Name Description
    Mocker mocker

    The current Mocker instance.

    Expression<Func<TService, TValue>> propertyExpression

    The interface property whose setter should be captured.

    PropertyValueCapture<TValue> capture

    The capture that should record assigned values.

    bool replace

    True to replace an existing registration for TService. Defaults to true because the helper intentionally swaps in a capture proxy.

    Returns
    Type Description
    PropertyValueCapture<TValue>

    The supplied capture.

    Type Parameters
    Name Description
    TService

    The interface type to wrap.

    TValue

    The property value type.

    Remarks

    When you use this helper from a MockerTestBase<TComponent>-based test, add the capture during the setup phase or call CreateComponent() after the registration change so the component is rebuilt against the proxy-wrapped dependency.

    AddPropertySetterCapture<TService, TValue>(Mocker, Expression<Func<TService, TValue>>, bool)

    Replaces the current interface registration with a proxy that captures assignments to the selected property while forwarding unrelated members to the previously resolved instance.

    Declaration
    public static PropertyValueCapture<TValue> AddPropertySetterCapture<TService, TValue>(this Mocker mocker, Expression<Func<TService, TValue>> propertyExpression, bool replace = true) where TService : class
    Parameters
    Type Name Description
    Mocker mocker

    The current Mocker instance.

    Expression<Func<TService, TValue>> propertyExpression

    The interface property whose setter should be captured.

    bool replace

    True to replace an existing registration for TService. Defaults to true because the helper intentionally swaps in a capture proxy.

    Returns
    Type Description
    PropertyValueCapture<TValue>

    A PropertyValueCapture<TValue> that records the assigned values.

    Type Parameters
    Name Description
    TService

    The interface type to wrap.

    TValue

    The property value type.

    Remarks

    When you use this helper from a MockerTestBase<TComponent>-based test, add the capture during the setup phase or call CreateComponent() after the registration change so the component is rebuilt against the proxy-wrapped dependency.

    Examples
    var modeCapture = Mocks.AddPropertySetterCapture<IOrderGateway, string?>(x => x.Mode);
    CreateComponent();
    
    await Component.RunAsync();
    
    modeCapture.Value.Should().Be("fast");
    In this article
    Back to top
    Generated 2026-04-29 03:53 UTC