Created
May 19, 2017 17:19
-
-
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.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
[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