Exemplo n.º 1
0
            public async Task CreateBlob_DisconnectedDuringCreate()
            {
                var data = new byte[25 * 1024 * 1024]; // try to send a massive blob

                ManualResetEvent testStarted = new ManualResetEvent(false);
                Func <Task>      f           = () => {
                    testStarted.Set();
                    return(_session.CreateBlobAsync(data));
                };
                var assertion = f.ShouldThrowAsync <RHostDisconnectedException>();
                await Task.Delay(100);

                await _session.StopHostAsync();

                await assertion;
            }
Exemplo n.º 2
0
 public async Task CreateBlob_DisconnectedFromTheStart()
 {
     using (var session = new RSession(0, _brokerConnector, () => { })) {
         var         data = new byte[] { 1, 2, 3, 4, 5 };
         Func <Task> f    = () => session.CreateBlobAsync(data);
         await f.ShouldThrowAsync <RHostDisconnectedException>();
     }
 }
Exemplo n.º 3
0
            public async Task CreateBlob_CanceledDuringCreate()
            {
                var         cts  = new CancellationTokenSource();
                var         data = new byte[1024 * 1024];
                Func <Task> f    = async() => {
                    while (true)
                    {
                        var blob = await _session.CreateBlobAsync(ct : cts.Token);

                        await _session.BlobWriteAsync(blob, data, -1, ct : cts.Token);
                    }
                };
                var assertion = f.ShouldThrowAsync <OperationCanceledException>();

                cts.CancelAfter(1);
                await assertion;
            }