public void Can_serialize_Model_with_list_of_escape_chars()
        {
            var model = new ModelWithList {
                Id         = 1,
                StringList = { @"1 \ 2 \r 3 \n 4 \b 5 \f 6 """, @"1 \ 2 \r 3 \n 4 \b 5 \f 6 """ }
            };

            SerializeAndCompare(model);
        }
        public void Can_serialize_Model_with_list()
        {
            var model = new ModelWithList {
                Id         = 1,
                StringList = { "One", "Two", "Three" }
            };

            SerializeAndCompare(model);
        }
        public void Can_serialize_Model_with_array()
        {
            var model = new ModelWithList {
                Id          = 1,
                StringArray = new[] { "One", "Two", "Three" }
            };

            SerializeAndCompare(model);
        }
示例#4
0
 public bool Equals(ModelWithList other)
 {
     if (ReferenceEquals(null, other))
     {
         return(false);
     }
     if (ReferenceEquals(this, other))
     {
         return(true);
     }
     return(other.Id == Id && StringList.EquivalentTo(other.StringList));
 }
示例#5
0
        public void Can_deserialize_nested_json_list_with_slash_at_end_of_value()
        {
            var model = new ModelWithList
            {
                Id         = 1,
                StringList = { "One", "Two\\" },
            };

            const string json = "{ \"Id\" : 1, \"StringList\" : [ \"One\", \"Two\\\\\" ] }";

            var fromJson = JsonSerializer.DeserializeFromString <ModelWithList>(json);

            Assert.That(fromJson.Id, Is.EqualTo(model.Id));
            Assert.That(fromJson.StringList, Is.EqualTo(model.StringList));
        }
示例#6
0
        public void Can_deserialize_json_list_with_whitespace()
        {
            var model = new ModelWithList
            {
                Id         = 1,
                StringList = { " One ", " Two " }
            };

            Log(JsonSerializer.SerializeToString(model));

            const string json = "\t { \"Id\" : 1 , \n \"StringList\" \t : \n [ \t \" One \" \t , \t \" Two \" \t ] \n } \t ";

            var fromJson = JsonSerializer.DeserializeFromString <ModelWithList>(json);

            Assert.That(fromJson, Is.EqualTo(model));
        }
        public void Can_deserialize_json_list_with_whitespace()
        {
            var model = new ModelWithList
            {
                Id = 1,
                StringList = { " One ", " Two " }
            };

            Log(JsonSerializer.SerializeToString(model));

            const string json = "\t { \"Id\" : 1 , \n \"StringList\" \t : \n [ \t \" One \" \t , \t \" Two \" \t ] \n } \t ";

            var fromJson = JsonSerializer.DeserializeFromString<ModelWithList>(json);

            Assert.That(fromJson, Is.EqualTo(model));
        }
        public void Can_serialize_Model_with_list_of_escape_chars()
        {
            var model = new ModelWithList {
                Id = 1,
                StringList = { @"1 \ 2 \r 3 \n 4 \b 5 \f 6 """, @"1 \ 2 \r 3 \n 4 \b 5 \f 6 """ }
            };

            SerializeAndCompare(model);
        }
        public void Can_serialize_Model_with_list()
        {
            var model = new ModelWithList {
                Id = 1,
                StringList = { "One", "Two", "Three" }
            };

            SerializeAndCompare(model);
        }
        public void Can_serialize_Model_with_array()
        {
            var model = new ModelWithList {
                Id = 1,
                StringArray = new[]{ "One", "Two", "Three" }
            };

            SerializeAndCompare(model);
        }
			public bool Equals(ModelWithList other)
			{
				if (ReferenceEquals(null, other)) return false;
				if (ReferenceEquals(this, other)) return true;
				return other.Id == Id && StringList.EquivalentTo(other.StringList);
			}
        public void Can_deserialize_nested_json_list_with_slash_at_end_of_value()
        {
            var model = new ModelWithList
            {
                Id = 1,
                StringList = { "One", "Two\\" },
            };

            const string json = "{ \"Id\" : 1, \"StringList\" : [ \"One\", \"Two\\\\\" ] }";

            var fromJson = JsonSerializer.DeserializeFromString<ModelWithList>(json);

            Assert.That(fromJson.Id, Is.EqualTo(model.Id));
            Assert.That(fromJson.StringList, Is.EqualTo(model.StringList));
        }