/// <summary> /// Verifies that the specified XPath (or more) return at least one result. /// </summary> /// <param name="navigable">Document to look in.</param> /// <param name="xpaths">The xpaths to verify.</param> public static void VerifyXPathExists(AssertionHandler assert, IXPathNavigable navigable, params string[] xpaths) { foreach (string xpath in xpaths) { int count = navigable.CreateNavigator().Select(xpath, NamespaceManager).Count; if (count == 0) { Trace.WriteLine(navigable.CreateNavigator().OuterXml); assert.Fail("Failed to find specified xpath in the document: " + xpath); } } }
/// <summary> /// Calls constructor and verifies expected exception. /// </summary> /// <param name="type">The type to construct.</param> /// <param name="errorMessage">The expected error message.</param> /// <param name="parameters">The parameters for the constructor.</param> public static void CheckInvalidConstructorParameters(AssertionHandler assert, Type type, string errorMessage, params object[] parameters) { try { ConstructorInfo c = type.GetConstructors(BindingFlags.Public | BindingFlags.Instance).Single(); c.Invoke(parameters); assert.Fail(errorMessage); } catch (TargetInvocationException e) { assert.IsTrue(e.InnerException is ArgumentException, "Expecting argument exception"); assert.IsTrue(e.InnerException.Message.Contains(errorMessage), "The exception message doesn't contain the expected string '" + errorMessage + "'."); } }
private static void VerifySyntaxTreesAreEqualImpl(SyntacticTree expected, SyntacticTree actual, AssertionHandler assert) { VerifyStringsAreEqual(expected.Path, actual.Path, assert); VerifyQueryTokensAreEqual(expected.Filter, actual.Filter, assert); if (expected.OrderByTokens != null && actual.OrderByTokens != null) { VerifyQueryTokensAreEqual(expected.OrderByTokens.Cast <QueryToken>(), actual.OrderByTokens.Cast <QueryToken>(), assert); } else if ((expected.OrderByTokens != null && actual.OrderByTokens == null) || (expected.OrderByTokens == null && actual.OrderByTokens != null)) { assert.Fail("Query tokens are different"); } assert.AreEqual(expected.Skip, actual.Skip, "Skip values are different."); VerificationUtils.VerifyEnumerationsAreEqual( expected.QueryOptions, actual.QueryOptions, VerifyCustomQueryOptionQueryTokensAreEqual, (item) => item.ToDebugString(), assert); }
/// <summary> /// Verifies that two query tokens are equal. /// </summary> /// <param name="expected">The expected query token.</param> /// <param name="actual">The actual query token.</param> /// <param name="assert">Assertion handler to use.</param> internal static void VerifyQueryTokensAreEqual(QueryToken expected, QueryToken actual, AssertionHandler assert) { try { if (!VerifyNullnessMatches(expected, actual, assert, "token")) { return; } assert.AreEqual(expected.Kind, actual.Kind, "The token kinds are different."); switch (expected.Kind) { case QueryTokenKind.Literal: VerifyLiteralQueryTokensAreEqual((LiteralToken)expected, (LiteralToken)actual, assert); break; case QueryTokenKind.BinaryOperator: VerifyBinaryOperatorQueryTokensAreEqual((BinaryOperatorToken)expected, (BinaryOperatorToken)actual, assert); break; case QueryTokenKind.UnaryOperator: VerifyUnaryOperatorQueryTokensAreEqual((UnaryOperatorToken)expected, (UnaryOperatorToken)actual, assert); break; case QueryTokenKind.EndPath: VerifyPropertyAccessQueryTokensAreEqual((EndPathToken)expected, (EndPathToken)actual, assert); break; case QueryTokenKind.InnerPath: VerifyNonRootSegmentQueryTokensAreEqual((InnerPathToken)expected, (InnerPathToken)actual, assert); break; case QueryTokenKind.FunctionCall: VerifyFunctionCallQueryTokensAreEqual((FunctionCallToken)expected, (FunctionCallToken)actual, assert); break; case QueryTokenKind.CustomQueryOption: VerifyCustomQueryOptionQueryTokensAreEqual((CustomQueryOptionToken)expected, (CustomQueryOptionToken)actual, assert); break; case QueryTokenKind.OrderBy: VerifyOrderByQueryTokensAreEqual((OrderByToken)expected, (OrderByToken)actual, assert); break; case QueryTokenKind.Select: VerifySelectQueryTokensAreEqual((SelectToken)expected, (SelectToken)actual, assert); break; case QueryTokenKind.Star: VerifyStarQueryTokensAreEqual((StarToken)expected, (StarToken)actual, assert); break; case QueryTokenKind.FunctionParameter: VerifyFunctionParameterTokensAreEqual((FunctionParameterToken)expected, (FunctionParameterToken)actual, assert); break; default: assert.Fail("The token kind '" + expected.Kind.ToString() + "' is not a lexical node."); break; } } catch (Exception) { assert.Warn("Expected query token: " + expected.ToDebugString()); assert.Warn("Actual query token: " + actual.ToDebugString()); throw; } }
private static void VerifySyntaxTreesAreEqualImpl(SyntacticTree expected, SyntacticTree actual, AssertionHandler assert) { VerifyStringsAreEqual(expected.Path, actual.Path, assert); VerifyQueryTokensAreEqual(expected.Filter, actual.Filter, assert); if (expected.OrderByTokens != null && actual.OrderByTokens != null) VerifyQueryTokensAreEqual(expected.OrderByTokens.Cast<QueryToken>(), actual.OrderByTokens.Cast<QueryToken>(), assert); else if ((expected.OrderByTokens != null && actual.OrderByTokens == null) || (expected.OrderByTokens == null && actual.OrderByTokens != null)) assert.Fail("Query tokens are different"); assert.AreEqual(expected.Skip, actual.Skip, "Skip values are different."); VerificationUtils.VerifyEnumerationsAreEqual( expected.QueryOptions, actual.QueryOptions, VerifyCustomQueryOptionQueryTokensAreEqual, (item) => item.ToDebugString(), assert); }
/// <summary> /// Verifies that two query tokens are equal. /// </summary> /// <param name="expected">The expected query token.</param> /// <param name="actual">The actual query token.</param> /// <param name="assert">Assertion handler to use.</param> internal static void VerifyQueryTokensAreEqual(QueryToken expected, QueryToken actual, AssertionHandler assert) { try { if(!VerifyNullnessMatches(expected, actual, assert, "token")) return; assert.AreEqual(expected.Kind, actual.Kind, "The token kinds are different."); switch (expected.Kind) { case QueryTokenKind.Literal: VerifyLiteralQueryTokensAreEqual((LiteralToken)expected, (LiteralToken)actual, assert); break; case QueryTokenKind.BinaryOperator: VerifyBinaryOperatorQueryTokensAreEqual((BinaryOperatorToken)expected, (BinaryOperatorToken)actual, assert); break; case QueryTokenKind.UnaryOperator: VerifyUnaryOperatorQueryTokensAreEqual((UnaryOperatorToken)expected, (UnaryOperatorToken)actual, assert); break; case QueryTokenKind.EndPath: VerifyPropertyAccessQueryTokensAreEqual((EndPathToken)expected, (EndPathToken)actual, assert); break; case QueryTokenKind.InnerPath: VerifyNonRootSegmentQueryTokensAreEqual((InnerPathToken) expected,(InnerPathToken) actual, assert); break; case QueryTokenKind.FunctionCall: VerifyFunctionCallQueryTokensAreEqual((FunctionCallToken)expected, (FunctionCallToken)actual, assert); break; case QueryTokenKind.CustomQueryOption: VerifyCustomQueryOptionQueryTokensAreEqual((CustomQueryOptionToken)expected, (CustomQueryOptionToken)actual, assert); break; case QueryTokenKind.OrderBy: VerifyOrderByQueryTokensAreEqual((OrderByToken)expected, (OrderByToken)actual, assert); break; case QueryTokenKind.Select: VerifySelectQueryTokensAreEqual((SelectToken)expected, (SelectToken)actual, assert); break; case QueryTokenKind.Star: VerifyStarQueryTokensAreEqual((StarToken)expected, (StarToken)actual, assert); break; case QueryTokenKind.FunctionParameter: VerifyFunctionParameterTokensAreEqual((FunctionParameterToken)expected, (FunctionParameterToken)actual, assert); break; default: assert.Fail("The token kind '" + expected.Kind.ToString() + "' is not a lexical node."); break; } } catch (Exception) { assert.Warn("Expected query token: " + expected.ToDebugString()); assert.Warn("Actual query token: " + actual.ToDebugString()); throw; } }
private static void ComparePrimitiveValue(IEdmValue edmValue, object odataValue, AssertionHandler assert) { TypeCode typeCode = Type.GetTypeCode(odataValue.GetType()); switch (typeCode) { case TypeCode.Boolean: assert.AreEqual(EdmValueKind.Boolean, edmValue.ValueKind, "Value kinds differ."); assert.AreEqual(odataValue, ((IEdmBooleanValue)edmValue).Value, "Values differ."); if (edmValue.Type != null) { assert.AreEqual(EdmTypeKind.Primitive, edmValue.Type.Definition.TypeKind, "EDM type kinds differ."); assert.AreEqual(EdmPrimitiveTypeKind.Boolean, edmValue.Type.PrimitiveKind(), "EDM primitive kinds differ."); } return; case TypeCode.Byte: assert.AreEqual(EdmValueKind.Integer, edmValue.ValueKind, "Value kinds differ."); assert.AreEqual(odataValue, (byte)((IEdmIntegerValue)edmValue).Value, "Values differ."); if (edmValue.Type != null) { assert.AreEqual(EdmTypeKind.Primitive, edmValue.Type.Definition.TypeKind, "EDM type kinds differ."); assert.AreEqual(EdmPrimitiveTypeKind.Byte, edmValue.Type.PrimitiveKind(), "EDM primitive kinds differ."); } return; case TypeCode.SByte: assert.AreEqual(EdmValueKind.Integer, edmValue.ValueKind, "Value kinds differ."); assert.AreEqual(odataValue, (sbyte)((IEdmIntegerValue)edmValue).Value, "Values differ."); if (edmValue.Type != null) { assert.AreEqual(EdmTypeKind.Primitive, edmValue.Type.Definition.TypeKind, "EDM type kinds differ."); assert.AreEqual(EdmPrimitiveTypeKind.SByte, edmValue.Type.PrimitiveKind(), "EDM primitive kinds differ."); } return; case TypeCode.Int16: assert.AreEqual(EdmValueKind.Integer, edmValue.ValueKind, "Value kinds differ."); assert.AreEqual(odataValue, (Int16)((IEdmIntegerValue)edmValue).Value, "Values differ."); if (edmValue.Type != null) { assert.AreEqual(EdmTypeKind.Primitive, edmValue.Type.Definition.TypeKind, "EDM type kinds differ."); assert.AreEqual(EdmPrimitiveTypeKind.Int16, edmValue.Type.PrimitiveKind(), "EDM primitive kinds differ."); } return; case TypeCode.Int32: assert.AreEqual(EdmValueKind.Integer, edmValue.ValueKind, "Value kinds differ."); assert.AreEqual(odataValue, (Int32)((IEdmIntegerValue)edmValue).Value, "Values differ."); if (edmValue.Type != null) { assert.AreEqual(EdmTypeKind.Primitive, edmValue.Type.Definition.TypeKind, "EDM type kinds differ."); assert.AreEqual(EdmPrimitiveTypeKind.Int32, edmValue.Type.PrimitiveKind(), "EDM primitive kinds differ."); } return; case TypeCode.Int64: assert.AreEqual(EdmValueKind.Integer, edmValue.ValueKind, "Value kinds differ."); assert.AreEqual(odataValue, (Int64)((IEdmIntegerValue)edmValue).Value, "Values differ."); if (edmValue.Type != null) { assert.AreEqual(EdmTypeKind.Primitive, edmValue.Type.Definition.TypeKind, "EDM type kinds differ."); assert.AreEqual(EdmPrimitiveTypeKind.Int64, edmValue.Type.PrimitiveKind(), "EDM primitive kinds differ."); } return; case TypeCode.Decimal: assert.AreEqual(EdmValueKind.Decimal, edmValue.ValueKind, "Value kinds differ."); assert.AreEqual(odataValue, ((IEdmDecimalValue)edmValue).Value, "Values differ."); if (edmValue.Type != null) { assert.AreEqual(EdmTypeKind.Primitive, edmValue.Type.Definition.TypeKind, "EDM type kinds differ."); assert.AreEqual(EdmPrimitiveTypeKind.Decimal, edmValue.Type.PrimitiveKind(), "EDM primitive kinds differ."); } return; case TypeCode.Single: assert.AreEqual(EdmValueKind.Floating, edmValue.ValueKind, "Value kinds differ."); assert.AreEqual(odataValue, (Single)((IEdmFloatingValue)edmValue).Value, "Values differ."); if (edmValue.Type != null) { assert.AreEqual(EdmTypeKind.Primitive, edmValue.Type.Definition.TypeKind, "EDM type kinds differ."); assert.AreEqual(EdmPrimitiveTypeKind.Single, edmValue.Type.PrimitiveKind(), "EDM primitive kinds differ."); } return; case TypeCode.Double: assert.AreEqual(EdmValueKind.Floating, edmValue.ValueKind, "Value kinds differ."); assert.AreEqual(odataValue, ((IEdmFloatingValue)edmValue).Value, "Values differ."); if (edmValue.Type != null) { assert.AreEqual(EdmTypeKind.Primitive, edmValue.Type.Definition.TypeKind, "EDM type kinds differ."); assert.AreEqual(EdmPrimitiveTypeKind.Double, edmValue.Type.PrimitiveKind(), "EDM primitive kinds differ."); } return; case TypeCode.String: assert.AreEqual(EdmValueKind.String, edmValue.ValueKind, "Value kinds differ."); assert.AreEqual(odataValue, ((IEdmStringValue)edmValue).Value, "Values differ."); if (edmValue.Type != null) { assert.AreEqual(EdmTypeKind.Primitive, edmValue.Type.Definition.TypeKind, "EDM type kinds differ."); assert.AreEqual(EdmPrimitiveTypeKind.String, edmValue.Type.PrimitiveKind(), "EDM primitive kinds differ."); } return; default: byte[] bytes = odataValue as byte[]; if (bytes != null) { assert.AreEqual(EdmValueKind.Binary, edmValue.ValueKind, "Value kinds differ."); assert.AreEqual(odataValue, ((IEdmBinaryValue)edmValue).Value, "Values differ."); if (edmValue.Type != null) { assert.AreEqual(EdmTypeKind.Primitive, edmValue.Type.Definition.TypeKind, "EDM type kinds differ."); assert.AreEqual(EdmPrimitiveTypeKind.Binary, edmValue.Type.PrimitiveKind(), "EDM primitive kinds differ."); } return; } if (odataValue is DateTimeOffset) { assert.AreEqual(EdmValueKind.DateTimeOffset, edmValue.ValueKind, "Value kinds differ."); assert.AreEqual(odataValue, ((IEdmDateTimeOffsetValue)edmValue).Value, "Values differ."); if (edmValue.Type != null) { assert.AreEqual(EdmTypeKind.Primitive, edmValue.Type.Definition.TypeKind, "EDM type kinds differ."); assert.AreEqual(EdmPrimitiveTypeKind.DateTimeOffset, edmValue.Type.PrimitiveKind(), "EDM primitive kinds differ."); } return; } if (odataValue is Guid) { assert.AreEqual(EdmValueKind.Guid, edmValue.ValueKind, "Value kinds differ."); assert.AreEqual(odataValue, ((IEdmGuidValue)edmValue).Value, "Values differ."); if (edmValue.Type != null) { assert.AreEqual(EdmTypeKind.Primitive, edmValue.Type.Definition.TypeKind, "EDM type kinds differ."); assert.AreEqual(EdmPrimitiveTypeKind.Guid, edmValue.Type.PrimitiveKind(), "EDM primitive kinds differ."); } return; } if (odataValue is TimeSpan) { assert.AreEqual(EdmValueKind.Duration, edmValue.ValueKind, "Value kinds differ."); assert.AreEqual(odataValue, ((IEdmDurationValue)edmValue).Value, "Values differ."); if (edmValue.Type != null) { assert.AreEqual(EdmTypeKind.Primitive, edmValue.Type.Definition.TypeKind, "EDM type kinds differ."); assert.AreEqual(EdmPrimitiveTypeKind.Duration, edmValue.Type.PrimitiveKind(), "EDM primitive kinds differ."); } return; } if (odataValue is ISpatial) { // TODO: [JsonLight] Add support for spatial values in ODataEdmStructuredValue throw new System.NotSupportedException(); } assert.Fail("Unsupported primitive type: " + odataValue.GetType().FullName); return; } }
private static void ComparePrimitiveValue(IEdmValue edmValue, object odataValue, AssertionHandler assert) { TypeCode typeCode = Type.GetTypeCode(odataValue.GetType()); switch (typeCode) { case TypeCode.Boolean: assert.AreEqual(EdmValueKind.Boolean, edmValue.ValueKind, "Value kinds differ."); assert.AreEqual(odataValue, ((IEdmBooleanValue)edmValue).Value, "Values differ."); if (edmValue.Type != null) { assert.AreEqual(EdmTypeKind.Primitive, edmValue.Type.Definition.TypeKind, "EDM type kinds differ."); assert.AreEqual(EdmPrimitiveTypeKind.Boolean, edmValue.Type.PrimitiveKind(), "EDM primitive kinds differ."); } return; case TypeCode.Byte: assert.AreEqual(EdmValueKind.Integer, edmValue.ValueKind, "Value kinds differ."); assert.AreEqual(odataValue, (byte)((IEdmIntegerValue)edmValue).Value, "Values differ."); if (edmValue.Type != null) { assert.AreEqual(EdmTypeKind.Primitive, edmValue.Type.Definition.TypeKind, "EDM type kinds differ."); assert.AreEqual(EdmPrimitiveTypeKind.Byte, edmValue.Type.PrimitiveKind(), "EDM primitive kinds differ."); } return; case TypeCode.SByte: assert.AreEqual(EdmValueKind.Integer, edmValue.ValueKind, "Value kinds differ."); assert.AreEqual(odataValue, (sbyte)((IEdmIntegerValue)edmValue).Value, "Values differ."); if (edmValue.Type != null) { assert.AreEqual(EdmTypeKind.Primitive, edmValue.Type.Definition.TypeKind, "EDM type kinds differ."); assert.AreEqual(EdmPrimitiveTypeKind.SByte, edmValue.Type.PrimitiveKind(), "EDM primitive kinds differ."); } return; case TypeCode.Int16: assert.AreEqual(EdmValueKind.Integer, edmValue.ValueKind, "Value kinds differ."); assert.AreEqual(odataValue, (Int16)((IEdmIntegerValue)edmValue).Value, "Values differ."); if (edmValue.Type != null) { assert.AreEqual(EdmTypeKind.Primitive, edmValue.Type.Definition.TypeKind, "EDM type kinds differ."); assert.AreEqual(EdmPrimitiveTypeKind.Int16, edmValue.Type.PrimitiveKind(), "EDM primitive kinds differ."); } return; case TypeCode.Int32: assert.AreEqual(EdmValueKind.Integer, edmValue.ValueKind, "Value kinds differ."); assert.AreEqual(odataValue, (Int32)((IEdmIntegerValue)edmValue).Value, "Values differ."); if (edmValue.Type != null) { assert.AreEqual(EdmTypeKind.Primitive, edmValue.Type.Definition.TypeKind, "EDM type kinds differ."); assert.AreEqual(EdmPrimitiveTypeKind.Int32, edmValue.Type.PrimitiveKind(), "EDM primitive kinds differ."); } return; case TypeCode.Int64: assert.AreEqual(EdmValueKind.Integer, edmValue.ValueKind, "Value kinds differ."); assert.AreEqual(odataValue, (Int64)((IEdmIntegerValue)edmValue).Value, "Values differ."); if (edmValue.Type != null) { assert.AreEqual(EdmTypeKind.Primitive, edmValue.Type.Definition.TypeKind, "EDM type kinds differ."); assert.AreEqual(EdmPrimitiveTypeKind.Int64, edmValue.Type.PrimitiveKind(), "EDM primitive kinds differ."); } return; case TypeCode.Decimal: assert.AreEqual(EdmValueKind.Decimal, edmValue.ValueKind, "Value kinds differ."); assert.AreEqual(odataValue, ((IEdmDecimalValue)edmValue).Value, "Values differ."); if (edmValue.Type != null) { assert.AreEqual(EdmTypeKind.Primitive, edmValue.Type.Definition.TypeKind, "EDM type kinds differ."); assert.AreEqual(EdmPrimitiveTypeKind.Decimal, edmValue.Type.PrimitiveKind(), "EDM primitive kinds differ."); } return; case TypeCode.Single: assert.AreEqual(EdmValueKind.Floating, edmValue.ValueKind, "Value kinds differ."); assert.AreEqual(odataValue, (Single)((IEdmFloatingValue)edmValue).Value, "Values differ."); if (edmValue.Type != null) { assert.AreEqual(EdmTypeKind.Primitive, edmValue.Type.Definition.TypeKind, "EDM type kinds differ."); assert.AreEqual(EdmPrimitiveTypeKind.Single, edmValue.Type.PrimitiveKind(), "EDM primitive kinds differ."); } return; case TypeCode.Double: assert.AreEqual(EdmValueKind.Floating, edmValue.ValueKind, "Value kinds differ."); assert.AreEqual(odataValue, ((IEdmFloatingValue)edmValue).Value, "Values differ."); if (edmValue.Type != null) { assert.AreEqual(EdmTypeKind.Primitive, edmValue.Type.Definition.TypeKind, "EDM type kinds differ."); assert.AreEqual(EdmPrimitiveTypeKind.Double, edmValue.Type.PrimitiveKind(), "EDM primitive kinds differ."); } return; case TypeCode.String: assert.AreEqual(EdmValueKind.String, edmValue.ValueKind, "Value kinds differ."); assert.AreEqual(odataValue, ((IEdmStringValue)edmValue).Value, "Values differ."); if (edmValue.Type != null) { assert.AreEqual(EdmTypeKind.Primitive, edmValue.Type.Definition.TypeKind, "EDM type kinds differ."); assert.AreEqual(EdmPrimitiveTypeKind.String, edmValue.Type.PrimitiveKind(), "EDM primitive kinds differ."); } return; default: byte[] bytes = odataValue as byte[]; if (bytes != null) { assert.AreEqual(EdmValueKind.Binary, edmValue.ValueKind, "Value kinds differ."); assert.AreEqual(odataValue, ((IEdmBinaryValue)edmValue).Value, "Values differ."); if (edmValue.Type != null) { assert.AreEqual(EdmTypeKind.Primitive, edmValue.Type.Definition.TypeKind, "EDM type kinds differ."); assert.AreEqual(EdmPrimitiveTypeKind.Binary, edmValue.Type.PrimitiveKind(), "EDM primitive kinds differ."); } return; } if (odataValue is DateTimeOffset) { assert.AreEqual(EdmValueKind.DateTimeOffset, edmValue.ValueKind, "Value kinds differ."); assert.AreEqual(odataValue, ((IEdmDateTimeOffsetValue)edmValue).Value, "Values differ."); if (edmValue.Type != null) { assert.AreEqual(EdmTypeKind.Primitive, edmValue.Type.Definition.TypeKind, "EDM type kinds differ."); assert.AreEqual(EdmPrimitiveTypeKind.DateTimeOffset, edmValue.Type.PrimitiveKind(), "EDM primitive kinds differ."); } return; } if (odataValue is Guid) { assert.AreEqual(EdmValueKind.Guid, edmValue.ValueKind, "Value kinds differ."); assert.AreEqual(odataValue, ((IEdmGuidValue)edmValue).Value, "Values differ."); if (edmValue.Type != null) { assert.AreEqual(EdmTypeKind.Primitive, edmValue.Type.Definition.TypeKind, "EDM type kinds differ."); assert.AreEqual(EdmPrimitiveTypeKind.Guid, edmValue.Type.PrimitiveKind(), "EDM primitive kinds differ."); } return; } if (odataValue is TimeSpan) { assert.AreEqual(EdmValueKind.Duration, edmValue.ValueKind, "Value kinds differ."); assert.AreEqual(odataValue, ((IEdmDurationValue)edmValue).Value, "Values differ."); if (edmValue.Type != null) { assert.AreEqual(EdmTypeKind.Primitive, edmValue.Type.Definition.TypeKind, "EDM type kinds differ."); assert.AreEqual(EdmPrimitiveTypeKind.Duration, edmValue.Type.PrimitiveKind(), "EDM primitive kinds differ."); } return; } if (odataValue is ISpatial) { // TODO: [JsonLight] Add support for spatial values in ODataEdmStructuredValue throw new System.NotSupportedException(); } assert.Fail("Unsupported primitive type: " + odataValue.GetType().FullName); return; } }
/// <summary> /// Verifies that the specified XPath (or more) return at least one result. /// </summary> /// <param name="navigable">Document to look in.</param> /// <param name="xpaths">The xpaths to verify.</param> public static void VerifyXPathExists(AssertionHandler assert, IXPathNavigable navigable, params string[] xpaths) { foreach (string xpath in xpaths) { int count = navigable.CreateNavigator().Select(xpath, NamespaceManager).Count; if (count == 0) { Trace.WriteLine(navigable.CreateNavigator().OuterXml); assert.Fail("Failed to find specified xpath in the document: " + xpath); } } }