Class PropertySetterCaptureExtensions
Provides first-party helpers for capturing interface property assignments without relying on provider-specific SetupSet(...) behavior.
Inherited Members
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 |
Returns
| Type | Description |
|---|---|
| PropertyValueCapture<TValue> | The supplied |
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 |
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");