Because the null value doesn't carry runtime type information. The
reflection framework won't be able tell which method you want to call.

There are two possible solutions to this:

If you mean null by don't care of what the parameter value is, then try
using string.Empty instead of null as Jake suggested. i.e.:

example = MockRepository.
>
> GenerateStrictMock<AbstractExample>(string.Empty);


If you must pass a null string then you need a subclass:

abstract class AbstractExampleStub : AbstractExample
{
    public AbstractExampleStub(string name) : base(name){}
}

Then use
example = MockRepository.
>
> GenerateStrictMock<AbstractExampleStub>(name);


HTH,
Kenneth

On Wed, Apr 14, 2010 at 10:34 AM, BaRuSa <[email protected]> wrote:

> Simplified example of a class:
>
> abstract class AbstractExample : IExampleInterface
> {
>  protected AbstractExample(string name) { /* Do Stuff */ }
>  protected AbstractExample(IExampleInterface deepCopy) { /* Do Stuff
> */ }
>  // abstract methods
> }
>
>
> Simpiflied test for constructor:
>
> [ExpectedException(typeof(ArgumentNullException))]
> void Test()
> {
>  AbstractExample example;
>  string name;
>
>  name = null;
>  example = MockRepository.GenerateStrictMock<AbstractExample>(name);
> }
>
>
> The test creates an exception
> "System.Reflection.AmbiguousMatchException: Ambiguous match found."  I
> am assuming the problem is there are two constructors that could
> accept null, but Rhino Mocks doesn't know which type to use.  I know
> there are constraints that be placed on methods; are there constraints
> for calling constructors?  Is there a different solution I am not
> thinking about?
>
> --
> 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]<rhinomocks%[email protected]>
> .
> For more options, visit this group at
> http://groups.google.com/group/rhinomocks?hl=en.
>
>

-- 
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.

Reply via email to