TestDictionary.cs 588 B

1234567891011121314151617181920212223242526272829
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Text;
  5. using Topten.JsonKit;
  6. using Xunit;
  7. namespace TestCases
  8. {
  9. public class TestDictionary
  10. {
  11. [Fact]
  12. public void DictionaryNonStringKeys()
  13. {
  14. var dict = new Dictionary<int, double>()
  15. {
  16. [-1] = 50,
  17. [0] = 100,
  18. [1] = 200,
  19. };
  20. var json = Json.Format(dict);
  21. var dict2 = Json.Parse<Dictionary<int, double>>(json);
  22. Assert.Equal(dict, dict2);
  23. }
  24. }
  25. }