コード例 #1
0
        public void Validate_OnNonEmptyString()
        {
            // Arrange
            var rawTopic = TestUtils.GenerateSingleValidTopic();
            var rule     = new MustNotBeBlank();

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

            // Assert
            validatingRawTopic.Should()
            .NotThrow <EmptyTopicException>(
                "because a topic with a valid value should not break the rule");
        }
コード例 #2
0
        public void Validate_OnEmptyString()
        {
            // Arrange
            var rawTopic = string.Empty;

            var rule = new MustNotBeBlank();

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

            // Assert
            validatingRawTopic.Should()
            .Throw <EmptyTopicException>(
                "because an empty topic should break the rule");
        }
コード例 #3
0
        public void Validate_OnNullString()
        {
            // Arrange
            string rawTopic = null;

            var rule = new MustNotBeBlank();

            // Act
            // ReSharper disable once ExpressionIsAlwaysNull
            Action validatingRawTopic = () =>
                                        rule.Validate(rawTopic);

            // Assert
            validatingRawTopic.Should()
            .Throw <EmptyTopicException>(
                "because an null topic should break the rule");
        }
コード例 #4
0
        public void Validate_OnBlankString()
        {
            // Arrange
            var whitespaceCount = Fixture.Create <int>() + 1;
            var rawTopic        = new string(' ', whitespaceCount);

            var rule = new MustNotBeBlank();

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

            // Assert
            validatingRawTopic.Should()
            .Throw <EmptyTopicException>(
                "because a blank topic should break the rule");
        }