public void Validate_OnTopicShorterThanMaximumLimit() { // Arrange const int length = Mqtt.Topic.MaxSubTopicLength / 2; var rawTopic = new string(Fixture.Create <char>(), length); var rule = new MustRespectMaximumLength(); // Act Action validatingRawTopic = () => rule.Validate(rawTopic); // Assert validatingRawTopic.Should() .NotThrow <TooLongTopicException>( "because the topic is under the defined bound"); }
public void Validate_OnTopicWithExactSameLengthAsMaximumLimit() { // Arrange const int length = Mqtt.Topic.MaxSubTopicLength; var rawTopic = new string(Fixture.Create <char>(), length); var rule = new MustRespectMaximumLength(); // Act Action validatingRawTopic = () => rule.Validate(rawTopic); // Assert validatingRawTopic.Should() .NotThrow <TooLongTopicException>( "because the topic as reached the maximum limit but does not exceed it"); }
public void Validate_OnTopicLongerThanMaximumLimit() { // Arrange var length = Fixture.Create <int>() + Mqtt.Topic.MaxSubTopicLength; var rawTopic = new string(Fixture.Create <char>(), length); var rule = new MustRespectMaximumLength(); // Act Action validatingRawTopic = () => rule.Validate(rawTopic); // Assert validatingRawTopic.Should() .Throw <TooLongTopicException>( "because the topic is exceeding the maximum allowed size"); }