DerDataTest.cs 3.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122
  1. using Renci.SshNet.Common;
  2. using Microsoft.VisualStudio.TestTools.UnitTesting;
  3. using System;
  4. namespace Renci.SshNet.Tests.Common
  5. {
  6. [TestClass()]
  7. public class DerDataTest
  8. {
  9. private TestContext testContextInstance;
  10. /// <summary>
  11. ///Gets or sets the test context which provides
  12. ///information about and functionality for the current test run.
  13. ///</summary>
  14. public TestContext TestContext
  15. {
  16. get
  17. {
  18. return testContextInstance;
  19. }
  20. set
  21. {
  22. testContextInstance = value;
  23. }
  24. }
  25. #region Additional test attributes
  26. //
  27. //You can use the following additional attributes as you write your tests:
  28. //
  29. //Use ClassInitialize to run code before running the first test in the class
  30. //[ClassInitialize()]
  31. //public static void MyClassInitialize(TestContext testContext)
  32. //{
  33. //}
  34. //
  35. //Use ClassCleanup to run code after all tests in a class have run
  36. //[ClassCleanup()]
  37. //public static void MyClassCleanup()
  38. //{
  39. //}
  40. //
  41. //Use TestInitialize to run code before running each test
  42. //[TestInitialize()]
  43. //public void MyTestInitialize()
  44. //{
  45. //}
  46. //
  47. //Use TestCleanup to run code after each test has run
  48. //[TestCleanup()]
  49. //public void MyTestCleanup()
  50. //{
  51. //}
  52. //
  53. #endregion
  54. // TODO: Restore those tests
  55. //[TestMethod]
  56. //[TestCategory("DER")]
  57. //[Description("Long form, test example given in 8.1.3.5")]
  58. //[Owner("Kenneth_aa")]
  59. //[DeploymentItem("Renci.SshNet.dll")]
  60. //public void Test_Der_GetLength_LongForm_MustNotFail()
  61. //{
  62. // // Taken from example in 8.1.3.5
  63. // // L = 201 can be encoded as:
  64. // // 1 0 0 0 0 0 0 1
  65. // // 1 1 0 0 1 0 0 1
  66. // int length = 201;
  67. // byte[] expected = new byte[2]
  68. // {
  69. // 0x81, // 1 0 0 0 0 0 0 1
  70. // 0xC9 // 1 1 0 0 1 0 0 1
  71. // };
  72. // byte[] actual = Helper_GetLength(length);
  73. // Helper_CompareByteArray(expected, actual);
  74. // Assert.Inconclusive("Verify the correctness of this test method.");
  75. //}
  76. //[TestMethod]
  77. //[TestCategory("DER")]
  78. //[Description("Short form, test example given in 8.1.3.5")]
  79. //[Owner("Kenneth_aa")]
  80. //[DeploymentItem("Renci.SshNet.dll")]
  81. //public void Test_Der_GetLength_ShortForm_MustNotFail()
  82. //{
  83. // int length = 127;
  84. // byte[] expected = new byte[1]
  85. // {
  86. // 0x7F // 0 1 1 1 1 1 1 1
  87. // };
  88. // byte[] actual = Helper_GetLength(length);
  89. // Helper_CompareByteArray(expected, actual);
  90. //}
  91. /// <summary>
  92. /// Compares 2 byte arrays.
  93. /// </summary>
  94. /// <param name="expected">Expected result.</param>
  95. /// <param name="actual">Actual result.</param>
  96. void Helper_CompareByteArray(byte[] expected, byte[] actual)
  97. {
  98. Assert.AreEqual(expected.Length, actual.Length, "Length mismatch: Expected.Length = {0} - Actual.Length = {1}", expected.Length, actual.Length);
  99. for (int i = 0; i < expected.Length; i++)
  100. Assert.AreEqual<byte>(expected[i], actual[i], "Byte mismatch at index {0}", i);
  101. }
  102. ///// <summary>
  103. ///// Wrapper for calling DerData.GetLength()
  104. ///// </summary>
  105. //byte[] Helper_GetLength(int length)
  106. //{
  107. // DerData_Accessor target = new DerData_Accessor();
  108. // return target.GetLength(length);
  109. //}
  110. }
  111. }