-
-
Notifications
You must be signed in to change notification settings - Fork 798
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Adding exension methods ReturnsAsync and ThrowsAsync for ISetupSequentialResult #261
Adding exension methods ReturnsAsync and ThrowsAsync for ISetupSequentialResult #261
Conversation
/// </summary> | ||
public static ISetupSequentialResult<Task<TResult>> ReturnsAsync<TResult>(this ISetupSequentialResult<Task<TResult>> setup, TResult value) | ||
{ | ||
var tcs = new TaskCompletionSource<TResult>(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why not Task.FromResult directly?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, I was wondering myself too.
Apparently it's available only in .NET 4.5 http://stackoverflow.com/a/21258011/41956
But all projects seems are targeting .NET 4.0 so I decided do not change much including tests same PR.
.ReturnsAsync(3) | ||
.ThrowsAsync(new InvalidOperationException()); | ||
|
||
Assert.Equal(2, mock.Object.DoAsync().Result); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Because of .NET 4.0 I can't properly await DoAsync() here and below.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe it's time to drop the ball on .NET < 4.5? Since it isn't even a
aupported version anymore, is it?
On Wed, May 18, 2016 at 1:40 PM Alexander Batishchev <
notifications@github.com> wrote:
In UnitTests/SequenceExtensionsFixture.cs
#261 (comment):@@ -21,6 +22,29 @@ public void PerformSequence()
}[Fact]
public void PerformSequenceAsync()
{
var mock = new Mock<IFoo>();
mock.SetupSequence(x => x.DoAsync())
.ReturnsAsync(2)
.ReturnsAsync(3)
.ThrowsAsync(new InvalidOperationException());
Assert.Equal(2, mock.Object.DoAsync().Result);
Because of .NET 4.0 I can't properly await DoAsync() here and below.
—
You are receiving this because you modified the open/close state.Reply to this email directly or view it on GitHub
https://github.com/moq/moq4/pull/261/files/fe053cec0eb2592edaa4730b5aa8ca6e9acaedc0#r63738514
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm for it. The minimal officially supported version now days is 4.5.2. So I'd jump to 4.6.1.
Cool, thanks for merging! |
Should be there already in the Moq.4.5.6-alpha Thanks! On Sun, May 22, 2016 at 1:22 AM Alexander Batishchev <
|
How often do you release stable version usually? Please consider one. |
Usually after a couple PRs, but right now we're in the middle of adding On Sun, May 22, 2016, 3:36 PM Alexander Batishchev notifications@github.com
|
Does it mean wait for Core RTM/RTW? Would you consider the last release before Core? |
Good point. Yes, upgrade to .NET 4.5 can ship now On Mon, May 23, 2016 at 1:59 AM Alexander Batishchev <
|
No description provided.