-- UPDATE See text in red below --
Ok, I am in NO way trying to say that this is either Rhino's issue or MSTest. I am simply blogging this with the intent that someone can shed some insight as to what may be going on. Although, since I know that the AAA logic of Rhino works with the EXACT same code under NUnit i have to believe it has something to do with the MSTest works.
So here is my propblem:
I have a test where i want to mock out and set an expectation on a repository. When I tried the code via the AAA syntax my expectation would only return a null. When I changed to use Record/Playback everything worked well. Odd.
Here is the syntax for AAA (non-working)
var mockRepository = new MockRepository();
var mockStatusCheckRepository = mockRepository.DynamicMock();
mockStatusCheckRepository.Expect( x => x.GetCustomerAuditInformation( "", "" ) ).IgnoreArguments().Return( new CustomerAuditInformation { NeedsInitialDataCreated = true } ).Repeat.Once();
var information = mockStatusCheckRepository.GetCustomerAuditInformation( "", "" );
// Returns null
I was able to get this working by NOT using the instance of MockRepoistory, instead using the Static Methods. Belows Code works
var mockStatusCheckRepository = MockRepository.GenerateMock();
mockStatusCheckRepository.Expect( x => x.GetCustomerAuditInformation( "", "" ) ).IgnoreArguments().Return( new CustomerAuditInformation { NeedsInitialDataCreated = true } ).Repeat.Once();
var information = mockStatusCheckRepository.GetCustomerAuditInformation( "", "" )
So, this may just be a case of me not fully understanding the new AAA syntax and how to use it, but I know that using the instance stuff works under NUnit... odd
Here is the syntax for the Record/Playback (working) - Can use the AAA syntax above as well
var mockRepository = new MockRepository();
var mockStatusCheckRepository = mockRepository.DynamicMock();
using ( mockRepository.Record() )
{
mockStatusCheckRepository.Expect( x => x.GetCustomerAuditInformation( "", "" ) ).IgnoreArguments().Return( new CustomerAuditInformation { NeedsInitialDataCreated = true } ).Repeat.Once();
}
using ( mockRepository.Playback() )
{
var information = mockStatusCheckRepository.GetCustomerAuditInformation( "", "" );
}
Cany anyone shed some light on this? Is there a way around this?
Till next time,
[----- Remember to check out DimeCasts.Net -----]