Error when trying to mock sealed class "ServicePartitionResolver"

2 Answers 437 Views
API Non-public Mocking
NovoPath
Top achievements
Rank 1
Iron
NovoPath asked on 13 Sep 2021, 03:34 PM

Error when trying to mock Microsoft.ServiceFabric.Services.Client with the following code:


using Microsoft.ServiceFabric.Services.Client;

[Fact]

public void Foo() {

var spr = Mock.Create<ServicePartitionResolver>();

}

When I run this simple test I got:


Message: 
System.TypeLoadException : Could not load type 'System.Runtime.Remoting.Proxies.RealProxy' from assembly 'mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089'.

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

 

2 Answers, 1 is accepted

Sort by
0
Ivo
Telerik team
answered on 14 Sep 2021, 03:52 PM

Hello,

The most probable reason for this error is the wrong assembly reference to JustMock that targets .NET Framework, but the project targets .NET Core. The right assembly is placed in a separate sub-directory netcoreapp2.0. If this is not the case, let us know, so we continue investigations for the potential cause.

Regards,
Ivo
Progress Telerik

Love the Telerik and Kendo UI products and believe more people should try them? Invite a fellow developer to become a Progress customer and each of you can get a $50 Amazon gift voucher.

0
NovoPath
Top achievements
Rank 1
Iron
answered on 15 Sep 2021, 07:19 PM

Thank you very much for your quick response.

Issue resolved, It was confusing since I'm using Core 5.0.

 

Thanks

Ivo
Telerik team
commented on 17 Sep 2021, 11:38 AM

I am glad to hear that the issue you were facing is now resolved. I would like to ask you to mark the answer, so the others having the same issue could benefit from this solution. Wish you a great day!

Tags
API Non-public Mocking
Asked by
NovoPath
Top achievements
Rank 1
Iron
Answers by
Ivo
Telerik team
NovoPath
Top achievements
Rank 1
Iron
Share this question
or