This is a migrated thread and some comments may be shown as answers.

Mocking generic method

3 Answers 161 Views
General Discussions
This is a migrated thread and some comments may be shown as answers.
Daní
Top achievements
Rank 1
Daní asked on 26 Apr 2013, 10:39 AM
Hi,

First of all, I'm newbie with Just Mock and after a few weeks working with it I think you are doing a great job. So, congratulations!!

Maybe this question is already answered but, if so, I didn't find it. I'd like to intercept a call to a generi method similar to:
public  class MyClass
{
    public void MyMethod<T>()
    {
        //
    }
}

Now I want to arrange a MyClass instance so I can assert that the method has been call only once for an specific type and never for any other type. I'm tryig to do something similar to:
var service = Mock.Create<MyClass>();
 Mock.Arrange(() => service.MyMethod<T>()).OccursNever();

So I can assert the generic method is never called

3 Answers, 1 is accepted

Sort by
0
Kaloyan
Telerik team
answered on 26 Apr 2013, 03:30 PM
Hi Dani,

Thank you for the nice words.

Currently, arranging against generic methods can be achieved only if you are passing a certain constraint, like this:
Mock.Arrange(() => service.MyMethod<string>()).OccursNever();
However, I find your idea very good. Please, vote for its implementation in our Ideas and Feedback portal.

We are granting you some Telerik points for bringing this to us.

Please, do not hesitate to contact us once again if you need further assistance with JustMock.

Kind regards,
Kaloyan
the Telerik team
Share what you think about JustTrace & JustMock with us, so we can become even better! You can use the built-in feedback tool inside JustTrace, our forums, or our JustTrace or JustMock portals.
0
Mark
Top achievements
Rank 1
answered on 03 Nov 2017, 04:56 PM

Did this ever get implemented in Just Mock?

it would make my life so much easier.

0
Kaloyan
Telerik team
answered on 09 Nov 2017, 02:01 PM
Hi Mark,

I am afraid that this is still an unsupported scenario in JustMock. 

Regards,
Kaloyan
Progress Telerik
Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Feedback Portal and vote to affect the priority of the items
Tags
General Discussions
Asked by
Daní
Top achievements
Rank 1
Answers by
Kaloyan
Telerik team
Mark
Top achievements
Rank 1
Share this question
or