Exemple #1
0
        public void ShouldParse_MessageExtrasJson_WithEmptyDelta()
        {
            const string json = @"{
                            'random':'boo',
                            'foo':'fooValue',
                            'bar':'barValue',
                            'object' : {
                                'key1': 'value1',
                                'key2': 'value2'
                            }
                        }";

            var originalJToken = JToken.Parse(json);
            var messageExtras  = JsonConvert.DeserializeObject <MessageExtras>(json, _jsonSettings);

            ((string)messageExtras.ToJson()["random"]).Should().Be("boo");
            ((string)messageExtras.ToJson()["foo"]).Should().Be("fooValue");
            ((string)messageExtras.ToJson()["bar"]).Should().Be("barValue");
            ((string)messageExtras.ToJson()["object"]["key1"]).Should().Be("value1");
            ((string)messageExtras.ToJson()["object"]["key2"]).Should().Be("value2");

            var serialized       = JsonConvert.SerializeObject(messageExtras, _jsonSettings);
            var serializedJToken = JToken.Parse(serialized);

            JAssert.DeepEquals(serializedJToken, originalJToken, _testOutputHelper).Should().Be(true);
        }
Exemple #2
0
        public void ShouldParse_MessageExtrasJson_WithDelta()
        {
            const string json = @"{
                            'delta': {
                                'From': '1',
                                'Format':'best'
                             }
                        }";

            var originalJToken = JToken.Parse(json);
            var messageExtras  = JsonConvert.DeserializeObject <MessageExtras>(json, _jsonSettings);

            messageExtras.Delta.Should().NotBeNull();
            messageExtras.Delta.From.Should().Be("1");
            messageExtras.Delta.Format.Should().Be("best");

            var serialized       = JsonConvert.SerializeObject(messageExtras, _jsonSettings);
            var serializedJToken = JToken.Parse(serialized);

            JAssert.DeepEquals(serializedJToken, originalJToken, _testOutputHelper).Should().Be(true);
        }