예제 #1
0
        public void WhenCompressAndDefaultStrategy()
        {
            var req1 = System.Text.Encoding.UTF8.GetBytes("Hello world! :)");
            var val1 = new BinaryValue(req1, null);
            var res1 = val1.Compress().Value;

            res1.SequenceEqual(req1).Should().BeTrue();
        }
예제 #2
0
        public void WhenCompressAndSuppliedStrategy()
        {
            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.Compress(mockRequest)).Returns(mockResponse);

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

            var req1 = mockRequest;
            var val1 = new BinaryValue(req1, opt);
            var res1 = val1.Compress().Value;

            res1.SequenceEqual(mockResponse).Should().BeTrue();
            mockStrategy.Verify(m => m.Compress(req1), Times.Once);
        }