Re: Rhino Mock Bug SetPropertyAndIgnoreArgument on "new virtual" property

102 views
Skip to first unread message
Message has been deleted

haifisch

unread,
Sep 6, 2012, 3:29:42 PM9/6/12
to rhino...@googlegroups.com
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 { getset; }
  }
 
  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.
Reply all
Reply to author
Forward
0 new messages