public async Task TestActorRemotingAsync() { var payload = new Payload("content"); var service = new CustomActorService(MockStatefulServiceContextFactory.Default, ActorTypeInformation.Get(typeof(RemotingEnabledActor))); var factory = new ServiceFabric.Mocks.RemotingV2.MockActorServiceRemotingClientFactory(service); var responseMessageBody = new MockServiceRemotingResponseMessageBody() { Response = payload }; var requestMessageBody = new MockServiceRemotingRequestMessageBody(); factory.MockServiceRemotingMessageBodyFactory = new MockServiceRemotingMessageBodyFactory() { Request = requestMessageBody, Response = responseMessageBody }; factory.ServiceRemotingClient = new RemotingV2.MockActorServiceRemotingClient(service) { ServiceRemotingResponseMessage = new MockServiceRemotingResponseMessage { Body = responseMessageBody } }; var proxyFactory = new ActorProxyFactory(callbackClient => factory); var proxy = proxyFactory.CreateActorProxy <IMyStatefulActor>(ActorId.CreateRandom(), "App", "Service", "Listener"); await proxy.InsertAsync("state", payload); Assert.IsInstanceOfType(proxy, typeof(IMyStatefulActor)); }
public async Task TestRemotingFactoryAsync() { var service = new CustomActorService(MockStatefulServiceContextFactory.Default, ActorTypeInformation.Get(typeof(MyStatefulActor))); var factory = new ServiceFabric.Mocks.RemotingV2.MockActorServiceRemotingClientFactory(service); var client = await factory.GetClientAsync(new Uri("fabric:/App/Service"), ServicePartitionKey.Singleton, TargetReplicaSelector.Default, "Listener", new OperationRetrySettings(), CancellationToken.None); Assert.IsInstanceOfType(factory, typeof(IServiceRemotingClientFactory)); Assert.IsInstanceOfType(client, typeof(IServiceRemotingClient)); Assert.IsInstanceOfType(client, typeof(MockActorServiceRemotingClient)); Assert.AreEqual("Listener", client.ListenerName); }