public async Task AddServiceAction_UsingFunc_RegisterInstance() { bool actionCalled = false; Task action(IServiceProvider provider, object c, CancellationToken t) { Assert.IsNotNull(provider); actionCalled = true; return(Task.CompletedTask); } HostBuilder hostBuilder = new HostBuilder(); new ServiceFabricHostBuilder <IServiceFabricService <ServiceContext>, ServiceContext>(hostBuilder).AddServiceAction(action); IServiceAction <IServiceFabricService <ServiceContext> > resolvedAction = hostBuilder .Build() .Services.GetService <IServiceAction <IServiceFabricService <ServiceContext> > >(); IServiceFabricService <ServiceContext> mockService = new Mock <IServiceFabricService <ServiceContext> >().Object; await resolvedAction.RunAsync(mockService, CancellationToken.None).ConfigureAwait(false); Assert.IsTrue(actionCalled); }