Esempio n. 1
0
        public void SerializeToString ()
        {
            var obj = new TestObject ();

            var json = context.CakeContext.SerializeJson (obj);

            Assert.IsNotEmpty (json);
            Assert.AreEqual (SERIALIZED_JSON, json);
        }
Esempio n. 2
0
        public void SerializeToStringWithIndentation()
        {
            var obj = new TestObject ();

            var json = context.CakeContext.SerializeJson (obj, Formatting.Indented);

            Assert.IsNotEmpty (json);
            Assert.AreEqual (SERIALIZED_JSON_INDENTED, json);
        }
Esempio n. 3
0
        public void SerializeToFile ()
        {
            var obj = new TestObject ();

            var file = new FilePath ("./serialized.json");

            context.CakeContext.SerializeJsonToFile (file, obj);

            var json = System.IO.File.ReadAllText (file.MakeAbsolute (context.CakeContext.Environment).FullPath);

            Assert.IsNotEmpty (json);
            Assert.AreEqual (SERIALIZED_JSON, json);
        }