Declined
Last Updated: 16 May 2023 07:45 by ADMIN
Jean-Paul
Created on: 12 May 2023 17:25
Type: Bug Report
0
Unable to mock interface containing method with 'in' parameter (R1 2023)

I am unable to mock interfaces that contain a method with an `in` parameter. When running the following code snippet, the result is an exception:

Message: 
  Test method Example.UnitTests.UnitTest.TestMethod threw exception:
  Telerik.JustMock.Core.MockException: Abstract type 'Example.UnitTests.InParamExample' is not accessible for inheritance.

Stack Trace: 
  MocksRepository.Create(Type type, MockCreationSettings settings)
  <>c__38`1.<Create>b__38_0()
  ProfilerInterceptor.GuardInternal[T](Func`1 guardedAction)
  UnitTest.TestMethod() line 23

namespace Example.UnitTests
{
    using Microsoft.VisualStudio.TestTools.UnitTesting;
    using Telerik.JustMock;

    public interface ParamExample
    {
        void Foo(int param);
    }

    public interface InParamExample
    {
        void Foo(in int param);
    }

    [TestClass]
    public class UnitTest
    {
        [TestMethod]
        public void TestMethod()
        {
            var mockedParamExample = Mock.Create<ParamExample>();
            var mockedInParamExample = Mock.Create<InParamExample>();
        }
    }
}
3 comments
ADMIN
Ivo
Posted on: 16 May 2023 07:44

Hello Jean-Paul,

I am glad to hear that the issue you are experiencing is now resolved. If you have any troubles, do not hesitate to contact us back again.

Regards,
Ivo
Progress Telerik

A brand new JustMock course was just added to the Virtual Classroom - the free self-paced technical training portal that gets you up to speed with Telerik and Kendo UI products! Check it out at https://learn.telerik.com.
Jean-Paul
Posted on: 15 May 2023 16:52

Hi Ivo,

You are right, turns out we were stashing and using an old Telerik.JustMock.dll in our project. Sorry for the false alarm!

JP

ADMIN
Ivo
Posted on: 15 May 2023 08:56

Hello Jean-Paul,

I am unable to observe such a problem using the provided code snippet (even with the profiler disabled), see attached. I would like to ask you the check your project settings since the issue could be caused by them.

Regards,
Ivo
Progress Telerik

A brand new JustMock course was just added to the Virtual Classroom - the free self-paced technical training portal that gets you up to speed with Telerik and Kendo UI products! Check it out at https://learn.telerik.com.
Attached Files: