question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

'ServiceFabric.Mocks.MockStatefulServiceContextFactory' threw an exception.

See original GitHub issue

Hi,

I am trying to do some very basic unit tests around my SchedulerActor but I cannot get that working.

    private static SchedulerActor CreateActor(ActorId id)
    {
      Func<ActorService, ActorId, ActorBase> actorFactory = (service, actorId) => new SchedulerActor(service, id);
      var svc = MockActorServiceFactory.CreateActorServiceForActor<SchedulerActor>(actorFactory);
      var actor = svc.Activate(id);
      return actor;
    }

The exception message:

System.TypeInitializationException : The type initializer for 'ServiceFabric.Mocks.MockStatefulServiceContextFactory' threw an exception.
  ----> System.TypeLoadException : Method 'ReportApplicationHealth' in type 'ServiceFabric.Mocks.MockCodePackageActivationContext' from assembly 'ServiceFabric.Mocks, Version=2.1.0.0, Culture=neutral, PublicKeyToken=null' does not have an implementation.
   at ServiceFabric.Mocks.MockActorServiceFactory.CreateActorServiceForActor[TActor](Func`3 actorFactory, IActorStateProvider actorStateProvider, StatefulServiceContext context, ActorServiceSettings settings)

Issue Analytics

  • State:closed
  • Created 6 years ago
  • Comments:8 (5 by maintainers)

github_iconTop GitHub Comments

2reactions
loekdcommented, Oct 26, 2017

can you try using v2.2.2, in that version, more overloads were added

0reactions
loekdcommented, Oct 27, 2017

Glad I could help. If you’re good to go, please close the issue.

Read more comments on GitHub >

github_iconTop Results From Across the Web

loekd/ServiceFabric.Mocks
Works by injecting IServiceProxyFactory and/or IActorProxyFactory Mocks into Actors and Services. The factories will create Mock Proxies. Mocking out called ...
Read more >
Unit testing in Azure Service Fabric
ServiceFabric.Mocks contains many Mock and helper classes to facilitate and simplify unit testing of Service Fabric Actors and Services. Useful ...
Read more >
Writing UnitTests for a Service Fabric Application Class
Mocks library, to create a test instance of your service by using the following code: var serviceInstance = new SearchServiceClass( ...
Read more >
Unit testing stateful services in Service Fabric - Azure
These remote resources should be mocked. Mocking in the context of this article will fake, record, and control the return values for remote ......
Read more >
Mmm, software: July 2017
Unit testing Service Fabric Reliable Service and Actors with Mocks and Moqs. Install-Package Moq Install-Package ServiceFabric.Mocks
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found