Quantcast
Viewing all articles
Browse latest Browse all 3

Answer by Bruno Garcia for Moq Throw async exception in one of tasks in call to Task.WhenAll

Task.WhenAll will call StartAsync, that will throw.The exception is thrown on the calling thread. Before a task could be created.

You want StartAsync to return a Task:

firstProcessor.Setup(x => x.StartAsync(It.IsAny<TextWriter>())).Returns(new Task(() => { throw new Exception("err"); }));

Viewing all articles
Browse latest Browse all 3

Trending Articles