Hi All, 

 I Try to stub a Business Layer methods with Rhino Mock and have a very 
strange result : 

 
/// <summary>
/// This method return a complete list of all TemplateProjects
/// </summary>
/// <param name="callContext"></param>
/// <returns></returns>
public IEnumerable<TemplateProjectDto> GetTemplateProjects(CallContext 
callContext)
{
 var templateProjects = _templateRepository.GetTemplateProjects();
 
 var templateProjectWorkOrders = 
_templateRepository.GetTemplateProjectWorkOrders();
 
 var templateProjectQuestions = 
_templateRepository.GetTemplateProjectQuestions().OrderBy(x => x.OrderBy);
 
 var templateQuestions = _templateRepository.GetTemplateQuestions();
....
///
I Just try to get some data from the repository (very simple)
Here is my Test : 
[TestMethod]
public void GetAllTemplateProject()
{

 ITemplateRepository _templateRepositoryStub = 
MockRepository.GenerateStub<ITemplateRepository>();
 
 _templateRepositoryStub.Stub(repo => repo.GetTemplateProjects())
  .IgnoreArguments()
  .Return(TemplateProjectMock.GetList());

 _templateRepositoryStub.Stub(repo => repo.GetTemplateWorkOrders())
  .IgnoreArguments()
  .Repeat
  .Any()
  .Return(TemplateWorkOrderMock.GetList());

 _templateRepositoryStub.Stub(repo => repo.GetTemplateWorkOrderLinks())
  .IgnoreArguments()
  .Repeat
  .Any()
  .Return(TemplateWorkOrderLinkMock.GetList());

 _templateRepositoryStub.Stub(repo => repo.GetTemplateProjectQuestions())
  .IgnoreArguments()
  .Repeat
  .Any()
  .Return(TemplateProjectQuestionMock.GetList());

 var result = _templateBl.GetTemplateProjects(_callContext)
  .OrderBy(x=>x.Id)
  .ToList();

 Assert.IsNotNull(result);
...
//////
Very simple too .. I stub all calls to repository to force RM to return 
result of static methodes (GetList()) to me. 
When I debug the code, I see the following message on execution of the 
_templateRepository.GetTemplateProjectQuestions() methods (the 3th line)

It is strange because, I try to execute the GetTemplateProjectQuestions 
method of my Business layer, and the exception of RM is based on the 
previous method!

An exception of type 'System.InvalidOperationException' occurred in 
Rhino.Mocks.dll but was not handled in user code
Additional information: Previous method 
'ITemplateRepository.GetTemplateProjectWorkOrders(null);' requires a return 
value or an exception to throw.

Other very strange thing : The GetList() method was tested at least 10 
times and return the expected result! And If I switch 2 calls into the BL 
methods, that does not change anything. 
Someone see what I did wrong? 

 Regards, 
 
  f. 

-- 
You received this message because you are subscribed to the Google Groups 
"Rhino.Mocks" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To post to this group, send email to [email protected].
Visit this group at http://groups.google.com/group/rhinomocks.
For more options, visit https://groups.google.com/d/optout.

Reply via email to