Reputation: 16029
I'm using Rhino Mock for my unit testing in my webapp using ASP.NET MVC and C#. I'm have a problem creating stubs in one of my method in the service interface. That method is returning a class. Please kindly see below the code,
The class of the Model Acct
public class Acct
{
public string Name { get; set; }
public static Acct GetAcct( string user )
{
...
}
}
Interface for Account
public interface IAccount
{
Acct GetAcct( string user );
}
Account service that will access the method from the model class above,
public class Account : IAccount
{
public Acct GetAcct( string user )
{
retrun Acct.GetAcct( user );
}
}
Then I can't access the GetAcct method of Account service class when I want to create a stub.
Please advise.
Many thanks.
Upvotes: 0
Views: 158
Reputation: 14677
The GetAcct method on Account must be virtual if you want a mocking framework (like Rhino.Mocks, moq, etc...) to be able to mock it.
Upvotes: 1