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.
 
 
 
 

37 lines
1.0 KiB

  1. // Licensed to the .NET Foundation under one or more agreements.
  2. // The .NET Foundation licenses this file to you under the MIT license.
  3. // See the LICENSE file in the project root for more information.
  4. using Microsoft.VisualStudio.TestTools.UnitTesting;
  5. using MQTTnet.Client;
  6. namespace MQTTnet.Tests
  7. {
  8. [TestClass]
  9. public class MqttPacketIdentifierProvider_Tests
  10. {
  11. [TestMethod]
  12. public void Reset()
  13. {
  14. var p = new MqttPacketIdentifierProvider();
  15. Assert.AreEqual(1, p.GetNextPacketIdentifier());
  16. Assert.AreEqual(2, p.GetNextPacketIdentifier());
  17. p.Reset();
  18. Assert.AreEqual(1, p.GetNextPacketIdentifier());
  19. }
  20. [TestMethod]
  21. public void ReachBoundaries()
  22. {
  23. var p = new MqttPacketIdentifierProvider();
  24. for (ushort i = 0; i < ushort.MaxValue; i++)
  25. {
  26. Assert.AreEqual(i + 1, p.GetNextPacketIdentifier());
  27. }
  28. Assert.AreEqual(1, p.GetNextPacketIdentifier());
  29. }
  30. }
  31. }