public async Task StartStopStart() { await using var pipe = new SingleConnectionPipeServer <string>("test"); await pipe.StartAsync(); await pipe.StopAsync(); await pipe.StartAsync(); }
public async Task DoubleStartWithSameName() { await using var pipe1 = new SingleConnectionPipeServer <string>("test"); await pipe1.StartAsync(); await using var pipe2 = new SingleConnectionPipeServer <string>("test"); await Assert.ThrowsExceptionAsync <IOException>(async() => await pipe2.StartAsync()); }
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); }
public async Task DoubleStartWithSameName_CommonDispose() { // ReSharper disable once UseAwaitUsing using var pipe1 = new SingleConnectionPipeServer <string>("test"); await pipe1.StartAsync(); // ReSharper disable once UseAwaitUsing using var pipe2 = new SingleConnectionPipeServer <string>("test"); await Assert.ThrowsExceptionAsync <IOException>(async() => await pipe2.StartAsync()); }
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); }