Exemplo n.º 1
0
        public void WhenDecodeAndDefaultStrategy()
        {
            var req1 = System.Text.Encoding.UTF8.GetBytes("Hello world! :)");
            var val1 = new BinaryValue(req1, null);
            var res1 = val1.Decode().Value;

            res1.Should().Be("Hello world! :)");
        }
Exemplo n.º 2
0
        public void WhenDecodeAndSuppliedStrategy()
        {
            var mockRequest  = System.Text.Encoding.UTF8.GetBytes("Hello world! :)");
            var mockResponse = "Hello world! :)";

            var mockStrategy = new Mock <IEncodingStrategy>();

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

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

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

            res1.Should().Be(mockResponse);
            mockStrategy.Verify(m => m.Decode(req1), Times.Once);
        }