Ejemplo n.º 1
0
        public void NullArrayOfValueTypeIsNotSerialize()
        {
            var entity = new EntityWithArray
            {
                EntityWithArrayID = "hello",
                IntArray          = null
            };

            Serializer subject = SerializationTestHelper.CreateSerializer(typeof(EntityWithArray));
            JObject    doc     = subject.Serialize("2-update", "entity-with-array", entity);

            Assert.IsFalse(doc.Children().OfType <JProperty>().Any(x => x.Name.Equals("intArray")));
        }
Ejemplo n.º 2
0
        public void Entity_With_Array()
        {
            var entity = new EntityWithArray
            {
                EntityWithArrayID = "hello",
                StringArray       = new[] { "A", "BB", "CCC" },
                IntArray          = new[] { 80, 79, 78 }
            };

            Serializer subject = SerializationTestHelper.CreateSerializer(typeof(EntityWithArray));
            JObject    doc     = subject.Serialize("2-update", "entity-with-array", entity);

            Assert.IsNotNull(doc, "Fail to serialize simple entity");
            CollectionAssert.AreEqual(new[] { "A", "BB", "CCC" }, JArrayHelper.ArrayOf <string>((JArray)doc["stringArray"]));
            CollectionAssert.AreEqual(new[] { 80, 79, 78 }, JArrayHelper.ArrayOf <int>((JArray)doc["intArray"]));
        }