예제 #1
0
        public void WhenDecompressAndDefaultStrategy()
        {
            var req2 = System.Text.Encoding.UTF8.GetBytes("Hello world! :)");
            var val2 = new BinaryValue(req2, null);
            var res2 = val2.Decompress().Value;

            res2.SequenceEqual(req2).Should().BeTrue();
        }
예제 #2
0
        public void WhenDecompressAndSuppliedStrategy()
        {
            var mockRequest  = System.Text.Encoding.UTF8.GetBytes("Hello world! :)");
            var mockResponse = new byte[] { 1, 2, 3, 4, 5, 6, 7, 8 };

            var mockStrategy = new Mock <ICompressionStrategy>();

            mockStrategy.Setup(m => m.Decompress(mockResponse)).Returns(mockRequest);

            var opt = new SerializationOptions
            {
                Compression = mockStrategy.Object
            };

            var req2 = mockResponse;
            var val2 = new BinaryValue(req2, opt);
            var res2 = val2.Decompress().Value;

            res2.SequenceEqual(mockRequest).Should().BeTrue();
            mockStrategy.Verify(m => m.Decompress(req2), Times.Once);
        }