[Fact(DisplayName="用户名为空")] public void Should_UsernameEmpty() { var paras = new Dictionary<string, string> { {"action","send"}, {"userid",userid}, {"account",""}, {"password",password}, {"mobile",mobile}, {"content",content}, {"sendtime",sendTime}, {"extno",extno} }; var rlt = HttpClientHelper.Instance.Post("sms.aspx", paras); Assert.False(string.IsNullOrEmpty(rlt)); var root = XElement.Parse(rlt).XPathSelectElement("/"); var msg = root.XPathSelectElement("message").Value; Assert.True(msg.Equals("用户名为空")); }
注意的是必须引用using System.Xml.Linq; using System.Xml.XPath;要不然是不能用的哦