Exemplo n.º 1
0
        public void TryDecodeAndDeserialize_ReturnsNull_IfInvalidString()
        {
            const string encoded = "not a valid base64 encoded string";

            var deserialized = HeaderEncoder.TryDecodeAndDeserialize <CrossApplicationRequestData>(encoded, "encodingKey");

            Assert.Null(deserialized);
        }
Exemplo n.º 2
0
        public void TryDecodeAndDeserialize_ReturnsNull_IfObjectCannotBeDeserializedAsExpectedType()
        {
            const string encoded = "PkwEGg0NTEstBBUWC09NEBsHFwIBW0lMEw4QASYGOA1bOA==";

            var deserialized = HeaderEncoder.TryDecodeAndDeserialize <MetricWireModel>(encoded, "encodingKey");

            Assert.Null(deserialized);
        }
Exemplo n.º 3
0
        public void TryDecodeAndDeserialize_ReturnsNull_IfIncorrectEncodingKey()
        {
            const string encoded = "PkwEGg0NTEstBBUWC09NEBsHFwIBW0lMEw4QASYGOA1bOA==";

            var deserialized = HeaderEncoder.TryDecodeAndDeserialize <CrossApplicationRequestData>(encoded, "wrong!");

            Assert.Null(deserialized);
        }
Exemplo n.º 4
0
        public void SerializeAndEncode_CreatesCorrectEncodedString_IfNonNullEncodingKey()
        {
            var data = new CrossApplicationRequestData("guid", false, "tripId", "pathHash");

            var encoded = HeaderEncoder.EncodeSerializedData(JsonConvert.SerializeObject(data), "encodingKey");

            Assert.AreEqual("PkwEGg0NTEstBBUWC09NEBsHFwIBW0lMEw4QASYGOA1bOA==", encoded);
        }
Exemplo n.º 5
0
        public void SerializeAndEncode_CreatesCorrectEncodedString_IfNullEncodingKey()
        {
            var data = new CrossApplicationRequestData("guid", false, "tripId", "pathHash");

            var encoded = HeaderEncoder.EncodeSerializedData(JsonConvert.SerializeObject(data), null);

            Assert.AreEqual("WyJndWlkIixmYWxzZSwidHJpcElkIiwicGF0aEhhc2giXQ==", encoded);
        }
Exemplo n.º 6
0
        public void TryDecodeAndDeserialize_ReturnsCorrectDeserializedObject_IfNonNullEncodingKey()
        {
            const string encoded = "PkwEGg0NTEstBBUWC09NEBsHFwIBW0lMEw4QASYGOA1bOA==";

            var deserialized = HeaderEncoder.TryDecodeAndDeserialize <CrossApplicationRequestData>(encoded, "encodingKey");

            Assert.NotNull(deserialized);

            NrAssert.Multiple(
                () => Assert.AreEqual("guid", deserialized.TransactionGuid),
                () => Assert.AreEqual(false, deserialized.Unused),
                () => Assert.AreEqual("tripId", deserialized.TripId),
                () => Assert.AreEqual("pathHash", deserialized.PathHash)
                );
        }
Exemplo n.º 7
0
        public void TryDecodeAndDeserialize_ReturnsCorrectDeserializedObject_IfNullEncodingKey()
        {
            const string encoded = "WyJndWlkIixmYWxzZSwidHJpcElkIiwicGF0aEhhc2giXQ==";

            var deserialized = HeaderEncoder.TryDecodeAndDeserialize <CrossApplicationRequestData>(encoded, null);

            Assert.NotNull(deserialized);

            NrAssert.Multiple(
                () => Assert.AreEqual("guid", deserialized.TransactionGuid),
                () => Assert.AreEqual(false, deserialized.Unused),
                () => Assert.AreEqual("tripId", deserialized.TripId),
                () => Assert.AreEqual("pathHash", deserialized.PathHash)
                );
        }