Fake private field

09/10/2012 16:41

//in code

private SPListItem configListItem;

 

//setting value of private field, target is class where is configListItem

var fakeItem = Isolate.Fake.Instance<SPListItem>();

ObjectState.SetField(target, "configListItem", fakeItem);

 

Button btnRegister = (Button)ObjectState.GetField(target, "btnRegister");

Assert.AreEqual(true, btnRegister.Visible);