2
0

SshDataTest.cs 1.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758
  1. using Microsoft.VisualStudio.TestTools.UnitTesting;
  2. using Renci.SshNet.Common;
  3. namespace Renci.SshNet.Tests.Classes.Common
  4. {
  5. [TestClass]
  6. public class SshDataTest
  7. {
  8. [TestMethod]
  9. public void Write_Boolean_False()
  10. {
  11. var sshData = new BoolSshData(false);
  12. var bytes = sshData.GetBytes();
  13. Assert.AreEqual((byte) 0, bytes[0]);
  14. }
  15. [TestMethod]
  16. public void Write_Boolean_True()
  17. {
  18. var sshData = new BoolSshData(true);
  19. var bytes = sshData.GetBytes();
  20. Assert.AreEqual((byte) 1, bytes[0]);
  21. }
  22. private class BoolSshData : SshData
  23. {
  24. private readonly bool _value;
  25. public BoolSshData(bool value)
  26. {
  27. _value = value;
  28. }
  29. public new bool IsEndOfData
  30. {
  31. get { return base.IsEndOfData; }
  32. }
  33. public new byte ReadByte()
  34. {
  35. return base.ReadByte();
  36. }
  37. protected override void LoadData()
  38. {
  39. }
  40. protected override void SaveData()
  41. {
  42. Write(_value);
  43. }
  44. }
  45. }
  46. }