Exemplo n.º 1
0
        public void SetLength_LessThanSingleBuffer_Truncates()
        {
            var stream = new HttpResponseStream();
            var buffer = new byte [10];

            stream.Write(buffer, 0, 10);
            stream.SetLength(5);

            long length = stream.Length;

            Assert.AreEqual(5, length);
        }
Exemplo n.º 2
0
        public void SetLength_LongerThanSingleBuffer_AddsFiller()
        {
            var stream = new HttpResponseStream();
            var buffer = new byte [10];

            stream.Write(buffer, 0, 10);

            stream.SetLength(25);

            long length = stream.Length;

            Assert.AreEqual(25, length);
        }
Exemplo n.º 3
0
        public void SetLength_EqualToCurrentLength_LengthStaysTheSame()
        {
            var stream = new HttpResponseStream();
            var buffer = new byte [10];

            stream.Write(buffer, 0, 10);
            stream.Write(buffer, 0, 10);

            stream.SetLength(20);

            long length = stream.Length;

            Assert.AreEqual(20, length);
        }
Exemplo n.º 4
0
        public void SetLength_MultiBuffer_AddsFiller()
        {
            var stream = new HttpResponseStream ();
            var buffer = new byte [10];

            stream.Write (buffer, 0, 10);
            stream.Write (buffer, 0, 10);

            stream.SetLength (25);

            long length = stream.Length;
            Assert.AreEqual (25, length);
        }
Exemplo n.º 5
0
        public void SetLength_LessThanSingleBuffer_Truncates()
        {
            var stream = new HttpResponseStream ();
            var buffer = new byte [10];

            stream.Write (buffer, 0, 10);
            stream.SetLength (5);

            long length = stream.Length;
            Assert.AreEqual (5, length);
        }
Exemplo n.º 6
0
        public void SetLength_EqualToCurrentLength_LengthStaysTheSame()
        {
            var stream = new HttpResponseStream ();
            var buffer = new byte [10];

            stream.Write (buffer, 0, 10);
            stream.Write (buffer, 0, 10);

            stream.SetLength (20);

            long length = stream.Length;
            Assert.AreEqual (20, length);
        }
        public void SetLengthThrows()
        {
            var stream = new HttpResponseStream(Mock.Of <IHttpBodyControlFeature>(), new MockHttpResponseControl());

            Assert.Throws <NotSupportedException>(() => stream.SetLength(0));
        }