Beispiel #1
0
        public void AJson_JsonHelper_BuildJsonForObject_SimpleObject()
        {
            SimpleGuy d = new SimpleGuy()
            {
                What = 3, Noice = 5
            };
            Json json = JsonHelper.BuildJsonForObject(d);

            Assert.IsNotNull(json);
            Assert.IsFalse(json.HasErrors, "Json parse errors:\n" + String.Join("\n\t", json.Errors));

            json.AssertSourceIsValid();
        }
Beispiel #2
0
        public void AJson_JsonBuilding_DeserializeJsonToObject_WorksWithSimpleGuy()
        {
            SimpleGuy guy = new SimpleGuy();

            guy.What  = 2;
            guy.Noice = 3;
            Json json = JsonHelper.BuildJsonForObject(guy);

            Assert.IsNotNull(json);
            Assert.IsFalse(json.HasErrors, "Json parse errors:\n" + String.Join("\n\t", json.Errors));

            string    simpleGuyJson = json.Data.StringValue;
            SimpleGuy serializedGuy = JsonHelper.BuildObjectForJson <SimpleGuy>(json);

            Assert.IsTrue(guy.Equals(serializedGuy));
        }