Exemplo n.º 1
0
 public void ArrayContainingNull()
 {
     CyclicObject co = new CyclicObject();
       co.Array = new CyclicObject[3];
       string json = SimpleJson.SerializeObject(co);
       Assert.AreEqual("{\"Array\":[null,null,null],\"Dictionary\":{},\"GenericDictionary\":{}}", json);
 }
Exemplo n.º 2
0
 public void NullInDictionaryDoesNotSerialize()
 {
     CyclicObject co = new CyclicObject();
       co.Dictionary["Key"] = null;
       string json = SimpleJson.SerializeObject(co);
       Assert.AreEqual("{\"Array\":[null],\"Dictionary\":{},\"GenericDictionary\":{}}", json);
 }
Exemplo n.º 3
0
        public void HandleCircularObjectStructureInMultipleBranches_Dictionary()
        {
            CyclicObject cyclicObject = new CyclicObject();
              cyclicObject.Dictionary["Key1"] = cyclicObject;
              cyclicObject.Dictionary["Key2"] = cyclicObject;
              cyclicObject.Dictionary["Key3"] = cyclicObject;
              cyclicObject.Dictionary["Key4"] = cyclicObject;

              string json = SimpleJson.SerializeObject(cyclicObject);
              Assert.AreEqual("{\"Array\":[null],\"Dictionary\":{\"Key1\":\"" + SimpleJson.CYCLIC_MESSAGE + "\"," + "\"Key2\":\"" + SimpleJson.CYCLIC_MESSAGE + "\"," + "\"Key3\":\"" + SimpleJson.CYCLIC_MESSAGE + "\"," + "\"Key4\":\"" + SimpleJson.CYCLIC_MESSAGE + "\"},\"GenericDictionary\":{}}", json);
        }
Exemplo n.º 4
0
        public void HandleCircularObjectStructureInMultipleBranches_Array()
        {
            CyclicObject cyclicObject = new CyclicObject();
              cyclicObject.Array = new CyclicObject[4];
              cyclicObject.Array[0] = cyclicObject;
              cyclicObject.Array[1] = cyclicObject;
              cyclicObject.Array[2] = cyclicObject;
              cyclicObject.Array[3] = cyclicObject;

              string json = SimpleJson.SerializeObject(cyclicObject);
              Assert.AreEqual("{\"Array\":[\"" + SimpleJson.CYCLIC_MESSAGE + "\",\"" + SimpleJson.CYCLIC_MESSAGE + "\",\"" + SimpleJson.CYCLIC_MESSAGE + "\",\"" + SimpleJson.CYCLIC_MESSAGE + "\"],\"Dictionary\":{},\"GenericDictionary\":{}}", json);
        }
Exemplo n.º 5
0
        public void SetUp()
        {
            _cyclicObject = new CyclicObject();
              _cyclicObject.Child = _cyclicObject;

              _cyclicArray = new CyclicObject();
              _cyclicArray.Array[0] = _cyclicArray;

              _cyclicDictionary = new CyclicObject();
              _cyclicDictionary.Dictionary["Key"] = _cyclicDictionary;

              _cyclicGenericDictionary = new CyclicObject();
              _cyclicGenericDictionary.GenericDictionary["Key"] = _cyclicGenericDictionary;

              _deepCyclicObject = new CyclicObject();
              _deepCyclicObject.Child = new CyclicObject();
              _deepCyclicObject.Child.Array[0] = new CyclicObject();
              _deepCyclicObject.Child.Array[0].Dictionary["Key"] = _deepCyclicObject;

              _siblingObject = new CyclicObject();
              _siblingObject.Child = new CyclicObject();
              _siblingObject.Array[0] = _siblingObject.Child;
        }