25개 이상의 토픽을 선택하실 수 없습니다. Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 

33 lines
870 B

  1. using Microsoft.VisualStudio.TestTools .UnitTesting;
  2. using MQTTnet.Client;
  3. namespace MQTTnet.Core.Tests
  4. {
  5. [TestClass]
  6. public class MqttPacketIdentifierProviderTests
  7. {
  8. [TestMethod]
  9. public void Reset()
  10. {
  11. var p = new MqttPacketIdentifierProvider();
  12. Assert.AreEqual(1, p.GetNewPacketIdentifier());
  13. Assert.AreEqual(2, p.GetNewPacketIdentifier());
  14. p.Reset();
  15. Assert.AreEqual(1, p.GetNewPacketIdentifier());
  16. }
  17. [TestMethod]
  18. public void ReachBoundaries()
  19. {
  20. var p = new MqttPacketIdentifierProvider();
  21. for (ushort i = 0; i < ushort.MaxValue; i++)
  22. {
  23. Assert.AreEqual(i + 1, p.GetNewPacketIdentifier());
  24. }
  25. Assert.AreEqual(1, p.GetNewPacketIdentifier());
  26. }
  27. }
  28. }