I have the following code:
public interface ILala
{
int AAA { get; set; }
}
public class BBB
{
public int Meth(ILala l)
{
return l.AAA;
}
}
and I'm trying to run the following test :
[Test]
[ExpectedException(typeof(ApplicationException))]
public void RhinoMockProperty()
{
//
// Arrange
BBB instance = new BBB();
ILala lStub =
MockRepository.GenerateStub<ILala>();
lStub.Stub(x => x.AAA).Throw(new ApplicationException());
//
// Act
instance.Meth(lStub);
}
this code fails with the following exception :
System.InvalidOperationException : You are trying to set an
expectation on a property that was defined to use PropertyBehavior.
Instead of writing code such as this: mockObject.Stub(x =>
x.SomeProperty).Return(42);
You can use the property directly to achieve the same result:
mockObject.SomeProperty = 42;
at Rhino.Mocks.Impl.RecordMockState.GetLastMethodOptions[T]()
at Rhino.Mocks.MockRepository.LastMethodCall[T](Object
mockedInstance)
at Rhino.Mocks.LastCall.GetOptions[T]()
at Rhino.Mocks.RhinoMocksExtensions.Expect[T,R](T mock, Function`2
action)
at Rhino.Mocks.RhinoMocksExtensions.Stub[T,R](T mock, Function`2
action)
BBBTests.cs(19,0): at
ClassLibrary14.Tests.BBBTests.RhinoMockProperty()
I tried doing the same with GenerateMock instead of GenerateStub and
it works.
Is there any other workaround ?
--
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.