SshDataTest.cs 1.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152
  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 MySshData();
  12. sshData.Load(new byte[0]);
  13. sshData.Write(false);
  14. Assert.AreEqual((byte) 0, sshData.ReadByte());
  15. Assert.IsTrue(sshData.IsEndOfData);
  16. }
  17. [TestMethod]
  18. public void Write_Boolean_True()
  19. {
  20. var sshData = new MySshData();
  21. sshData.Load(new byte[0]);
  22. sshData.Write(true);
  23. Assert.AreEqual((byte) 1, sshData.ReadByte());
  24. Assert.IsTrue(sshData.IsEndOfData);
  25. }
  26. private class MySshData : SshData
  27. {
  28. public new void Write(bool data)
  29. {
  30. base.Write(data);
  31. }
  32. public new byte ReadByte()
  33. {
  34. return base.ReadByte();
  35. }
  36. protected override void LoadData()
  37. {
  38. }
  39. protected override void SaveData()
  40. {
  41. }
  42. }
  43. }
  44. }