I'm seeing a problem probably related to NCrunch.
See the code below.
One needs NUnit and NSubstitute nuget packages. It's a .net 4.6.1 class library.
The test passes.
Now, add System.Threading.Tasks.Extensions 4.5.1 nuget library and test will start failing.
If running outside NCrunch test still succeeds.
If I downgrade System.Threading.Tasks.Extensions to i.e. 4.4.0. it works again.
I think that MS screwed something with System.Threading.Tasks.Extensions 4.5.1 (it manifests problems in i.e. Xamarin as well).
Perhaps something to consider.
You can download repro
here.
Code:
[TestFixture]
public class Tests
{
[Test]
public async Task Test()
{
var target = new Some();
var worker = Substitute.For<IWorker>();
await target.ProcessAsync(worker);
worker.Received(1).Confirm();
}
}
public interface IWorker
{
void Confirm();
}
public class Some
{
public async Task<bool> ProcessAsync(IWorker worker)
{
await Tubo();
worker.Confirm();
return true;
}
async ValueTask<bool> Tubo()
{
return true;
}
}