I am looking to write some unit tests for my c# class. I have a base class called BaseClass that has an abstract method called Execute and also a method called Redirect. I have a class called Class1 which inherits BaseClass and implements the abstracted Execute method, the method I want to test. The following code explains the set up further:
public abstract class BaseClass
{
public abstract void Execute();
public void Redirect()
{
// redirect code here
}
}
public class Class1 : BaseClass
{
public void Execute()
{
// do some processing
this.Redirect();
}
}
I am working with mstest and using rhino mocks for my mocking. I want to write tests for the Execute method to test it works as I expect.
As you can see from above, the Execute method makes a call to the base method Redirect, so I have an expectation that the Redirect method is called.
I use the Rhino mocks mockrepository to create a Partial Mock of Class1. The created mock contains the Execute method which is great, but does not contain a reference to the Redirect method, which is in Class1. I want to be able to set an expectation on the mocked repository that the Redirect method is called.
Any tips or advice as how I might be able to create a test with rhino mocks to achieve what I have outlined?