What if you specifically cast "name" as a string?

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

---
Patrick Steele
http://weblogs.asp.net/psteele



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

Reply via email to