You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
So a string-returning method and a void-returning method; and async versions of both.
Then suppose I want to make setups on a strict mock like this:
// strict mock, I only want to setup for one magical value of arg 'input'varmock=newMock<I>(MockBehavior.Strict);
mock.Setup(x => x.GetStuff(42)).Returns("stuff");// works
mock.Setup(x => x.DoStuff(42));// works
mock.Setup(x => x.GetStuffAsync(42)).ReturnsAsync("stuff");// works// what about '.DoStuffAsync' then:/* 1 */ mock.Setup(x => x.DoStuffAsync(42));// run-time error when 'mock.Object' is used: I.DoStuffAsync(42) invocation failed with mock behavior Strict. ⏎ Invocation needs to return a value and therefore must have a corresponding setup that provides it./* 2 */ mock.Setup(x => x.DoStuffAsync(42)).ReturnsAsync();// compile-time error (we do not have this method/overload)/* 3 */ mock.Setup(x => x.DoStuffAsync(42)).Returns(Task.CompletedTask);// OK, but shorter syntax desired by me
Then for DoStuffAsync, neither attempt 1 nor attempt 2 works. But I believe it would be natural to have a short syntax here, just like the short syntax seen in the Setup for the void-returning DoStuff above.
so would it not be expected that you could also give a delay for DoStuffAsync:
/* 2b */ mock.Setup(x => x.DoStuffAsync(42)).ReturnsAsync(delay: TimeSpan.FromMilliseconds(123.4));// compile-time error (we do not have this method/overload)
The text was updated successfully, but these errors were encountered:
Due to lack of recent activity, this issue has been labeled as 'stale'.
It will be closed if no further activity occurs within 30 more days.
Any new comment will remove the label.
Seen with Moq 4.18.4.
Suppose I have this interface:
So a string-returning method and a void-returning method; and
async
versions of both.Then suppose I want to make setups on a strict mock like this:
Then for
DoStuffAsync
, neither attempt1
nor attempt2
works. But I believe it would be natural to have a short syntax here, just like the short syntax seen in theSetup
for the void-returningDoStuff
above.Also, with
Task<string>
, we offer stuff like:so would it not be expected that you could also give a
delay
forDoStuffAsync
:The text was updated successfully, but these errors were encountered: