May i know is there any way to expect a variable that throw null reference exception? for an example,
public class class1
{
public struct structVariable
{
public int a;
public string b;
}
public int a;
public structVariable[] structArray;
public class1(){}
public void assignValue()
{
a = 5;
structArray = new structVariable[1];
structArray[0].a = 1;
structArray[0].b = "test";
}
public void doSomething(){}
}
public class class2
{
private class1 c1;
private int a;
private string b;
public class2
{
c1 = new class1();
}
public void doSomething()
{
a = c1.a;
by = c1.structArray[a].b;
c1.doSomething();
}
}
testing, used to test doSomething() under class2
[Test]
public void test()
{
MockManager.Init();
Mock mockClass1 = MockManager.Mock(typeof(class1));
class2 c2 = new class2();
mockClass1.ExpectCall("doSomething");
c2.doSomething();
MockManager.Verify();
}
Error
System.NullReferenceException : Object reference not set to an instance of an object.
[/u]