0
以下this教程和遇到麻烦。Windows Phone测试失败
[TestMethod]
[ExpectedException(typeof(Exception))]
public void VerifyPropertyNameMethod_NonExistentPropertyString_ThrowsException()
{
var customer = new Customer() { FirstName = "June", LastName = "Smith" };
var sut = new CustomerViewModel(_customerRepository, customer);
sut.VerifyPropertyName("NonExistentPropertyName");
}
测试失败,显示以下消息。测试显然引发了一个异常,但它应该是!为什么测试失败?
VerifyPropertyNameMethod_NonExistentPropertyString_ThrowsException : FailedTest method FirstOnSiteWindowsPhoneApp.AppCode.Tests.Unit.CustomerViewModelTests.VerifyPropertyNameMethod_NonExistentPropertyString_ThrowsException threw exception:
FirstOnSiteWindowsPhoneApp.AppCode.Domain.VerifyPropertyNameException: Exception of type 'FirstOnSiteWindowsPhoneApp.AppCode.Domain.VerifyPropertyNameException' was thrown.
at FirstOnSiteWindowsPhoneApp.AppCode.ViewModel.CustomerViewModel.VerifyPropertyName(String propertyName) in CustomerViewModel.cs: line 29
at FirstOnSiteWindowsPhoneApp.AppCode.Tests.Unit.CustomerViewModelTests.VerifyPropertyNameMethod_NonExistentPropertyString_ThrowsException() in CustomerViewModelTests.cs: line 53
通过外观的东西值NonconistantPropertyName被标记为无效和抛出的异常。你能澄清一下你的问题吗?或许可以详细说明你在哪里挣扎? – anothershrubery 2012-03-27 11:47:58