Hi Arnauld,
I tried to reproduce the behavior - but for me it seems to work - what version are you using?
To get sure that I've got you right I attach the code I've used - maybe I've missed something - otherwise you might want to use
https://github.com/alaendle/rhino-mocks/downloads.
Br,
Andreas
[Fact]
public void SetterAmbigious()
{
var bar = MockRepository.GenerateStrictMock<Bar2>();
bar.Expect(x => x.Foo).SetPropertyAndIgnoreArgument();
bar.Foo = 2;
bar.VerifyAllExpectations();
} public class Bar
{
public virtual int? Foo { get; set; }
}
public class Bar2 : Bar
{
public new virtual int? Foo
{
get { return base.Foo; }
set { base.Foo = value; }
}
}
Am Mittwoch, 29. August 2012 13:04:25 UTC+2 schrieb arnauld dumez:
I have a exception because the reflexion for the SetPropertyAndIgnoreArgument methode fail on a property,
because this property has a new operator,
public new virtual int? Value
{ get
{ return base.Value;
}
set
{ base.Value = value;
}
}
and the exception is :
{"Ambiguous match found."}
at System.RuntimeType.GetPropertyImpl(String name, BindingFlags bindingAttr, Binder binder, Type returnType, Type[] types, ParameterModifier[] modifiers)
at System.Type.GetProperty(String name, Type[] types)
at Rhino.Mocks.Impl.MethodOptions`1.GetPropertyFromMethod(MethodInfo method)
at Rhino.Mocks.Impl.MethodOptions`1.PropertySetterFromMethod(MethodInfo method)
at Rhino.Mocks.Impl.MethodOptions`1.SetPropertyAndIgnoreArgument()
My code :
.Expect(e => e.Value).SetPropertyAndIgnoreArgument();
Thanks for help me.