public async Task IfWeCantReachServerWeShouldHaveWebExceptionAsync() { try { await _fakeClient.GetAsync(); } catch (Exception e) //catch all, for asserts will narrow scope next { Assert.That(e is AggregateException, "When failing to connect to server, did not recieve aggregate exception."); var aggregateException = (AggregateException)e; if (aggregateException.InnerExceptions.Count == 1) { Assert.That(aggregateException.InnerException is WebException && aggregateException.InnerException.Message.Contains(UnableToReachServerMessage) || aggregateException.InnerException.InnerException.Message.Contains( UnableToReachServerMessage), "When failing to connect to server, did not recieve the expected web exception."); } else { Assert.That( aggregateException.InnerExceptions.Any( ex => ex is AggregateException && ex.Message.Contains(UnableToReachServerMessage)), "When failing to connect to server, did not recieve the expected web exception."); } } A.CallTo(() => _fakeClient.ConvertMillisecondsToDateTime(NaN)).WithAnyArguments().MustNotHaveHappened(); //we're depending on this not to fire if we didn't reach server }