Exemplo n.º 1
0
        public void ToJsonTest()
        {
            var student = StudentMocker.MockOneStudent();

            string json       = SerializeUtil.ToJson(student);
            string newtonJson = Newtonsoft.Json.JsonConvert.SerializeObject(student, new Newtonsoft.Json.Converters.StringEnumConverter());

            Assert.Equal(json, newtonJson);
        }
Exemplo n.º 2
0
        public void Collection_Test()
        {
            IList <Student> students = new List <Student> {
                StudentMocker.MockOneStudent(), StudentMocker.MockOneStudent()
            };

            string json       = SerializeUtil.ToJson(students);
            string newtonJson = Newtonsoft.Json.JsonConvert.SerializeObject(students, new Newtonsoft.Json.Converters.StringEnumConverter());

            _outputHelper.WriteLine(json);
            _outputHelper.WriteLine(newtonJson);

            Assert.Equal(json, newtonJson);

            IList <Student>?fromJson = SerializeUtil.FromJson <IList <Student> >(json);
        }