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.

MqttPacketIdentifierProviderTests.cs 870 B

преди 7 години
1234567891011121314151617181920212223242526272829303132
  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. }