示例#1
0
        public XmlCompareConstraint WithState(XmlComparisonState comparisonState, XmlComparisonType comparisonType)
        {
            var customAnalyzer = (XmlCustomAnalyzer)this.comparer.Analyzer;

            customAnalyzer.SetState(comparisonState, comparisonType);
            return(this);
        }
示例#2
0
        private static bool ResolveState(XmlComparisonState expectedState, XmlComparisonState actualState)
        {
            if (expectedState == XmlComparisonState.Similar)
            {
                return(actualState != XmlComparisonState.Different);
            }

            return(expectedState == actualState);
        }
示例#3
0
        public XmlDifference(XmlComparisonState state, XmlComparison difference)
        {
            if (difference == null)
            {
                throw new ArgumentNullException("difference");
            }

            this.state      = state;
            this.difference = difference;
        }
示例#4
0
        public bool SetState(XmlComparisonState newState)
        {
            this.state = newState;

            if ((int)this.finalState < (int)newState)
            {
                this.finalState = newState;
                return(true);
            }

            return(false);
        }
示例#5
0
        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);
        }
示例#6
0
        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));
        }
示例#9
0
 public XmlConstantAnalyzer(XmlComparisonState state)
 {
     this.state = state;
 }
示例#10
0
 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)
 {
 }