Ejemplo n.º 1
0
        public void Validate_OnNoWildcards()
        {
            // Arrange
            var rawTopic = TestUtils.GenerateSingleValidTopic();
            var rule     = new MustHaveAtMostOneMultiLevelWildcard();

            // Act
            Action validatingRawTopic = () =>
                                        rule.Validate(rawTopic);

            // Assert
            validatingRawTopic.Should()
            .NotThrow <IllegalTopicConstructionException>(
                "because the wildcard count is not violated");
        }
Ejemplo n.º 2
0
        public void Validate_OnOneWildcard()
        {
            // Arrange
            var rawTopic = Mqtt.Wildcard.MultiLevel.ToString();
            var rule     = new MustHaveAtMostOneMultiLevelWildcard();

            // Act
            Action validatingRawTopic = () =>
                                        rule.Validate(rawTopic);

            // Assert
            validatingRawTopic.Should()
            .NotThrow <IllegalTopicConstructionException>(
                "because the wildcard count is not violated");
        }
Ejemplo n.º 3
0
        public void Validate_OnMoreThanOneWildcard()
        {
            // Arrange
            var wildcardsCount = Fixture.Create <int>() + 2;
            var rawTopic       = new string(Mqtt.Wildcard.MultiLevel, wildcardsCount);
            var rule           = new MustHaveAtMostOneMultiLevelWildcard();

            // Act
            Action validatingRawTopic = () =>
                                        rule.Validate(rawTopic);

            // Assert
            validatingRawTopic.Should()
            .Throw <IllegalTopicConstructionException>(
                "because there is more than one wildcard, which is forbidden");
        }