Skip to content

Instantly share code, notes, and snippets.

@solvingj
Created May 19, 2017 17:19
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save solvingj/84f8e0a6e6db5512efa0d5df01f0d529 to your computer and use it in GitHub Desktop.
Save solvingj/84f8e0a6e6db5512efa0d5df01f0d529 to your computer and use it in GitHub Desktop.
Is this unit test valid? It succeeds, but I dunno if Task.Factory.StartNew really imitates an async task from a 3rd party library.
[Fact]
public async Task can_return_failed_exceptional_from_async_task_try()
{
Func<Task<int>> mathFunc = () => Task.Factory.StartNew(() => Int32.Parse(""));
Exceptional<int> exceptionalInt = await Tryable.Try(mathFunc);
//Assert
exceptionalInt.IsFailure.Should().BeTrue();
exceptionalInt.ToString().ShouldBeEquivalentTo("Input string was not in a correct format.");
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment