예제 #1
0
        public void TestCreateDisposeClient(IIpcProvider provider)
        {
            var m1 = provider.CreateNewConnectionString();

            using (provider.GetClient(m1, new ClientConfig()))
            {
            }
        }
예제 #2
0
        public void TestCreateDisposeServer(IIpcProvider provider)
        {
            var m1 = provider.CreateNewConnectionString();

            using (var server = provider.GetServer(m1, new ServerConfig()))
            {
            }
        }
예제 #3
0
        public void TestServerConsideredNotCompletedBeforeStarted(IIpcProvider provider)
        {
            var m1 = provider.CreateNewConnectionString();

            using (var server = provider.GetServer(m1, new ServerConfig()))
            {
                Assert.False(server.Completion.IsCompleted);
            }
        }
예제 #4
0
        public void TestCreateStartStopDisposeServer(IIpcProvider provider)
        {
            var m1 = provider.CreateNewConnectionString();

            using (var server = provider.GetServer(m1, new ServerConfig()))
            {
                server.Start(EchoingExecutor);
                Assert.False(server.Completion.IsCompleted);
                server.RequestStop();
                WaitServerDone(server);
            }
        }
예제 #5
0
        public void TestServerMultipleDispose(IIpcProvider provider)
        {
            var m1 = provider.CreateNewConnectionString();

            using (var server = provider.GetServer(m1, new ServerConfig()))
            {
                server.Start(EchoingExecutor);
                server.RequestStop();
                WaitServerDone(server);
                server.Dispose();
            }
        }
예제 #6
0
        public void TestServerMultipleStartFails(IIpcProvider provider)
        {
            var testName = nameof(TestServerMultipleStartFails);
            var m1       = provider.CreateNewConnectionString();

            using (var server = provider.GetServer(m1, ServerConfigWithLogger(testName)))
            {
                server.Start(EchoingExecutor);
                var ex = Assert.Throws <IpcException>(() => server.Start(EchoingExecutor));
                Assert.Equal(IpcException.IpcExceptionKind.MultiStart, ex.Kind);
                server.RequestStop();
                WaitServerDone(server);
            }
        }
예제 #7
0
        public async Task TestWithConnectionErrorAsync(IIpcProvider provider)
        {
            var testName         = nameof(TestWithConnectionErrorAsync);
            var connectionString = provider.CreateNewConnectionString();
            var config           = new ClientConfig()
            {
                Logger            = VerboseLogger(testName),
                MaxConnectRetries = 2,
                ConnectRetryDelay = TimeSpan.FromMilliseconds(1)
            };

            using var client = provider.GetClient(connectionString, config);
            var syncOpResult = await client.Send(new IpcOperation("sync hi", waitForServerAck : true));

            var asyncOpResult = await client.Send(new IpcOperation("async hi", waitForServerAck : false));

            // operations should fail because no server was started
            XAssert.AreEqual(IpcResultStatus.ConnectionError, syncOpResult.ExitCode);
            XAssert.AreEqual(IpcResultStatus.ConnectionError, asyncOpResult.ExitCode);
            XAssert.IsFalse(syncOpResult.Succeeded);
            XAssert.IsFalse(asyncOpResult.Succeeded);
        }
예제 #8
0
 private string GetOrAddConnectionString(string monikerId)
 {
     return(m_moniker2connectionString.GetOrAdd(monikerId, (mId) => m_provider.CreateNewConnectionString()));
 }
예제 #9
0
 private static Client CreateDummyBxlApiClient(IIpcProvider ipcProvider)
 {
     return(new Client(new MockClient(ipcProvider.GetClient(ipcProvider.CreateNewConnectionString(), new ClientConfig()))));
 }