// Copyright (c) .NET Foundation. All rights reserved. // Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. using System; using System.IO; using System.Threading.Tasks; using Microsoft.AspNetCore.Server.Kestrel.Http; using Microsoft.AspNetCore.Server.KestrelTests.TestHelpers; using Xunit; namespace Microsoft.AspNetCore.Server.KestrelTests { public class FrameResponseStreamTests { [Fact] public void CanReadReturnsFalse() { var stream = new FrameResponseStream(new MockFrameControl()); Assert.False(stream.CanRead); } [Fact] public void CanSeekReturnsFalse() { var stream = new FrameResponseStream(new MockFrameControl()); Assert.False(stream.CanSeek); } [Fact] public void CanWriteReturnsTrue() { var stream = new FrameResponseStream(new MockFrameControl()); Assert.True(stream.CanWrite); } [Fact] public void ReadThrows() { var stream = new FrameResponseStream(new MockFrameControl()); Assert.Throws(() => stream.Read(new byte[1], 0, 1)); } [Fact] public void ReadByteThrows() { var stream = new FrameResponseStream(new MockFrameControl()); Assert.Throws(() => stream.ReadByte()); } [Fact] public async Task ReadAsyncThrows() { var stream = new FrameResponseStream(new MockFrameControl()); await Assert.ThrowsAsync(() => stream.ReadAsync(new byte[1], 0, 1)); } #if NET451 [Fact] public void BeginReadThrows() { var stream = new FrameResponseStream(new MockFrameControl()); Assert.Throws(() => stream.BeginRead(new byte[1], 0, 1, null, null)); } #endif [Fact] public void SeekThrows() { var stream = new FrameResponseStream(new MockFrameControl()); Assert.Throws(() => stream.Seek(0, SeekOrigin.Begin)); } [Fact] public void LengthThrows() { var stream = new FrameResponseStream(new MockFrameControl()); Assert.Throws(() => stream.Length); } [Fact] public void SetLengthThrows() { var stream = new FrameResponseStream(new MockFrameControl()); Assert.Throws(() => stream.SetLength(0)); } [Fact] public void PositionThrows() { var stream = new FrameResponseStream(new MockFrameControl()); Assert.Throws(() => stream.Position); Assert.Throws(() => stream.Position = 0); } } }