Exemplo n.º 1
0
        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 TestActorRemotingAsync()
        {
            var service      = new CustomActorService(MockStatefulServiceContextFactory.Default, ActorTypeInformation.Get(typeof(MyStatefulActor)));
            var factory      = new MockActorServiceRemotingClientFactory(service);
            var proxyFactory = new ActorProxyFactory(callbackClient => factory);
            var proxy        = proxyFactory.CreateActorProxy <IMyStatefulActor>(ActorId.CreateRandom(), "App", "Service", "Listener");
            await proxy.InsertAsync("state", new Payload("content"));

            Assert.IsInstanceOfType(proxy, typeof(IMyStatefulActor));
        }
Exemplo n.º 3
0
        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);
        }
        public async Task Alternative_TestSubscribe_Doesnt_CrashAsync()
        {
            var guid    = Guid.NewGuid();
            var service = new CustomActorService(MockStatefulServiceContextFactory.Default, ActorTypeInformation.Get(typeof(MyStatefulActor)));
            var factory = new MockActorServiceRemotingClientFactory(service);

            var mockProxyFactory = new ActorProxyFactory(callbackClient => factory);
            var exampleService   = new ExampleClient(MockStatefulServiceContextFactory.Default, new MockReliableStateManager(),
                                                     null, mockProxyFactory);
            await exampleService.DoSomething(guid, "message text");

            Assert.IsFalse(IsSuccess);             //Subscribe doesn't crash the test, but the Event is not really fired and processed at this time
        }