'Xunit, MOCK unitest error : Setup on method with 9 parameter(s) cannot invoke callback with different number of parameters (8)
I'm very new to xunit unitest case writing. I changed a function and also, and I made some changes in unit test case. But I got the following error. I tried to fix the issue. But no hope.
System.ArgumentException : Invalid callback. Setup on method with 9 parameter(s) cannot invoke callback with different number of parameters (8).
Stack Trace:
MethodCall.<SetReturnsResponse>g__ValidateCallback|22_1(Delegate callback)
MethodCall.SetReturnsResponse(Delegate valueFactory)
NonVoidSetupPhrase`2.Returns[T1,T2,T3,T4,T5,T6,T7,T8](Func`9 valueExpression)
GeneratedReturnsExtensions.ReturnsAsync[T1,T2,T3,T4,T5,T6,T7,T8,TMock,TResult](IReturns`2 mock, Func`9 valueFunction)
CreateReportTests.ctor() line 39
I got the error from below section
_ReportClientMock
.Setup(m => m.CreateReportAsync(
It.IsAny<string>(), It.IsAny<string>(), It.IsAny<string>(), It.IsAny<string>(),
It.IsAny<Guid>(), It.IsAny<string>(), It.IsAny<IEnumerable<Guid>>(), It.IsAny<TimeSpan>(), It.IsAny<bool>()))
.ReturnsAsync<string, string, string, string, Guid, string, IEnumerable<Guid>, TimeSpan, IReportClient, Report>
((entityType, entityId, appId, appContext, creatorId, report, UserIds, _) =>
new Report(Guid.NewGuid(), entityType, entityId, appId, appContext, creatorId, DateTimeOffset.UtcNow, null, report, false, UserIds));
Actual function is *
Task<Comment> CreateReportAsync(string entityType, string entityId, string appId, string? appContext, Guid creatorId, string report, IEnumerable<Guid>? UserIds, TimeSpan expirationTime, bool allow);
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|
