我目前正在为类方法编写单元测试,但访问器总是抛出异常。
考虑以下测试方法:
namespace GSVMTestCase
{
[TestClass]
public class GatewaySettingsViewModelTest
{
[TestMethod]
[DeploymentItem("SmartGatewayUABL.dll")]
public void AddGatewayTest1()
{
GatewaySettingsViewModel_Accessor target = new GatewaySettingsViewModel_Accessor(); // error occurs here
target.GatewayIPAddress = null;
target.AddGateway();
Assert.AreEqual(TextStrings.TxtErrInvalidIP, target.ErrorMessage);
}}}
}
总是抛出异常:
你调用的对象是空的