public async Task ArgumentException() { // prepare var invalid = new InvalidStream(); var md = new MimeDetector(); // act && verify await Assert.ThrowsAsync <ArgumentException>(() => md.DetectAsync(invalid)); }
public async Task IgnoreResponse_Test() { using var bodyStream = new InvalidStream(); using var response = new HttpResponseMessage(); // IgnoreResponse() によってレスポンスの Stream が読まれずに破棄されることをテストするため、 // 読み込みが行われると IOException が発生する InvalidStream クラスを bodyStream に使用している response.Content = new StreamContent(bodyStream); using var lazyJson = new LazyJson <string>(response); // レスポンスボディを読まずに破棄 await Task.FromResult(lazyJson) .IgnoreResponse() .ConfigureAwait(false); Assert.True(bodyStream.IsDisposed); }
public async Task IgnoreResponse_Test() { using (var bodyStream = new InvalidStream()) using (var response = new HttpResponseMessage()) { // IgnoreResponse() によってレスポンスの Stream が読まれずに破棄されることをテストするため、 // 読み込みが行われると IOException が発生する InvalidStream クラスを bodyStream に使用している response.Content = new StreamContent(bodyStream); using (var lazyJson = new LazyJson<string>(response)) { // レスポンスボディを読まずに破棄 await Task.FromResult(lazyJson) .IgnoreResponse() .ConfigureAwait(false); Assert.True(bodyStream.IsDisposed); } } }