Hi
I have an odd case.
I have the following test:
private IEventQueueItemCollection _eventQueueItems;
[TestInitialize]
public void TestInitialize()
{
this._eventQueueItems =
MockRepository.GenerateMock<IEventQueueItemCollection>();
}
[TestMethod]
public void
Forecast_CreateSimpleLinearForecast_GetAverageInQueueTime_WithoutAverageInQueueTime_Test()
{
DateTime expectedLastInQueueUtcTimeRedirected =
DateTime.UtcNow;
this._eventQueueItems.Stub(items =>
items.Count).Return(1);
this._eventQueueItems.Stub(items => items[0])
.Return(new EventQueueItem(Guid.NewGuid())
{ InQueueUtcTime = expectedLastInQueueUtcTimeRedirected });
Forecast actualForecast = new Forecast(this._customerId,
this._eventId);
actualForecast.CalculateForecast(DateTime.MinValue, 4, 10,
DateTime.MinValue);
Assert.AreEqual(expectedLastInQueueUtcTimeRedirected,
actualForecast.AverageInWindowUtcTime);
}
If I run this test as the only test or if I run all the tests in the
test class it works fine. However if I run all tests in the project I
will receive the following error in approx 1 of 3 test runs. That is
it works fine 2 out of 3 times.
Test method
xxx.ForecastTest.Forecast_CreateSimpleLinearForecast_GetAverageInQueueTime_WithoutAverageInQueueTime_Test
threw exception:
System.InvalidOperationException: Type 'xxx.EventQueueItem' doesn't
match the return type 'System.Void' for method
'ICollection`1.Add(missing parameter);'
at
Rhino.Mocks.Expectations.AbstractExpectation.AssertTypesMatches(Object
value)
at Rhino.Mocks.Expectations.AbstractExpectation.set_ReturnValue(Object
value)
at Rhino.Mocks.Impl.MethodOptions`1.Return(T objToReturn)
at
xxx.ForecastTest.Forecast_CreateSimpleLinearForecast_GetAverageInQueueTime_WithoutAverageInQueueTime_Test()
in ForecastTest.cs: line 333
The exception is thrown in this line:
this._eventQueueItems.Stub(items => items[0])
.Return(new EventQueueItem(Guid.NewGuid())
{ InQueueUtcTime = expectedLastInQueueUtcTimeRedirected });
Does anyone have an idea to why this exception occurs approx every
third time the test is run?
--
You received this message because you are subscribed to the Google Groups
"Rhino.Mocks" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to
[email protected].
For more options, visit this group at
http://groups.google.com/group/rhinomocks?hl=en.