Beispiel #1
0
        public void SerializePayloadArrayTest()
        {
            var payload = new List <PayloadStub>()
            {
                new PayloadStub
                {
                    Prop1 = 1,
                    Prop2 = "value",
                    Prop3 = false,
                    Prop4 = new List <PayloadStub>()
                    {
                        new PayloadStub {
                            Prop2 = "nested"
                        }
                    }
                }
            };
            var serializer = new JsonOutputSerializer(new Settings {
            });
            var str        = serializer.SerializePayload(payload);
            var obj        = JsonConvert.DeserializeObject <List <PayloadStub> >(str);

            Assert.AreEqual(payload[0].Prop1, obj[0].Prop1);
            Assert.AreEqual(payload[0].Prop2, obj[0].Prop2);
            Assert.AreEqual(payload[0].Prop3, obj[0].Prop3);
            Assert.AreEqual(payload[0].Prop4.Count, obj[0].Prop4.Count);
            Assert.AreEqual(payload[0].Prop4[0].Prop2, obj[0].Prop4[0].Prop2);
        }
Beispiel #2
0
        public void SerializePayloadTest()
        {
            var payload    = new { property = "value", count = 2 };
            var serializer = new JsonOutputSerializer(new Settings {
            });
            var     str    = serializer.SerializePayload <dynamic>(payload);
            dynamic obj    = JObject.Parse(str);

            Assert.AreEqual(payload.property, (string)obj.property);
            Assert.AreEqual(payload.count, (int)obj.count);
        }