Hello All,
Newby to TypeMock Isolator. I'm working on a legacy app at our institution, fixing bugs and what not... :x
App is on MVC.NET, trying to poke as little as possible with the app, and having some issues trying to do some unit tests.
I'm basically trying to fake/Mock a Protected field, I found this on the typemock user guide/online documentation:
[url]
http://docs.typemock.com/isolator/Default.aspx##Ref.chm/Documentation/Fields.html[/url]
Tried following it but I am getting the following error message on the current production code I have.
System.IndexOutOfRangeException : Index was outside the bounds of the array.
For the sake of making things easy to replicate the error, I have reduced the code to the following:
[Test]
public void TestingSomething()
{
//Arrange
var mockBase = MockManager.Mock<MyBaseControllerClass>();
var mockedBaseField = mockBase.MockField("dataAccess");
mockedBaseField.ExpectAndReturn("getMeSomeData", new object());
var derivedController = new MyDerivedControllerClass(); //<------- This is where the unit test BLOWS UP !!
}
public class MyClassWithDataAccessFunctions
{
public object getMeSomeData() { return null; }
}
public class MyBaseControllerClass
{
protected MyClassWithDataAccessFunctions dataAccess =
new MyClassWithDataAccessFunctions();
}
public class MyDerivedControllerClass : MyBaseControllerClass
{
public void FunctionUsingDataAccess()
{
var data = dataAccess.getMeSomeData();
}
}
So any help would be appreciated, probably I'm doing things incorrectly or in a funky fashion
THANKS !!!
edo@rdo