FsCheck icon indicating copy to clipboard operation
FsCheck copied to clipboard

How to use Collect from async test (C#)

Open jibbers42 opened this issue 2 years ago • 1 comments

I'm unable to return a Property from async tests. I'm not sure if the issue is more or less a missing overload in the api or if things are more complicated. Is there a way to use Collect from an async test (both assertion and bool style)?

// Assertion style
[Property]
public Property Test_async_function2() {
  return Prop.ForAll<DoNotSize<int>>(async i => {
    await Task.Delay(10);
    Assert.True(i.Item is int);
    // return true.Collect(i); // will not compile
  });
}

// Bool style
[Property]
public Property Test_async_function6() {
  return Prop.ForAll<DoNotSize<int>>(async i => {
    await Task.Delay(10);
    // return (i.Item is int).Collect(i.Item); // will not compile
  });
}

As an aside, I believe I had to update to v3 to get async tests to work and I notice a C# records fix recently landed. Will there be a v3 beta update soon? Is there a thread to track progress on when v3 will be released?

jibbers42 avatar Jun 03 '22 01:06 jibbers42

hmm, looks like a Task<Property> overload is missing for ForAll.

kurtschelfthout avatar Jun 03 '22 21:06 kurtschelfthout