Trying to mock an interface with a generic parameter

501 views
Skip to first unread message

Michiel Huygen

unread,
Jan 31, 2014, 11:09:31 AM1/31/14
to nsubs...@googlegroups.com
Hey,

I'm trying to do the following:

Substitute.For<IPathFinder2D<Node>>();

With IPathFinder2D an interface and Node a class.

However, when i execute this code, i get an InvalidCastException (Castle.Proxies.IPathFinder2D`1Proxy_2 to IPathFinder2D`1[Node])

Am i doing something wrong?

Thanks in advance

MH

David Tchepak

unread,
Feb 2, 2014, 7:50:44 PM2/2/14
to nsubs...@googlegroups.com
What libraries are you using for IPathFinder2D and Node? Sometimes there can be strange issues trying to proxy interop classes, in which case you may be best asking the good folks at the Castle project (https://groups.google.com/forum/#!forum/castle-project-users).

There is nothing wrong with the syntax you're using. For example, this works fine:

    [Test]
    public void Sample() {
        Substitute.For<IPathFinder2D<Node>>();
    }
    public class Node { } 
    public interface IPathFinder2D<T> { }

Regards,
David



--
You received this message because you are subscribed to the Google Groups "NSubstitute" group.
To unsubscribe from this group and stop receiving emails from it, send an email to nsubstitute...@googlegroups.com.
To post to this group, send email to nsubs...@googlegroups.com.
Visit this group at http://groups.google.com/group/nsubstitute.
For more options, visit https://groups.google.com/groups/opt_out.

Reply all
Reply to author
Forward
0 new messages