UnitTest1.cs 2.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869
  1. using DeviceInfoToAliIotHubViaGateway;
  2. using Microsoft.VisualStudio.TestTools.UnitTesting;
  3. using Newtonsoft.Json;
  4. using System;
  5. using System.Collections.Generic;
  6. using static DeviceInfoToAliIotHubViaGateway.App;
  7. namespace DeviceInfoToAliIotHubViaGatewayTest
  8. {
  9. [TestClass]
  10. public class UnitTest1
  11. {
  12. [TestMethod]
  13. public void TestMethod1()
  14. {
  15. List<KeyValuePair<string, object>> list = new List<KeyValuePair<string, object>>()
  16. {
  17. new KeyValuePair<string, object>("p1","v1"),
  18. };
  19. var vv = list.WrapToPropertiesChangedInLocalJson(12);
  20. }
  21. [TestMethod]
  22. public void TestMethod2()
  23. {
  24. List<KeyValuePair<string, object>> list = new List<KeyValuePair<string, object>>()
  25. {
  26. new KeyValuePair<string, object>("p1",222),
  27. };
  28. var vv = list.WrapToPropertiesChangedInLocalJson(12);
  29. }
  30. [TestMethod]
  31. public void TestMethod6()
  32. {
  33. List<KeyValuePair<string, object>> list = new List<KeyValuePair<string, object>>()
  34. {
  35. new KeyValuePair<string, object>("p1","v1"),
  36. new KeyValuePair<string, object>("p2","v2"),
  37. };
  38. var vv = list.WrapToPropertiesChangedInLocalJson(12);
  39. }
  40. [TestMethod]
  41. public void TestMethod8()
  42. {
  43. List<KeyValuePair<string, object>> list = new List<KeyValuePair<string, object>>()
  44. {
  45. new KeyValuePair<string, object>("p1","v1"),
  46. new KeyValuePair<string, object>("p2",2),
  47. new KeyValuePair<string, object>("p4","v4"),
  48. };
  49. var vv = list.WrapToPropertiesChangedInLocalJson(12);
  50. }
  51. [TestMethod]
  52. public void JsonSerializeTestMethod0()
  53. {
  54. //Alink_PropertyChanging_FromLocal request = new Alink_PropertyChanging_FromLocal() { id = "123" };
  55. //request.Params = new Dictionary<string, object>() {
  56. // { "p1", "v1" },
  57. // { "p2", 9999 },
  58. // { "p3", new DynamicDevice2TupleParam(){
  59. // deviceName = "myName", productKey = "myKey" } } };
  60. //var result = JsonConvert.SerializeObject(request,
  61. // new JsonSerializerSettings() { ContractResolver = new AliIotHubJsonFormatResolver() });
  62. }
  63. }
  64. }