Decode() public method

Decodes the specified value.
public Decode ( byte value ) : byte[]
value byte The byte array to decode.
return byte[]
Example #1
0
        public void Decode_WithNull_ReturnsNull()
        {
            var encoding = new ContentEncoder("gzip");
            var nullBytes = encoding.Decode(null);

            Assert.IsNull(nullBytes);
        }
Example #2
0
        public void Decode_WithNull_ReturnsNull()
        {
            var encoding  = new ContentEncoder("gzip");
            var nullBytes = encoding.Decode(null);

            Assert.IsNull(nullBytes);
        }
Example #3
0
        public void Decode_UsingUnknownMethod_ReturnsSame()
        {
            var encoding = new ContentEncoder("badmethod");
            var actual   = encoding.Decode(_helloWorldGZip);

            CollectionAssert.AreEqual(_helloWorldGZip, actual);
        }
Example #4
0
        public void Decode_UsingGzip_ReturnsDecompressed()
        {
            var encoding = new ContentEncoder("gzip");
            var actual   = encoding.Decode(_helloWorldGZip);

            CollectionAssert.AreEqual(_helloWorldUtf8, actual);
        }
Example #5
0
        public void Decode_UsingDeflate_ReturnsDecompressed()
        {
            var encoding = new ContentEncoder("deflate");
            var actual   = encoding.Decode(_helloWorldDeflate);

            CollectionAssert.AreEqual(_helloWorldUtf8, actual);
        }
Example #6
0
        public void Encode_UsingDeflate_ReturnsCompressed()
        {
            var encoding = new ContentEncoder("deflate");
            var actual   = encoding.Encode(_helloWorldUtf8);

            // assert that we got back something different
            CollectionAssert.AreNotEqual(_helloWorldUtf8, actual);

            var roundTrip = encoding.Decode(actual);

            CollectionAssert.AreEqual(_helloWorldUtf8, roundTrip);
        }
Example #7
0
        public void Encode_UsingGzip_ReturnsCompressed()
        {
            var encoding = new ContentEncoder("gzip");
            var actual   = encoding.Encode(_helloWorldUtf8);

            CollectionAssert.AreNotEqual(_helloWorldUtf8, actual);

            // assert that the gzip header is present
            Assert.AreEqual(actual[0], 31);
            Assert.AreEqual(actual[1], 139);

            var roundTrip = encoding.Decode(actual);

            CollectionAssert.AreEqual(_helloWorldUtf8, roundTrip);
        }
Example #8
0
        public void Encode_UsingGzipUppercase_ReturnsCompressed()
        {
            var encoding = new ContentEncoder("GZIP");
            var actual = encoding.Encode(_helloWorldUtf8);

            // assert that we got back something different
            CollectionAssert.AreNotEqual(_helloWorldUtf8, actual);

            // assert that the gzip header is present
            Assert.AreEqual(actual[0], 31);
            Assert.AreEqual(actual[1], 139);

            var roundTrip = encoding.Decode(actual);
            CollectionAssert.AreEqual(_helloWorldUtf8, roundTrip);
        }
Example #9
0
        public void Encode_UsingDeflate_ReturnsCompressed()
        {
            var encoding = new ContentEncoder("deflate");
            var actual = encoding.Encode(_helloWorldUtf8);

            // assert that we got back something different
            CollectionAssert.AreNotEqual(_helloWorldUtf8, actual);

            var roundTrip = encoding.Decode(actual);

            CollectionAssert.AreEqual(_helloWorldUtf8, roundTrip);
        }
Example #10
0
 public void Decode_UsingUnknownMethod_ReturnsSame()
 {
     var encoding = new ContentEncoder("badmethod");
     var actual = encoding.Decode(_helloWorldGZip);
     CollectionAssert.AreEqual(_helloWorldGZip, actual);
 }
Example #11
0
 public void Decode_UsingGzip_ReturnsDecompressed()
 {
     var encoding = new ContentEncoder("gzip");
     var actual = encoding.Decode(_helloWorldGZip);
     CollectionAssert.AreEqual(_helloWorldUtf8, actual);
 }
Example #12
0
 public void Decode_UsingDeflate_ReturnsDecompressed()
 {
     var encoding = new ContentEncoder("deflate");
     var actual = encoding.Decode(_helloWorldDeflate);
     CollectionAssert.AreEqual(_helloWorldUtf8, actual);
 }