Beispiel #1
0
        public override bool Equals(object obj)
        {
            XPathNodeMatchComparisonResult rhs = obj as XPathNodeMatchComparisonResult;

            if (rhs != null)
            {
                return((rhs.Result == Result) && (rhs.Message == Message));
            }
            return(false);
        }
		public void ResultEqualsReturnsTrueWhenXPathNodesAreSame()
		{
			XPathNodeMatch lhs = new XPathNodeMatch("nodeValue", "DisplayValue", 1, 2, XPathNodeType.Text);
			XPathNodeMatch rhs = new XPathNodeMatch("nodeValue", "DisplayValue", 1, 2, XPathNodeType.Text);
			XPathNodeMatchComparison comparison = new XPathNodeMatchComparison();
			
			XPathNodeMatchComparisonResult result = new XPathNodeMatchComparisonResult();
			result.Result = comparison.AreEqual(lhs, rhs);
			result.Message = comparison.GetReasonForNotMatching();
			
			XPathNodeMatchComparisonResult expectedResult = new XPathNodeMatchComparisonResult(true, String.Empty);
			Assert.AreEqual(expectedResult, result);
		}
		public void ResultEqualsReturnsFalseWhenXPathNodeLinePositionsAreDifferent()
		{
			XPathNodeMatch lhs = new XPathNodeMatch("nodeValue", "DisplayValue", 1, 2,  XPathNodeType.Text);
			XPathNodeMatch rhs = new XPathNodeMatch("nodeValue", "DisplayValue", 1, 3, XPathNodeType.Text);
			XPathNodeMatchComparison comparison = new XPathNodeMatchComparison();
			
			XPathNodeMatchComparisonResult result = new XPathNodeMatchComparisonResult();
			result.Result = comparison.AreEqual(lhs, rhs);
			result.Message = comparison.GetReasonForNotMatching();
			
			string expectedReason = "LinePositions do not match. Expected '2' but was '3'.";
			XPathNodeMatchComparisonResult expectedResult = new XPathNodeMatchComparisonResult(false, expectedReason);
			Assert.AreEqual(expectedResult, result);
		}
        public void ResultEqualsReturnsFalseWhenOneXPathNodeLineNumberIsNull()
        {
            int? lineNumber = null;
            XPathNodeMatch lhs = new XPathNodeMatch("nodeValue", "DisplayValue", lineNumber, 2,  XPathNodeType.Text);
            XPathNodeMatch rhs = new XPathNodeMatch("nodeValue", "DisplayValue", 0, 2, XPathNodeType.Text);
            XPathNodeMatchComparison comparison = new XPathNodeMatchComparison();

            XPathNodeMatchComparisonResult result = new XPathNodeMatchComparisonResult();
            result.Result = comparison.AreEqual(lhs, rhs);
            result.Message = comparison.GetReasonForNotMatching();

            string expectedReason = "LineNumbers do not match. Expected 'null' but was '0'.";
            XPathNodeMatchComparisonResult expectedResult = new XPathNodeMatchComparisonResult(false, expectedReason);
            Assert.AreEqual(expectedResult, result);
        }
		public void ComparisonResultEqualsReturnsFalseForNull()
		{
			XPathNodeMatchComparisonResult result = new XPathNodeMatchComparisonResult();
			Assert.IsFalse(result.Equals(null));
		}
		public void ComparisonResultToString()
		{
			XPathNodeMatchComparisonResult lhs = new XPathNodeMatchComparisonResult(true, "message");
			Assert.AreEqual("Result: True, Message: 'message'", lhs.ToString());
		}
		public void ComparisonResultsAreNotEqualWhenMessageIsDifferent()
		{
			XPathNodeMatchComparisonResult lhs = new XPathNodeMatchComparisonResult(false, "aaa");
			XPathNodeMatchComparisonResult rhs = new XPathNodeMatchComparisonResult(false, "bbb");
			Assert.AreNotEqual(lhs, rhs);
		}
		public void ComparisonResultsAreNotEqualWhenResultIsDifferent()
		{
			XPathNodeMatchComparisonResult lhs = new XPathNodeMatchComparisonResult(false, "abc");
			XPathNodeMatchComparisonResult rhs = new XPathNodeMatchComparisonResult(true, "abc");
			Assert.AreNotEqual(lhs, rhs);
		}
		public void ComparisonResultsAreEqualWhenResultAndMessageAreSame()
		{
			XPathNodeMatchComparisonResult lhs = new XPathNodeMatchComparisonResult(true, "abc");
			XPathNodeMatchComparisonResult rhs = new XPathNodeMatchComparisonResult(true, "abc");
			Assert.AreEqual(lhs, rhs);
		}