You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

MqttPacketWriter_Tests.cs 818 B

6 jaren geleden
5 jaren geleden
123456789101112131415161718192021222324252627282930
  1. using Microsoft.VisualStudio.TestTools.UnitTesting;
  2. using MQTTnet.Formatter;
  3. namespace MQTTnet.Tests
  4. {
  5. [TestClass]
  6. public class MqttPacketWriter_Tests
  7. {
  8. protected virtual IMqttPacketWriter WriterFactory()
  9. {
  10. return new MqttPacketWriter();
  11. }
  12. [TestMethod]
  13. public void WritePacket()
  14. {
  15. var writer = WriterFactory();
  16. Assert.AreEqual(0, writer.Length);
  17. writer.WriteWithLengthPrefix("1234567890");
  18. Assert.AreEqual(10 + 2, writer.Length);
  19. writer.WriteWithLengthPrefix(new byte[300]);
  20. Assert.AreEqual(300 + 2 + 12, writer.Length);
  21. writer.WriteWithLengthPrefix(new byte[5000]);
  22. Assert.AreEqual(5000 + 2 + 300 + 2 + 12, writer.Length);
  23. }
  24. }
  25. }