Пример #1
0
        public static void LowerCaseJsonSerializerSettings_Should_Return_Parsed_Object()
        {
            // arrange
            var obj = new JsonExampleTest
            {
                SomeTest = "test"
            };

            // act
            var json = JsonConvert.SerializeObject(obj, JsonUtility.LowerCaseJsonSerializerSettings);

            // assert
            Assert.Contains("sometest", json);
        }
Пример #2
0
        public static void CamelCaseJsonSerializerSettings_Should_Return_Parsed_Object()
        {
            // arrange
            var obj = new JsonExampleTest
            {
                SomeTest  = "test",
                TestEnumm = TestEnumm.FirstName
            };

            // act
            var json = JsonConvert.SerializeObject(obj, JsonUtility.CamelCaseJsonSerializerSettings);

            // assert
            Assert.Contains("someTest", json);
            Assert.Contains("firstName", json);
        }
Пример #3
0
        public static void LowerCaseJsonSerializer_Should_Return_Parsed_Object()
        {
            // arrange
            var obj = new JsonExampleTest
            {
                SomeTest = "test"
            };
            StringBuilder sb         = new StringBuilder();
            StringWriter  sw         = new StringWriter(sb);
            JsonWriter    jsonWriter = new JsonTextWriter(sw);

            // act
            JsonUtility.LowerCaseJsonSerializer.Serialize(jsonWriter, obj);

            // assert
            Assert.Contains("sometest", sb.ToString());
        }
Пример #4
0
        public static void SnakeCaseJsonSerializerSettings_Should_Return_Parsed_Object()
        {
            // arrange
            var obj = new JsonExampleTest
            {
                SomeTest      = "test",
                CreateDDD     = "true",
                CreateDDDCode = "false",
                Create123asd  = "test",
                TestEnumm     = TestEnumm.FirstName
            };

            // act
            var json = JsonConvert.SerializeObject(obj, JsonUtility.SnakeCaseJsonSerializerSettings);

            // assert
            Assert.Contains("some_test", json);
            Assert.Contains("create_ddd\"", json);
            Assert.Contains("create_ddd_code", json);
            Assert.Contains("create123asd", json);
            Assert.Contains("first_name", json);
        }