Skip to content
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

Merged
merged 1 commit into from
May 18, 2016
Merged

Adding exension methods ReturnsAsync and ThrowsAsync for ISetupSequentialResult #261

merged 1 commit into from
May 18, 2016

Conversation

abatishchev
Copy link
Contributor

No description provided.

/// </summary>
public static ISetupSequentialResult<Task<TResult>> ReturnsAsync<TResult>(this ISetupSequentialResult<Task<TResult>> setup, TResult value)
{
var tcs = new TaskCompletionSource<TResult>();
Copy link
Member

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?

Copy link
Contributor Author

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.

@kzu kzu merged commit 978d379 into devlooped:master May 18, 2016
.ReturnsAsync(3)
.ThrowsAsync(new InvalidOperationException());

Assert.Equal(2, mock.Object.DoAsync().Result);
Copy link
Contributor Author

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.

Copy link
Member

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

Copy link
Contributor Author

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.

@abatishchev abatishchev deleted the SetupSequence-ReturnsAsync-1 branch May 22, 2016 04:20
@abatishchev
Copy link
Contributor Author

Cool, thanks for merging!
Do you have any idea when to release the latest changes?

@kzu
Copy link
Member

kzu commented May 22, 2016

Should be there already in the Moq.4.5.6-alpha

Thanks!

On Sun, May 22, 2016 at 1:22 AM Alexander Batishchev <
notifications@github.com> wrote:

Cool, thanks for merging!
Do you have any idea when to release the latest changes?


You are receiving this because you modified the open/close state.

Reply to this email directly or view it on GitHub
#261 (comment)

@abatishchev
Copy link
Contributor Author

How often do you release stable version usually? Please consider one.

@kzu
Copy link
Member

kzu commented May 22, 2016

Usually after a couple PRs, but right now we're in the middle of adding
support for. Net core, so I'd rather wait a bit so it's a worthy 4.5 upgrade

On Sun, May 22, 2016, 3:36 PM Alexander Batishchev notifications@github.com
wrote:

How often do you release stable version usually? Please consider one.


You are receiving this because you modified the open/close state.

Reply to this email directly or view it on GitHub
#261 (comment)

@abatishchev
Copy link
Contributor Author

Does it mean wait for Core RTM/RTW? Would you consider the last release before Core?
Personally I'd have two: the last before .NET 4.5 and the last before Core.
As a compromising solution: upgrade to 4.5 now and then wait indefinitely till Core is released.

@kzu
Copy link
Member

kzu commented May 23, 2016

Good point. Yes, upgrade to .NET 4.5 can ship now

On Mon, May 23, 2016 at 1:59 AM Alexander Batishchev <
notifications@github.com> wrote:

Does it mean wait for Core RTM/RTW? Would you consider the last release
before Core?
Personally I'd have two: the last before .NET 4.5 and the last before Core.
As a compromising solution: upgrade to 4.5 now and then wait indefinitely
till Core is released.


You are receiving this because you modified the open/close state.

Reply to this email directly or view it on GitHub
#261 (comment)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants