Esempio 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");
        }
Esempio 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");
        }
Esempio 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");
        }