Ejemplo n.º 1
0
        public void ValidateDurableAbortReconnection()
        {
            IOperationDispatcher    serverDispatcher = new OperationDispatcher();
            StatelessServerEndpoint server           = new StatelessServerEndpoint(url, serverDispatcher);

            serverDispatcher.RegisterHandler <IWeakCalculator>(new WeakCalculator {
                Destroyed = () => server.Dispose()
            });
            server.Start();
            using (DurableClientConnection client = new DurableClientConnection(url))
            {
                client.ConnectionPaused = response => response.Abort = true;
                client.Open();
                IWeakCalculator calculator = client.RemoteExecutor.Create <IWeakCalculator>();
                Assert.AreEqual(4, calculator.Add(2, 2));
                calculator.Destroy();
                server = new StatelessServerEndpoint(url2, serverDispatcher);
                server.Start();
                bool exceptionThrown = false;
                try
                {
                    calculator.Add(5, 6);
                }
                catch (NotConnectedException ex)
                {
                    exceptionThrown = ex.Message == "Network connection is not opened.";
                }
                Assert.IsTrue(exceptionThrown);
                server.Dispose();
            }
        }
Ejemplo n.º 2
0
        public StrongCalculator()
        {
            FabricClientConnection connection = new FabricClientConnection(new Uri("fabric:/ServiceFabric.App/Stateless"));

            connection.Open();
            remoteWeakCalculator = connection.RemoteExecutor.Create <IWeakCalculator>();
        }
Ejemplo n.º 3
0
        public void ValidateDurableSilentFailover()
        {
            IOperationDispatcher    serverDispatcher = new OperationDispatcher();
            StatelessServerEndpoint server           = new StatelessServerEndpoint(url, serverDispatcher);

            serverDispatcher.RegisterHandler <IWeakCalculator>(new WeakCalculator {
                Destroyed = () => server.Dispose()
            });
            server.Start();
            using (ClientConnection client = new ClientConnection(url))
            {
                client.Open();
                IWeakCalculator calculator = client.RemoteExecutor.Create <IWeakCalculator>();
                Assert.AreEqual(4, calculator.Add(2, 2));
                calculator.Destroy();
                server = new StatelessServerEndpoint(url, serverDispatcher);
                server.Start();
                Assert.AreEqual(11, calculator.Add(5, 6));
                server.Dispose();
            }
        }