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

            res2.SequenceEqual(req2).Should().BeTrue();
        }
Beispiel #2
0
        public void WhenDecryptAndSuppliedStrategy()
        {
            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 <IEncryptionStrategy>();

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

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

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

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