public void BadNetwork(string mockUrl, string detectionUrl) { mMockClient.SetResponse(mockUrl, new MockHttpResponse { StatusCode = HttpStatusCode.GatewayTimeout }); Assert.Throws(typeof(AggregateException), () => { mDetector.DetectImagesAsync(new Uri($"{BaseUrl}{detectionUrl}")).Wait(); }); Assert.Equal(expected: ImageDetectorState.BadNetwork, actual: mDetector.State); Thread.Sleep(4); mDetector.CheckStateAsync().Wait(); Assert.Equal(expected: ImageDetectorState.Good, actual: mDetector.State); }