Explorar el Código

Unit test for int key dictionaries

Brad Robinson hace 3 años
padre
commit
1528361be9
Se han modificado 1 ficheros con 29 adiciones y 0 borrados
  1. 29 0
      Topten.JsonKit.Test/TestDictionary.cs

+ 29 - 0
Topten.JsonKit.Test/TestDictionary.cs

@@ -0,0 +1,29 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using Topten.JsonKit;
+using Xunit;
+
+namespace TestCases
+{
+    public class TestDictionary
+    {
+        [Fact]
+        public void DictionaryNonStringKeys()
+        {
+            var dict = new Dictionary<int, double>()
+            {
+                [-1] = 50,
+                [0] = 100,
+                [1] = 200,
+            };
+
+            var json = Json.Format(dict);
+
+            var dict2 = Json.Parse<Dictionary<int, double>>(json);
+
+            Assert.Equal(dict, dict2);
+        }
+    }
+}