public void ShouldReturnKeys()
            {
                var cursor = CreateResultCursor(3, 0);
                var result = new InternalRxResult(Observable.Return(cursor));

                VerifyKeys(result, "key01", "key02", "key03");
            }
            public void ShouldReturnSummary()
            {
                var cursor = CreateResultCursor(3, 0, "my query");
                var result = new InternalRxResult(Observable.Return(cursor));

                VerifySummary(result, "my query");
            }
            public void ShouldReturnRecords()
            {
                var keys   = new[] { "key01", "key02", "key03" };
                var cursor = CreateResultCursor(3, 5);
                var result = new InternalRxResult(Observable.Return(cursor));

                VerifyRecords(result, keys, 5);
            }
            public void ShouldErrorOnSummary()
            {
                var failure = new ClientException("some error");
                var cursor  = CreateFailingResultCursor(failure, 2, 5);
                var result  = new InternalRxResult(Observable.Return(cursor));

                VerifyError(result.Consume(), failure);
            }
            public void ShouldReturnKeys()
            {
                var failure = new AuthenticationException("unauthenticated");
                var cursor  = CreateFailingResultCursor(failure, 2, 5);
                var result  = new InternalRxResult(Observable.Return(cursor));

                VerifyKeys(result, "key01", "key02");
            }
            public void ShouldErrorOnSummary()
            {
                var failure = new DatabaseException("code", "message");
                var cursor  = CreateFailingResultCursor(failure, 2, 5);
                var result  = new InternalRxResult(Observable.Return(cursor));

                VerifyError(result.Consume(), failure);
            }
            public void ShouldErrorOnRecords()
            {
                var exc    = new ClientException("some error");
                var cursor = CreateFailingResultCursor(exc);
                var result = new InternalRxResult(Observable.Return(cursor));

                VerifyError(result.Records(), exc);
            }
            public void ShouldNotReturnRecordsIfSummaryIsObserved()
            {
                var cursor = CreateResultCursor(3, 0, "my query");
                var result = new InternalRxResult(Observable.Return(cursor));

                VerifySummary(result, "my query");
                VerifyResultConsumedError(result.Records());
            }
            public void ShouldNotReturnRecordsIfRecordsIsAlreadyObserved()
            {
                var keys   = new[] { "key01", "key02", "key03" };
                var cursor = CreateResultCursor(3, 5);
                var result = new InternalRxResult(Observable.Return(cursor));

                VerifyRecords(result, keys, 5);
                VerifyResultConsumedError(result.Records());
            }
            public void ShouldReturnKeysAfterSummary()
            {
                var keys   = new[] { "key01", "key02", "key03" };
                var cursor = CreateResultCursor(3, 0);
                var result = new InternalRxResult(Observable.Return(cursor));

                VerifySummary(result);
                VerifyKeys(result, keys);
            }
            public void ShouldReturnRecords()
            {
                var keys    = new[] { "key01", "key02" };
                var failure = new DatabaseException("code", "message");
                var cursor  = CreateFailingResultCursor(failure, 2, 5);
                var result  = new InternalRxResult(Observable.Return(cursor));

                VerifyRecordsAndError(result, keys, 5, failure);
            }
            public void ShouldErrorOnKeysRecordsAndButNotOnSummary()
            {
                var exc    = new ClientException("some error");
                var cursor = CreateFailingResultCursor(exc);
                var result = new InternalRxResult(Observable.Return(cursor));

                VerifyError(result.Keys(), exc);
                VerifyError(result.Records(), exc);
                VerifyNoError(result.Consume());
            }
            public void ShouldReturnKeysRecordsAndSummary()
            {
                var keys   = new[] { "key01", "key02", "key03" };
                var cursor = CreateResultCursor(3, 5, "my query");
                var result = new InternalRxResult(Observable.Return(cursor));

                VerifyKeys(result, keys);
                VerifyRecords(result, keys, 5);
                VerifySummary(result, "my query");
            }
            public void ShouldErrorOnRecordsRepeatable()
            {
                var exc    = new ClientException("some error");
                var cursor = CreateFailingResultCursor(exc);
                var result = new InternalRxResult(Observable.Return(cursor), new TestLogger(Output.WriteLine));

                VerifyError(result.Records(), exc);

                VerifyResultConsumedError(result.Records());
                VerifyResultConsumedError(result.Records());
            }
            public void ShouldNotAllowConcurrentRecordObservers()
            {
                var cursor = CreateResultCursor(3, 20, "my query", 1000);
                var result = new InternalRxResult(Observable.Return(cursor));

                result.Records()
                .Merge(result.Records())
                .WaitForCompletion()
                .AssertEqual(
                    OnError <IRecord>(0, MatchesException <ClientException>()));
            }