public void IsMatchThrowsExceptionWithNullProperty()
        {
            var sut = new RegexIgnoreRule(NameExpression.FirstName);

            Action action = () => sut.IsMatch(null !);

            action.Should().Throw <ArgumentNullException>();
        }
        public void IsMatchReturnsWhenPropertyMatchesExpression(string expression, bool expected)
        {
            var property = typeof(Person).GetProperty(nameof(Person.FirstName)) !;

            var sut = new RegexIgnoreRule(expression);

            var actual = sut.IsMatch(property);

            actual.Should().Be(expected);
        }
        public void IsMatchReturnsTrueWhenPropertyMatches()
        {
            var property = typeof(Person).GetProperty(nameof(Person.FirstName)) !;

            var sut = new RegexIgnoreRule(NameExpression.FirstName);

            var actual = sut.IsMatch(property);

            actual.Should().BeTrue();
        }
Пример #4
0
        /// <summary>
        ///     Adds a new <see cref="RegexIgnoreRule" /> to the configuration.
        /// </summary>
        /// <param name="configuration">The configuration.</param>
        /// <param name="expression">The expression that matches a property name.</param>
        /// <returns>The configuration.</returns>
        /// <exception cref="ArgumentNullException">The <paramref name="configuration" /> parameter is <c>null</c>.</exception>
        /// <exception cref="ArgumentNullException">The <paramref name="expression" /> parameter is <c>null</c>.</exception>
        public static IBuildConfiguration AddIgnoreRule(
            this IBuildConfiguration configuration,
            Regex expression)
        {
            configuration = configuration ?? throw new ArgumentNullException(nameof(configuration));

            expression = expression ?? throw new ArgumentNullException(nameof(expression));

            var rule = new RegexIgnoreRule(expression);

            configuration.IgnoreRules.Add(rule);

            return(configuration);
        }
Пример #5
0
        /// <summary>
        ///     Adds a new <see cref="RegexIgnoreRule" /> to the configuration.
        /// </summary>
        /// <param name="configuration">The configuration.</param>
        /// <param name="expression">The expression that matches a property name.</param>
        /// <returns>The configuration.</returns>
        /// <exception cref="ArgumentNullException">The <paramref name="configuration" /> parameter is <c>null</c>.</exception>
        /// <exception cref="ArgumentNullException">The <paramref name="expression" /> parameter is <c>null</c> or empty.</exception>
        public static IBuildConfiguration AddIgnoreRule(
            this IBuildConfiguration configuration,
            string expression)
        {
            configuration = configuration ?? throw new ArgumentNullException(nameof(configuration));

            if (string.IsNullOrEmpty(expression))
            {
                throw new ArgumentNullException(nameof(expression));
            }

            var rule = new RegexIgnoreRule(expression);

            configuration.IgnoreRules.Add(rule);

            return(configuration);
        }