public void IsMatchThrowsExceptionWithNullProperty() { var sut = new PredicateIgnoreRule(x => x.Name == nameof(Person.FirstName)); Action action = () => sut.IsMatch(null !); action.Should().Throw <ArgumentNullException>(); }
public void IsMatchReturnsTrueWhenPropertyMatchesDerivedTypeProperty() { var property = typeof(Person).GetProperty(nameof(Entity.Id)) !; var sut = new PredicateIgnoreRule(x => x.DeclaringType == typeof(Entity)); var actual = sut.IsMatch(property); actual.Should().BeTrue(); }
public void IsMatchReturnsTrueWhenPropertyMatches() { var property = typeof(Person).GetProperty(nameof(Person.FirstName)) !; var sut = new PredicateIgnoreRule(x => x.Name == nameof(Person.FirstName)); var actual = sut.IsMatch(property); actual.Should().BeTrue(); }
public void IsMatchReturnsFalseWhenPropertyTypeDoesNotMatch() { var property = typeof(Person).GetProperty(nameof(Person.LastName)) !; var sut = new PredicateIgnoreRule(x => x.PropertyType == typeof(DateTimeOffset)); var actual = sut.IsMatch(property); actual.Should().BeFalse(); }
public void IsMatchReturnsTrueWhenInheritedPropertyMatchesPropertyOnDeclaredType() { var property = typeof(Person).GetProperty(nameof(Entity.Id)) !; var sut = new PredicateIgnoreRule(x => x.ReflectedType == typeof(Person) && x.Name == nameof(Entity.Id) && x.PropertyType == typeof(Guid)); var actual = sut.IsMatch(property); actual.Should().BeTrue(); }
/// <summary> /// Adds a new <see cref="PredicateIgnoreRule" /> to the configuration. /// </summary> /// <param name="configuration">The configuration.</param> /// <param name="predicate">The predicate that matches on a property.</param> /// <returns>The configuration.</returns> /// <exception cref="ArgumentNullException">The <paramref name="configuration" /> parameter is <c>null</c>.</exception> /// <exception cref="ArgumentNullException">The <paramref name="predicate" /> parameter is <c>null</c>.</exception> public static IBuildConfiguration AddIgnoreRule( this IBuildConfiguration configuration, Predicate <PropertyInfo> predicate) { configuration = configuration ?? throw new ArgumentNullException(nameof(configuration)); predicate = predicate ?? throw new ArgumentNullException(nameof(predicate)); var rule = new PredicateIgnoreRule(predicate); configuration.IgnoreRules.Add(rule); return(configuration); }