Ejemplo n.º 1
0
        public async Task ClientConnectCancellationTest()
        {
            using var cancellationTokenSource = new CancellationTokenSource(TimeSpan.FromSeconds(1));
            await using var client            = new SingleConnectionPipeClient <string>("this_pipe_100%_is_not_exists");

            await Assert.ThrowsExceptionAsync <OperationCanceledException>(async() => await client.ConnectAsync(cancellationTokenSource.Token));
        }
Ejemplo n.º 2
0
        public async Task ClientConnectTest()
        {
            using var cancellationTokenSource = new CancellationTokenSource(TimeSpan.FromSeconds(1));
            await using var client            = new SingleConnectionPipeClient <string>(nameof(ClientConnectTest));
            await using var server            = new SingleConnectionPipeServer <string>(nameof(ClientConnectTest));

            await server.StartAsync(cancellationToken : cancellationTokenSource.Token);

            await client.ConnectAsync(cancellationTokenSource.Token);
        }
Ejemplo n.º 3
0
        public static async Task DataSingleTestAsync <T>(List <T> values, Func <T, string>?hashFunc = null, IFormatter?formatter = default, TimeSpan?timeout = default)
        {
            using var cancellationTokenSource = new CancellationTokenSource(timeout ?? TimeSpan.FromSeconds(15));

            const string pipeName = "data_test_pipe";

            await using var server = new SingleConnectionPipeServer <T>(pipeName, formatter ?? new BinaryFormatter())
                        {
                            WaitFreePipe = true
                        };
            await using var client = new SingleConnectionPipeClient <T>(pipeName, formatter: formatter ?? new BinaryFormatter());

            await DataTestAsync(server, client, values, hashFunc, cancellationTokenSource.Token);
        }