Exemplo n.º 1
0
        public void LargeModeSerializeWithUnknownData()
        {
            var sharedDictionary = new SharedDictionary(new SystemTextJsonSerializer(SerializeMode.LargeObject), null, null);

            sharedDictionary.RawImport(Encoding.UTF8.GetBytes(JsonConstant.LargeModeJsonWithUnknownData));
            Assert.AreEqual(sharedDictionary.PropertyCount, 1);
            Assert.AreEqual(sharedDictionary.GetProperty <int>("key2"), 1);
        }
Exemplo n.º 2
0
        public void ShortModeSerializeWithUnknownData()
        {
            var sharedDictionary = new SharedDictionary(SpanJsonSerializer.Create(SerializeMode.ShortObject), null, null);

            sharedDictionary.RawImport(Encoding.UTF8.GetBytes(JsonConstant.ShortModeJsonWithUnknownData));
            Assert.AreEqual(sharedDictionary.PropertyCount, 1);
            Assert.AreEqual(sharedDictionary.GetProperty <int>("key2"), 1);
        }
Exemplo n.º 3
0
        public void LargeModeSerialize()
        {
            var sharedDictionary = new SharedDictionary(new SystemTextJsonSerializer(SerializeMode.LargeObject), null, null);

            sharedDictionary.RawImport(Encoding.UTF8.GetBytes(JsonConstant.LargeModeJson));
            Assert.AreEqual(sharedDictionary.GetProperty <string>("key1"), "string");
            Assert.AreEqual(sharedDictionary.GetProperty <int>("key2"), 1);
        }
Exemplo n.º 4
0
        public void ShortModeSerialize()
        {
            var sharedDictionary = new SharedDictionary(SpanJsonSerializer.Create(SerializeMode.ShortObject), null, null);

            sharedDictionary.RawImport(Encoding.UTF8.GetBytes(JsonConstant.ShortModeJson));
            Assert.AreEqual(sharedDictionary.GetProperty <string>("key1"), "string");
            Assert.AreEqual(sharedDictionary.GetProperty <int>("key2"), 1);
        }
Exemplo n.º 5
0
        public void LargeModeNullValue()
        {
            var sharedDictionary = new SharedDictionary(new SystemTextJsonSerializer(SerializeMode.LargeObject), null, null);

            sharedDictionary.SetProperty <int?>("nullableInt", null);
            sharedDictionary.SetProperty <string?>("nullableString", null);

            byte[] binary = sharedDictionary.RawExport();
            sharedDictionary.ClearProperty();
            Assert.AreEqual(0, sharedDictionary.PropertyCount);
            sharedDictionary.RawImport(binary);

            Assert.AreEqual(null, sharedDictionary.GetProperty <int?>("nullableInt"));
            Assert.AreEqual(null, sharedDictionary.GetProperty <string?>("nullableString"));
        }