예제 #1
0
파일: NLSMapTests.cs 프로젝트: azist/azos
        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);
        }
예제 #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);
        }
예제 #3
0
파일: NLSMapTests.cs 프로젝트: azist/azos
        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);
        }
예제 #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);
        }