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

Telerik.JustMock.Core.ElevatedMockingException issue

11 Answers 824 Views
General Discussions
This is a migrated thread and some comments may be shown as answers.
Ciprian
Top achievements
Rank 1
Ciprian asked on 23 Jul 2015, 02:29 PM

Hello guys!

 

I get a Telerik.JustMock.Core.ElevatedMockingException when I run: Mock.Arrange(() => _client.GetAsync(Arg.IsAny<string>())).Returns(ShowMeTheMoney());

static async Task<HttpResponseMessage> ShowMeTheMoney()
        {
            HttpRequestMessage httpRequest = new HttpRequestMessage();
            httpRequest.SetConfiguration(new HttpConfiguration());
            HttpResponseMessage response = httpRequest.CreateResponse(HttpStatusCode.OK, new List<SmsDTO>() { new SmsDTO()});
            return response;
        } 

    [TestMethod]
        public void GetAll_NullResultTes3t()
        {
            //Assert.IsTrue(Mock.IsProfilerEnabled);
            _client = Mock.Create<HttpClient>();
            _controller = new SmsController(new Persistence(_client));
            _controller.Request = new HttpRequestMessage();           
            Mock.Arrange(() => _client.GetAsync(Arg.IsAny<string>())).Returns(ShowMeTheMoney());
            IEnumerable<SmsDTO> actualResult = _controller.GetAll();
            CollectionAssert.AllItemsAreNotNull(actualResult.ToList());
        }

 

I use VS2015 Enterprise and I have disabled IntelliTrace(Tools>Options>IntelliTrace: Uncheck the Enable IntelliTrace checkbox). Also I enabled the profiler from the JustMock Menu.

I get the following in Event logs:
Info: .NET Runtime version 4.0.30319.0 - The profiler has requested that the CLR instance not load the profiler into this process.  Profiler CLSID: '{9999995d-2cbb-4893-be09-fce80abc7564}'.  Process ID (decimal): 7808.  Message ID: [0x2516].

Info: TraceLog Profiler component initialized successfully, process vstest.executionengine.x86.exe

Info: .NET Runtime version 4.0.30319.0 - The profiler was loaded successfully.  Profiler CLSID: '{9999995d-2cbb-4893-be09-fce80abc7564}'.  Process ID (decimal): 7724.  Message ID: [0x2507].

Error:

The description for Event ID 0 from source Application cannot be found. Either the component that raises this event is not installed on your local computer or the installation is corrupted. You can install or repair the component on the local computer.

If the event originated on another computer, the display information had to be saved with the event.

The following information was included with the event: 

Error Handler Exception: System.ServiceModel.CommunicationException: There was an error reading from the pipe: The pipe has been ended. (109, 0x6d). ---> System.IO.IOException: The read operation failed, see inner exception. ---> System.ServiceModel.CommunicationException: There was an error reading from the pipe: The pipe has been ended. (109, 0x6d). ---> System.IO.PipeException: There was an error reading from the pipe: The pipe has been ended. (109, 0x6d).
   at System.ServiceModel.Channels.PipeConnection.OnAsyncReadComplete(Boolean haveResult, Int32 error, Int32 numBytes)
   --- End of inner exception stack trace ---
   at System.Runtime.AsyncResult.End[TAsyncResult](IAsyncResult result)
   at System.ServiceModel.Channels.ConnectionStream.EndRead(IAsyncResult asyncResult)
   at System.Net.FixedSizeReader.ReadCallback(IAsyncResult transportResult)
   --- End of inner exception stack trace ---
   at System.Net.Security.NegotiateStream.EndRead(IAsyncResult asyncResult)
   at System.ServiceModel.Channels.StreamConnection.EndRead()
   --- End of inner exception stack trace ---
   at System.Runtime.AsyncResult.End[TAsyncResult](IAsyncResult result)
   at System.ServiceModel.Channels.TransportDuplexSessionChannel.EndTryReceive(IAsyncResult result, Message& message)
   at System.ServiceModel.Dispatcher.DuplexChannelBinder.EndTryReceive(IAsyncResult result, RequestContext& requestContext)
   at System.ServiceModel.Dispatcher.ErrorHandlingReceiver.EndTryReceive(IAsyncResult result, RequestContext& requestContext) \r\n    at System.Runtime.AsyncResult.End[TAsyncResult](IAsyncResult result)
   at System.ServiceModel.Channels.TransportDuplexSessionChannel.EndTryReceive(IAsyncResult result, Message& message)
   at System.ServiceModel.Dispatcher.DuplexChannelBinder.EndTryReceive(IAsyncResult result, RequestContext& requestContext)
   at System.ServiceModel.Dispatcher.ErrorHandlingReceiver.EndTryReceive(IAsyncResult result, RequestContext& requestContext)

the message resource is present but the message is not found in the string/message table

Info: .NET Runtime version 4.0.30319.0 - The profiler has requested that the CLR instance not load the profiler into this process.  Profiler CLSID: '{b7abe522-a68f-44f2-925b-81e7488e9ec0}'.  Process ID (decimal): 6696.  Message ID: [0x2516].

 According to regedit, CLSID: '{9999995d-2cbb-4893-be09-fce80abc7564} corresponds to IntelliTrace and  CLSID: '{b7abe522-a68f-44f2-925b-81e7488e9ec0}' to CodeWeaverProfiler class. 

 Could you please help?

 

