您最多选择25个主题 主题必须以字母或数字开头,可以包含连字符 (-),并且长度不得超过35个字符

ByteWriterTests.cs 1.3 KiB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051
  1. using Microsoft.VisualStudio.TestTools.UnitTesting;
  2. using MQTTnet.Serializer;
  3. namespace MQTTnet.Core.Tests
  4. {
  5. [TestClass]
  6. public class ByteWriterTests
  7. {
  8. [TestMethod]
  9. public void ByteWriter_WriteMultipleAll()
  10. {
  11. var b = new ByteWriter();
  12. Assert.AreEqual(0, b.Value);
  13. b.Write(3, 2);
  14. Assert.AreEqual(3, b.Value);
  15. }
  16. [TestMethod]
  17. public void ByteWriter_WriteMultiplePartial()
  18. {
  19. var b = new ByteWriter();
  20. Assert.AreEqual(0, b.Value);
  21. b.Write(255, 2);
  22. Assert.AreEqual(3, b.Value);
  23. }
  24. [TestMethod]
  25. public void ByteWriter_WriteTo0xFF()
  26. {
  27. var b = new ByteWriter();
  28. Assert.AreEqual(0, b.Value);
  29. b.Write(true);
  30. Assert.AreEqual(1, b.Value);
  31. b.Write(true);
  32. Assert.AreEqual(3, b.Value);
  33. b.Write(true);
  34. Assert.AreEqual(7, b.Value);
  35. b.Write(true);
  36. Assert.AreEqual(15, b.Value);
  37. b.Write(true);
  38. Assert.AreEqual(31, b.Value);
  39. b.Write(true);
  40. Assert.AreEqual(63, b.Value);
  41. b.Write(true);
  42. Assert.AreEqual(127, b.Value);
  43. b.Write(true);
  44. Assert.AreEqual(255, b.Value);
  45. }
  46. }
  47. }