Rhythm.Staticize.ValidationProjection.TitleEquals C# (CSharp) Method

TitleEquals() public static method

验证 HTML 网页标题是否等于预期的标题。
public static TitleEquals ( String excepted, String errorMessage = null ) : IValidation
excepted String 预期的标题
errorMessage String
return IValidation
        public static IValidation TitleEquals(String excepted, String errorMessage = null)
        {
            return new ValidationDelegateTaken("网页标题", ValidationType.Content, (doc) =>
            {
                var htmlNode = doc.DocumentNode;
                var titleNode = htmlNode.SelectSingleNode(@"html/head/title");
                if (titleNode == null)
                {
                    return false;
                }
                return excepted == titleNode.InnerHtml;
            }, errorMessage ?? string.Format("预期的标题 \"{0}\"。", excepted));
        }