-
-
Notifications
You must be signed in to change notification settings - Fork 0
Closed
Labels
documentationImprovements or additions to documentationImprovements or additions to documentationstate: releasedThe issue is releasedThe issue is released
Description
Description
While delegates are mentioned in the main example, delegate mocking is not properly documented as a standalone feature.
Missing Documentation
- Mock
Action<T>,Func<T>, and custom delegates SetupMock.Delegate()for setupVerifyMock.Invoked()for delegate verification- Full parameter matching support for delegates
Suggested Documentation
Add a new section titled "Mocking Delegates":
### Mocking Delegates
Mockolate supports mocking delegates including `Action<T>`, `Func<T>`, and custom delegates:
```csharp
// Create a mock delegate
var myDelegate = Mock.Create<Action<string, int>>();
// Setup the delegate
myDelegate.SetupMock.Delegate(It.Is(\"Dark\"), It.IsAny<int>())
.Do((type, amount) => Console.WriteLine($\"Dispensed {amount} {type}\"));
// Invoke the delegate
myDelegate(\"Dark\", 5);
// Verify invocation
myDelegate.VerifyMock.Invoked(It.Is(\"Dark\"), It.Is(5)).Once();Custom delegates are also supported:
var customDelegate = Mock.Create<ChocolateDispensedDelegate>();
customDelegate.SetupMock.Delegate(It.IsAny<string>(), It.IsAny<int>())
.Do((type, amount) => { /* handler */ });Reactions are currently unavailable
Metadata
Metadata
Labels
documentationImprovements or additions to documentationImprovements or additions to documentationstate: releasedThe issue is releasedThe issue is released