public void ShouldDelegateToAsyncSession()
            {
                var asyncSession = new Mock <IInternalAsyncSession>();
                var rxSession    = new InternalRxSession(asyncSession.Object, Mock.Of <IRxRetryLogic>());

                var bookmark = rxSession.SessionConfig;

                asyncSession.Verify(x => x.SessionConfig, Times.Once);
            }
            public void ShouldInvokeSessionCloseAsync()
            {
                var asyncSession = new Mock <IInternalAsyncSession>();
                var rxSession    = new InternalRxSession(asyncSession.Object, Mock.Of <IRxRetryLogic>());

                var close = rxSession.Close <Unit>();

                asyncSession.Verify(x => x.CloseAsync(), Times.Never);

                close.WaitForCompletion();

                asyncSession.Verify(x => x.CloseAsync(), Times.Once);
            }
            public void ShouldReturnObservable()
            {
                var session = new Mock <IInternalAsyncSession>();

                session.Setup(x => x.BeginTransactionAsync(It.IsAny <Action <TransactionConfigBuilder> >(), It.IsAny <bool>()))
                .ReturnsAsync(Mock.Of <IInternalAsyncTransaction>());

                var rxSession = new InternalRxSession(session.Object, Mock.Of <IRxRetryLogic>());

                rxSession.BeginTransaction().WaitForCompletion()
                .AssertEqual(
                    OnNext(0, Matches <IRxTransaction>(t => t.Should().BeOfType <InternalRxTransaction>())),
                    OnCompleted <IRxTransaction>(0));
                session.Verify(x => x.BeginTransactionAsync(It.IsAny <Action <TransactionConfigBuilder> >(), It.IsAny <bool>()), Times.Once);
            }
示例#4
0
            private static void VerifyLazyRunAsync(Action <IRxStatementResult> action)
            {
                var asyncSession = new Mock <IInternalAsyncSession>();

                asyncSession.Setup(x => x.RunAsync(It.IsAny <Statement>(), It.IsAny <Action <TransactionConfigBuilder> >()))
                .ReturnsAsync(new ListBasedRecordCursor(new[] { "x" }, Enumerable.Empty <IRecord>,
                                                        Mock.Of <IResultSummary>));
                var session = new InternalRxSession(asyncSession.Object, Mock.Of <IRxRetryLogic>());
                var result  = session.Run("RETURN 1");

                asyncSession.Verify(
                    x => x.RunAsync(It.IsAny <Statement>(), It.IsAny <Action <TransactionConfigBuilder> >()), Times.Never);

                action(result);

                asyncSession.Verify(
                    x => x.RunAsync(It.IsAny <Statement>(), It.IsAny <Action <TransactionConfigBuilder> >()), Times.Once);
            }
            public void ShouldReturnInternalRxResult()
            {
                var rxSession = new InternalRxSession(Mock.Of <IInternalAsyncSession>(), Mock.Of <IRxRetryLogic>());

                rxSession.Run("RETURN 1").Should().BeOfType <RxResult>();
            }