public async Task NotificationStreamDisposeShouldInvokeStreamDisposedAsync()
        {
            await using (var notificationStream = new ODataNotificationStream(
                             this.stream,
                             this.streamListener)) // `synchronous` argument becomes irrelevant
            {
            }

            var result = await this.ReadStreamContentsAsync();

            Assert.Equal("StreamDisposedAsync", result);
        }
        public async Task NotificationStreamDisposeShouldInvokeStreamDisposedAsync()
        {
            using (var notificationStream = new ODataNotificationStream(
                       this.stream,
                       this.streamListener,
                       /*synchronous*/ false))
            {
            }

            var result = await this.ReadStreamContentsAsync();

            Assert.Equal("StreamDisposedAsync", result);
        }
        public void NotificationStreamDisposeShouldInvokeStreamDisposed(bool synchronous, string expected)
        {
            // We care about the notification stream being disposed
            // We don't care about the stream passed to the notification stream
            using (var notificationStream = new ODataNotificationStream(
                       this.stream,
                       this.streamListener,
                       synchronous))
            {
            }

            var result = ReadStreamContents();

            Assert.Equal(expected, result);
        }
        public async Task NotificationStreamDisposeAsyncShouldBeIdempotent()
        {
            var notificationStream = new ODataNotificationStream(
                this.stream,
                this.streamListener);

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

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

            var result = await this.ReadStreamContentsAsync();

            // StreamDisposeAsync was written only once
            Assert.Equal("StreamDisposedAsync", result);
        }
        public void NotificationStreamDisposeShouldBeIdempotent(bool synchronous, string expected)
        {
            var notificationStream = new ODataNotificationStream(
                this.stream,
                this.streamListener,
                synchronous);

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

            var result = ReadStreamContents();

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