public void ShouldMatchPropertyName() { IMatchingRule rule = new PropertyMatchingRule("MyProperty"); Assert.IsTrue(rule.Matches(getMyProperty)); Assert.IsTrue(rule.Matches(setMyProperty)); }
public void ShouldNotMatchGetWithSetOption() { IMatchingRule rule = new PropertyMatchingRule("MyProperty", PropertyMatchingOption.Set); Assert.IsFalse(rule.Matches(getMyProperty)); Assert.IsTrue(rule.Matches(setMyProperty)); }
public void ShouldMatchWithWildcard() { IMatchingRule rule = new PropertyMatchingRule("My*"); Assert.IsTrue(rule.Matches(getMyProperty)); Assert.IsTrue(rule.Matches(setMyProperty)); Assert.IsTrue(rule.Matches(getMyOtherProperty)); }
public void ShouldMatchWithMultipleMatchTargets() { IMatchingRule rule = new PropertyMatchingRule(new PropertyMatchingInfo[] { new PropertyMatchingInfo("MyProperty"), new PropertyMatchingInfo("ACompletelyDifferentProperty", PropertyMatchingOption.Set) }); Assert.IsTrue(rule.Matches(getMyProperty)); Assert.IsTrue(rule.Matches(setMyProperty)); Assert.IsFalse(rule.Matches(getMyOtherProperty)); Assert.IsFalse(rule.Matches(getACompletelyDifferentProperty)); Assert.IsTrue(rule.Matches(setACompletelyDifferentProperty)); }
/// <summary> /// Builds an instance of the subtype of IMatchingRule type the receiver knows how to build, based on /// a configuration object. /// </summary> /// <param name="context">The <see cref="IBuilderContext"/> that represents the current building process.</param> /// <param name="objectConfiguration">The configuration object that describes the object to build.</param> /// <param name="configurationSource">The source for configuration objects.</param> /// <param name="reflectionCache">The cache to use retrieving reflection information.</param> /// <returns>A fully initialized instance of the IMatchingRule subtype.</returns> public IMatchingRule Assemble( IBuilderContext context, MatchingRuleData objectConfiguration, IConfigurationSource configurationSource, ConfigurationReflectionCache reflectionCache) { PropertyMatchingRuleData propertyData = (PropertyMatchingRuleData)objectConfiguration; List <PropertyMatchingInfo> info = new List <PropertyMatchingInfo>(); foreach (PropertyMatchData data in propertyData.Matches) { info.Add(new PropertyMatchingInfo(data.Match, data.MatchOption, data.IgnoreCase)); } PropertyMatchingRule rule = new PropertyMatchingRule(info); return(rule); }
public void ShouldNotMatchPathologiciallyNamedMethod() { IMatchingRule rule = new PropertyMatchingRule("NotAProperty"); Assert.IsFalse(rule.Matches(setNotAProperty)); }