DeviceHandlerTest.cs 3.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Threading;
  5. using Microsoft.VisualStudio.TestTools.UnitTesting;
  6. using Edge.Core.Parser.BinaryParser.Util;
  7. using Wayne_Pump_Dart.MessageEntity;
  8. using Wayne_Pump_Dart.MessageEntity.Incoming;
  9. using Wayne_Pump_Dart.MessageEntity.Outgoing;
  10. using Microsoft.Extensions.DependencyInjection;
  11. namespace Test_Wayne_Pump_Dart
  12. {
  13. [TestClass]
  14. public class DeviceHandlerTest
  15. {
  16. public static bool ValueEquals(IEnumerable<byte> array1, IEnumerable<byte> array2)
  17. {
  18. if (array1 == null && array2 == null)
  19. {
  20. return true;
  21. }
  22. if ((array1 == null) || (array2 == null))
  23. {
  24. return false;
  25. }
  26. if (array1.Count() != array2.Count())
  27. {
  28. return false;
  29. }
  30. if (array1.Equals(array2))
  31. {
  32. return true;
  33. }
  34. else
  35. {
  36. for (int Index = 0; Index < array1.Count(); Index++)
  37. {
  38. if (!Equals(array1.ElementAt(Index), array2.ElementAt(Index)))
  39. {
  40. return false;
  41. }
  42. }
  43. }
  44. return true;
  45. }
  46. [TestMethod]
  47. public void TestMethod1()
  48. {
  49. var services = new ServiceCollection();
  50. services.AddLogging();
  51. Wayne_Pump_Dart.PumpGroupHandler pumpGroupHanlder = new Wayne_Pump_Dart.PumpGroupHandler(
  52. new Wayne_Pump_Dart.PumpGroupHandler.PumpGroupConfiguration()
  53. {
  54. AmountDecimalDigits = 1,
  55. PriceDecimalDigits = 2,
  56. VolumeDecimalDigits = 3,
  57. VolumeTotalizerDecimalDigits = 4,
  58. PumpConfigurations = new List<Wayne_Pump_Dart.PumpGroupHandler.PumpConfiguration>()
  59. {
  60. new Wayne_Pump_Dart.PumpGroupHandler.PumpConfiguration()
  61. {
  62. PumpId = 1,
  63. PhysicalId = 5,
  64. NozzleConfigurations = new List<Wayne_Pump_Dart.PumpGroupHandler.NozzleConfiguration>()
  65. {
  66. new Wayne_Pump_Dart.PumpGroupHandler.NozzleConfiguration()
  67. {
  68. LogicalId = 1,
  69. PhysicalId = 1,
  70. },
  71. new Wayne_Pump_Dart.PumpGroupHandler.NozzleConfiguration()
  72. {
  73. LogicalId = 2,
  74. PhysicalId = 2,
  75. }
  76. }
  77. },
  78. new Wayne_Pump_Dart.PumpGroupHandler.PumpConfiguration()
  79. {
  80. PumpId = 2,
  81. PhysicalId = 6,
  82. NozzleConfigurations = new List<Wayne_Pump_Dart.PumpGroupHandler.NozzleConfiguration>()
  83. {
  84. new Wayne_Pump_Dart.PumpGroupHandler.NozzleConfiguration()
  85. {
  86. LogicalId = 1,
  87. PhysicalId = 1,
  88. },
  89. new Wayne_Pump_Dart.PumpGroupHandler.NozzleConfiguration()
  90. {
  91. LogicalId = 2,
  92. PhysicalId = 2,
  93. }
  94. }
  95. }
  96. }
  97. }, services.BuildServiceProvider()
  98. );
  99. }
  100. }
  101. }