Nevar pievienot vairāk kā 25 tēmas Tēmai ir jāsākas ar burtu vai ciparu, tā var saturēt domu zīmes ('-') un var būt līdz 35 simboliem gara.
 
 
 
 

52 rindas
1.3 KiB

  1. using Microsoft.VisualStudio.TestTools.UnitTesting;
  2. using MQTTnet.Core.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. }