My answer to this is that you have a flawed design in AbstractExample.

Firstly, if you had developed this in a TDD fashion, you would not end
up with an object that takes two types as alternate constructors.

My advice would be to think more carefully about what it is that yor
object is suppoed to be doing. Quite frankly, even the .net framework
would be confused

public class MyImpl : AbstractExample
{
    public MyImpl(string s) : base(s) { }
    public MyImpl(IExampleInterface iei) : base(iei) { }
}

var instance = MyImpl(null);   ... what constructor should be invoked?



On Apr 14, 3:34 pm, 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].
For more options, visit this group at 
http://groups.google.com/group/rhinomocks?hl=en.

Reply via email to