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.
>
--
You received this message because you are subscribed to the Google Groups
"Rhino.Mocks" group.
To view this discussion on the web visit
https://groups.google.com/d/msg/rhinomocks/-/-1ZQmnkLD3wJ.
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.