【发布时间】:2011-09-22 05:59:04
【问题描述】:
为什么这种测试方法不起作用?我不断收到需要返回值或抛出异常。
public AuthenticateResponse Authenticate(string username, string password)
{
string response = GetResponse(GetUrl(username, password).ToString());
return ParseResponse(response);
}
[TestMethod()]
[ExpectedException(typeof(XmlException))]
public void Authenticate_BadXml_ReturnException()
{
MockRepository mockRepository = new MockRepository();
SSO sso = mockRepository.Stub<SSO>();
sso.Stub(t => t.GetResponse("")).Return("<test>d");
AuthenticateResponse response = sso.Authenticate("test", "test");
}
【问题讨论】:
-
GetResponse方法是虚拟的吗?
标签: c# unit-testing rhino-mocks stub