public XmlCompareConstraint WithState(XmlComparisonState comparisonState, XmlComparisonType comparisonType) { var customAnalyzer = (XmlCustomAnalyzer)this.comparer.Analyzer; customAnalyzer.SetState(comparisonState, comparisonType); return(this); }
private static bool ResolveState(XmlComparisonState expectedState, XmlComparisonState actualState) { if (expectedState == XmlComparisonState.Similar) { return(actualState != XmlComparisonState.Different); } return(expectedState == actualState); }
public XmlDifference(XmlComparisonState state, XmlComparison difference) { if (difference == null) { throw new ArgumentNullException("difference"); } this.state = state; this.difference = difference; }
public bool SetState(XmlComparisonState newState) { this.state = newState; if ((int)this.finalState < (int)newState) { this.finalState = newState; return(true); } return(false); }
public XmlCompareConstraint(XmlComparisonState expectedState, object expected) { if (expected == null) { throw new ArgumentNullException("expected"); } this.expectedNode = GetXNode(expected); this.expectedState = expectedState; this.comparer = new XmlComparer(); this.UseAnalizer(XmlGlobalsSettings.Analyzer) .UseHandler(XmlGlobalsSettings.CompareHandler) .UseMatcher(XmlGlobalsSettings.NodeMatcher) .UseFormatter(XmlGlobalsSettings.Formatter); }
private static void AssertComparison(XmlComparisonResult comparison, XmlComparisonState expectedState, XmlComparisonType[] expectedTypes = null) { Assert.IsNotNull(comparison); Assert.AreEqual(expectedState, comparison.State); if (expectedTypes != null) { var actualItems = comparison.Differences.ToArray(); Assert.AreEqual(expectedTypes.Length, actualItems.Length); for (var i = 0; i < expectedTypes.Length; i++) { Assert.AreEqual(expectedTypes[i], actualItems[i].Difference.ComparisonType); } } }
public XmlCustomAnalyzer SetState(XmlComparisonState state, XmlComparisonType comparisonType, Predicate <XmlComparison> condition = null) { for (var i = 0; i < this.infos.Count; i++) { if (this.infos[i].State == state && this.infos[i].ComparisonType == comparisonType) { this.infos[i].Condition = condition; return(this); } } this.infos.Add(new XmlAnalyzeInfo { State = state, ComparisonType = comparisonType, Condition = condition }); return(this); }
public XmlCustomAnalyzer SetDefault(XmlComparisonState comparisonState) { var analyzer = XmlAnalyzer.Constant(comparisonState); return(this.SetDefault(analyzer)); }
public XmlConstantAnalyzer(XmlComparisonState state) { this.state = state; }
public static IXmlAnalyzer Constant(XmlComparisonState comparisonState) { return(new XmlConstantAnalyzer(comparisonState)); }
public static XmlCompareHandler Limit(XmlComparisonState state, int count) { return(x => x.Differences.Count(item => item.State == state) >= count); }
public static XmlCompareHandler StopWhen(XmlComparisonState state) { return(x => (int)x.State >= (int)state); }
public XmlComparisonResult(XmlComparisonState state, IEnumerable <XmlDifference> differences) { this.state = state; this.differences = new List <XmlDifference>(differences); }
public XmlComparisonResult(XmlComparisonState result) : this(result, null) { }