public void AddGlobalParseRule_GIVEN_propertyParseRule_With_StyleClass_Already_Exists_WHEN_propertyParseRule_With_propertyParseName_Added_Again_THEN_Throws_InvalidOperationException() { var propertyParseRule = new PropertyParseRule("StyleClass"); var set = new DelimeterSet(); set.AddGlobalPropertyParseRule(propertyParseRule); set.AddGlobalPropertyParseRule(propertyParseRule); }
public void AddGlobalPropertyParseRule_Adds_PropertyParseRule_To_GlobalList() { var propertyParseRule = new PropertyParseRule("StyleClass"); var set = new DelimeterSet(); set.AddGlobalPropertyParseRule(propertyParseRule); set.GlobalPropertyParseRules.ShouldContain(propertyParseRule); }
/// <summary> /// Adds a parse rule for a property which will be applied to only this delimeter /// </summary> /// <param name="propertyParseRule">property parse rule to add</param> public void AddPropertyParseRule(PropertyParseRule propertyParseRule) { if (propertyParseRule == null) throw new ArgumentNullException("properyParseRule"); if (_localPropertyParseRules.Count(ppr => ppr.PropertyName.Equals(propertyParseRule.PropertyName, StringComparison.CurrentCultureIgnoreCase)) > 0) throw new InvalidOperationException(String.Format("PropertyParseRule for property name '{0}' has already been added to the global list", propertyParseRule.PropertyName)); _localPropertyParseRules.Add(propertyParseRule); }