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.
 
 
 
 

38 lines
965 B

  1. using Microsoft.VisualStudio.TestTools.UnitTesting;
  2. using MQTTnet.Exceptions;
  3. using MQTTnet.Protocol;
  4. namespace MQTTnet.Tests
  5. {
  6. [TestClass]
  7. public class MqttTopicValidator_Tests
  8. {
  9. [TestMethod]
  10. public void Valid_Topic()
  11. {
  12. MqttTopicValidator.ThrowIfInvalid("/a/b/c");
  13. }
  14. [TestMethod]
  15. [ExpectedException(typeof(MqttProtocolViolationException))]
  16. public void Invalid_Topic_Plus()
  17. {
  18. MqttTopicValidator.ThrowIfInvalid("/a/+/c");
  19. }
  20. [TestMethod]
  21. [ExpectedException(typeof(MqttProtocolViolationException))]
  22. public void Invalid_Topic_Hash()
  23. {
  24. MqttTopicValidator.ThrowIfInvalid("/a/#/c");
  25. }
  26. [TestMethod]
  27. [ExpectedException(typeof(MqttProtocolViolationException))]
  28. public void Invalid_Topic_Empty()
  29. {
  30. MqttTopicValidator.ThrowIfInvalid(string.Empty);
  31. }
  32. }
  33. }