Ejemplo n.º 1
0
        public void NLSMap_JSONSerializationRoundtrip()
        {
            var content = "{eng: {n: 'Cucumber',d: 'It is green'}, deu: {n: 'Gurke', d: 'Es ist grün'}}";

            var nls = new NLSMap(content);

            var json = nls.ToJson();

            json.See();

            var nls2 = new NLSMap(json);

            Aver.AreEqual(2, nls2.Count);
            Aver.AreEqual("Cucumber", nls2["eng"].Name);
            Aver.AreEqual("Gurke", nls2["deu"].Name);
            Aver.AreEqual(null, nls["rus"].Name);
        }
Ejemplo n.º 2
0
        public void NLSMap_SerializeAll()
        {
            var content = "{eng: {n: 'Cucumber',d: 'It is green'}, deu: {n: 'Gurke', d: 'Es ist grün'}}";

            var nls = new NLSMap(content);

            var json = nls.ToJson();

            Console.WriteLine(json);

            dynamic read = json.JsonToDynamic();

            Aver.IsNotNull(read);

            Aver.AreEqual("Cucumber", read.ENG.n);
            Aver.AreEqual("Gurke", read.DEU.n);
        }
Ejemplo n.º 3
0
        public void NLSMap_SerializeOnlyOneNoneExisting()
        {
            var content = "{eng: {n: 'Cucumber',d: 'It is green'}, deu: {n: 'Gurke', d: 'Es ist grün'}}";

            var nls = new NLSMap(content);

            var options = new JsonWritingOptions {
                NLSMapLanguageISO = CoreConsts.ISOA_LANG_RUSSIAN, Purpose = JsonSerializationPurpose.UIFeed
            };
            var json = nls.ToJson(options);

            json.See();

            dynamic read = json.JsonToDynamic();

            Aver.IsNotNull(read);

            Aver.AreEqual("Cucumber", read.n);
            Aver.AreEqual("It is green", read.d);
        }
Ejemplo n.º 4
0
        public void NLSMap_SerializeOnlyOneExisting()
        {
            var content = "{eng: {n: 'Cucumber',d: 'It is green'}, deu: {n: 'Gurke', d: 'Es ist grün'}}";

            var nls = new NLSMap(content);


            var options = new JsonWritingOptions {
                NLSMapLanguageISO = "deu", Purpose = JsonSerializationPurpose.UIFeed
            };
            var json = nls.ToJson(options);

            Console.WriteLine(json);

            dynamic read = json.JsonToDynamic();

            Aver.IsNotNull(read);

            Aver.AreEqual("Gurke", read.n);
            Aver.AreEqual("Es ist grün", read.d);
        }