Why not differentiate the constructor by using string.Empty?
-----Original Message-----
From: BaRuSa <[email protected]>
Date: Wed, 14 Apr 2010 07:34:02 
To: Rhino.Mocks<[email protected]>
Subject: [RhinoMocks] Ambiguous match found when passing null to a constructor

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