Exemplo n.º 1
0
        public async Task WriteStreamDisposeShouldInvokeStreamDisposedAsync()
        {
            await using (var writeStream = new ODataWriteStream(
                             new MemoryStream(),
                             this.streamListener)) // `synchronous` argument becomes irrelevant
            {
            }

            var result = await this.ReadStreamContentsAsync();

            Assert.Equal("StreamDisposedAsync", result);
        }
Exemplo n.º 2
0
        public async Task WriteStreamDisposeShouldInvokeStreamDisposedAsync()
        {
            using (var writeStream = new ODataWriteStream(
                       new MemoryStream(),
                       this.streamListener,
                       /*synchronous*/ false))
            {
            }

            var result = await this.ReadStreamContentsAsync();

            Assert.Equal("StreamDisposedAsync", result);
        }
Exemplo n.º 3
0
        public void WriteStreamDisposeShouldInvokeStreamDisposed(bool synchronous, string expected)
        {
            // We care about the write stream being disposed
            // We don't care about the stream passed to the write stream
            using (var writeStream = new ODataWriteStream(
                       new MemoryStream(),
                       this.streamListener,
                       synchronous))
            {
            }

            var result = ReadStreamContents();

            Assert.Equal(expected, result);
        }
Exemplo n.º 4
0
        public async Task WriteStreamDisposeAsyncShouldBeIdempotent()
        {
            var writeStream = new ODataWriteStream(
                new MemoryStream(),
                this.streamListener);

            // 1st call to DisposeAsync
            await writeStream.DisposeAsync();

            // 2nd call to DisposeAsync
            await writeStream.DisposeAsync();

            var result = await this.ReadStreamContentsAsync();

            // StreamDisposeAsync was written only once
            Assert.Equal("StreamDisposedAsync", result);
        }
Exemplo n.º 5
0
        public void WriteStreamDisposeShouldBeIdempotent(bool synchronous, string expected)
        {
            var writeStream = new ODataWriteStream(
                new MemoryStream(),
                this.streamListener,
                synchronous);

            // 1st call to Dispose
            writeStream.Dispose();
            // 2nd call to Dispose
            writeStream.Dispose();

            var result = ReadStreamContents();

            // StreamDisposed/StreamDisposeAsync was written only once
            Assert.Equal(expected, result);
        }