Thanks!

11 Answers, 1 is accepted

Sort by
0
Ciprian
Top achievements
Rank 1
answered on 23 Jul 2015, 02:39 PM

The full exception Message is:
Cannot mock 'System.Threading.Tasks.Task`1[System.Net.Http.HttpResponseMessage] GetAsync(System.String)'. The profiler must be enabled to mock, arrange or execute the specified target.
Detected active third-party profilers:
* {9999995d-2cbb-4893-be09-fce80abc7564} (from process environment)
Disable the profilers or link them from the JustMock configuration utility. Restart Visual Studio and/or the test runner after linking.

StackTrace:

   at Telerik.JustMock.Core.ProfilerInterceptor.ThrowElevatedMockingException(MemberInfo member)
   at Telerik.JustMock.Core.MocksRepository.CheckMethodInterceptorAvailable(IMatcher instanceMatcher, MethodBase method)
   at Telerik.JustMock.Core.MocksRepository.AddArrange(IMethodMock methodMock)
   at Telerik.JustMock.Core.MocksRepository.Arrange[TMethodMock](Expression expr, Func`1 methodMockFactory)
   at Telerik.JustMock.Mock.<>c__DisplayClass8`1.<Arrange>b__6()
   at Telerik.JustMock.Core.ProfilerInterceptor.GuardInternal[T](Func`1 guardedAction)
   at Telerik.JustMock.Mock.Arrange[TResult](Expression`1 expression)
   at SMSTemplate.Test.ControllerAndPersistenceTest.GetAll_NullResultTes3t() in D:\Work\CommunicationGateway\MicroServices\Templates\SMSTemplate\V1.1\SMSTemplate.Test\ControllerAndPersistenceTest.cs:line 35

 ​

0
Accepted
Stefan
Telerik team
answered on 24 Jul 2015, 07:07 AM
Hello Ciprian,

Open the JustMock configuration utility (JustMock->Options...) and click the "Visual Studio 2015 Code Coverage/IntelliTrace" check box. Restart Visual Studio and try running the test again.

The IntelliTrace profiler is also loaded by Visual Studio's code coverage and by Fakes. Do you use any of those?

Regards,
Stefan
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
0
Ciprian
Top achievements
Rank 1
answered on 24 Jul 2015, 08:21 AM

Hello Stefan!

 

First let me just say that I don't get IntelliTrace 2015 in 'Telerik JustMock Configuration' window(that's what shows up when I click JustMock>Options).

 

Your second advice worked. I found an unused reference to some fakes library in my test project(leftover from when I tried to write some tests with fakes). After I removed it, it just worked.

 

Thanks! Problem solved!

 

Ciprian.

0
Stefan
Telerik team
answered on 27 Jul 2015, 09:14 AM
Hello Ciprian,

I'm glad that your issue is now resolved. It's strange that the configuration tool is not offering IntelliTrace 2015, as you have stated that the profiler is present in the COM registry. Can you send me a screenshot of what you see in the configuration tool, please?

Regards,
Stefan
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
0
Ciprian
Top achievements
Rank 1
answered on 27 Jul 2015, 12:58 PM
Hello! I have attached the config tool window. Please let me know, if you need further details.
0
Kaloyan
Telerik team
answered on 30 Jul 2015, 11:18 AM
Hi Ciprian,

Thank you for the screen shots. We will investigate what could be causing this behavior locally and will address any issues found. It is possible that we require some further information from your side, so please let us know if this is okay to you?

Regards,
Kaloyan
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
0
Ciprian
Top achievements
Rank 1
answered on 03 Aug 2015, 07:02 AM
Sure.
0
Stefan
Telerik team
answered on 11 Aug 2015, 09:23 AM
Hello Ciprian,

It appears that you're running an outdated version of JustMock that does not support the Visual Studio 2015 Code Coverage/IntelliTrace profiler integration. Can you update to the latest version of JustMock and try again? In any case, if you remove any Fakes assemblies from your test project and disable IntelliTrace from Visual Studio options, the JustMock profiler should load successfully and you will not need to link the profilers.

Regards,
Stefan
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
0
Ciprian
Top achievements
Rank 1
answered on 12 Aug 2015, 12:02 PM
I'm using Telerik JustMock 2014.3 1021(Oct. 27, 2014). I don't have access to a newer version. 

Sorry.
0
Stefan
Telerik team
answered on 12 Aug 2015, 12:54 PM
Hi Ciprian,

In that case remove any Fakes assemblies from your test project and disable IntelliTrace from Visual Studio options. The JustMock profiler should load successfully and you will not need to link the profilers.

Regards,
Stefan
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
0
Ciprian
Top achievements
Rank 1
answered on 12 Aug 2015, 01:08 PM

Hello!

 I've already done that and it worked(see my second message).

 

Thanks!

Tags
General Discussions
Asked by
Ciprian
Top achievements
Rank 1
Answers by
Ciprian
Top achievements
Rank 1
Stefan
Telerik team
Kaloyan
Telerik team
Share this question
or