ExtensionsTest_ToBigInteger2.cs 1.0 KB

1234567891011121314151617181920212223242526272829303132333435363738
  1. using Microsoft.VisualStudio.TestTools.UnitTesting;
  2. using Renci.SshNet.Common;
  3. namespace Renci.SshNet.Tests.Classes.Common
  4. {
  5. [TestClass]
  6. public class ExtensionsTest_ToBigInteger2
  7. {
  8. [TestMethod]
  9. public void ShouldNotAppendZero()
  10. {
  11. byte[] value = { 0x0a, 0x0d };
  12. var actual = value.ToBigInteger2().ToByteArray(isBigEndian: true);
  13. Assert.IsNotNull(actual);
  14. Assert.AreEqual(2, actual.Length);
  15. Assert.AreEqual(0x0a, actual[0]);
  16. Assert.AreEqual(0x0d, actual[1]);
  17. }
  18. [TestMethod]
  19. public void ShouldAppendZero()
  20. {
  21. byte[] value = { 0xff, 0x0a, 0x0d };
  22. var actual = value.ToBigInteger2().ToByteArray(isBigEndian: true);
  23. Assert.IsNotNull(actual);
  24. Assert.AreEqual(4, actual.Length);
  25. Assert.AreEqual(0x00, actual[0]);
  26. Assert.AreEqual(0xff, actual[1]);
  27. Assert.AreEqual(0x0a, actual[2]);
  28. Assert.AreEqual(0x0d, actual[3]);
  29. }
  30. }
  31. }