Example #1
0
            public WhenCallingCreateCommand_WithConnectionScopePerSession_AndThereIsNoTransaction()
            {
                this.mockDbDriver.Setup(x => x.CreateConnection()).Returns(this.mockConnection.Object);
                this.mockDbDriver.Setup(x => x.BuildCommand(sqlQuery)).Returns(this.mockCommand.Object);

                var sessionBase = new TestSessionBase(ConnectionScope.PerSession, this.mockDbDriver.Object);

                sessionBase.CallCreateCommand(sqlQuery);
            }
Example #2
0
            public WhenCallingConfigureCommand_WithConnectionScopePerTransaction_ThereIsNoTransaction_AndTheConnectionIsClosed()
            {
                this.mockConnection.Setup(x => x.State).Returns(ConnectionState.Closed);

                this.mockDbDriver.Setup(x => x.CreateConnection()).Returns(this.mockConnection.Object);
                this.mockConnection.Setup(x => x.CreateCommand()).Returns(this.mockCommand.Object);

                var sessionBase = new TestSessionBase(ConnectionScope.PerTransaction, this.mockDbDriver.Object);

                sessionBase.CallConfigureCommand(sqlQuery);
            }
Example #3
0
            public WhenCallingCommandCompleted_WithConnectionScopePerTransaction_ThereIsNoTransaction_AndTheConnectionIsOpen()
            {
                this.mockConnection.Setup(x => x.State).Returns(ConnectionState.Open);

                var mockDbDriver = new Mock <IDbDriver>();

                mockDbDriver.Setup(x => x.CreateConnection()).Returns(mockConnection.Object);

                var sessionBase = new TestSessionBase(ConnectionScope.PerTransaction, mockDbDriver.Object);

                sessionBase.CallCommandCompleted();
            }
Example #4
0
            public WhenCallingDispose_AndTheConnectionScopeIsPerTransaction()
            {
                this.mockConnection.Setup(x => x.CreateCommand()).Returns(this.mockCommand.Object);

                var mockDbDriver = new Mock <IDbDriver>();

                mockDbDriver.Setup(x => x.CreateConnection()).Returns(this.mockConnection.Object);

                this.sessionBase = new TestSessionBase(ConnectionScope.PerTransaction, mockDbDriver.Object);
                this.sessionBase.CallConfigureCommand(new SqlQuery(""));
                this.sessionBase.Dispose();
            }
Example #5
0
            public WhenCallingConfigureCommand_WithConnectionScopePerSession_AndThereIsATransaction()
            {
                this.mockConnection.Setup(x => x.BeginTransaction(It.IsAny <IsolationLevel>())).Returns(this.mockTransaction.Object);
                this.mockConnection.Setup(x => x.CreateCommand()).Returns(this.mockCommand.Object);

                this.mockDbDriver.Setup(x => x.CreateConnection()).Returns(this.mockConnection.Object);

                var sessionBase = new TestSessionBase(ConnectionScope.PerSession, this.mockDbDriver.Object);

                sessionBase.BeginTransaction();
                sessionBase.CallConfigureCommand(sqlQuery);
            }
Example #6
0
            public WhenCallingCreateCommand_WithConnectionScopePerTransaction_ThereIsNoTransaction_AndTheConnectionIsClosed()
            {
                this.mockConnection.Setup(x => x.State).Returns(ConnectionState.Closed);

                this.mockDbDriver.Setup(x => x.GetConnection(ConnectionScope.PerTransaction)).Returns(this.mockConnection.Object);
                this.mockDbDriver.Setup(x => x.BuildCommand(sqlQuery)).Returns(this.mockCommand.Object);

                var sessionBase = new TestSessionBase(ConnectionScope.PerTransaction, this.mockDbDriver.Object);
                sessionBase.CallCreateCommand(sqlQuery);
            }
Example #7
0
            public WhenCallingCreateCommand_WithConnectionScopePerSession_AndThereIsATransaction()
            {
                this.mockConnection.Setup(x => x.BeginTransaction(It.IsAny<IsolationLevel>())).Returns(this.mockTransaction.Object);

                this.mockDbDriver.Setup(x => x.GetConnection(ConnectionScope.PerSession)).Returns(this.mockConnection.Object);
                this.mockDbDriver.Setup(x => x.BuildCommand(sqlQuery)).Returns(this.mockCommand.Object);

                var sessionBase = new TestSessionBase(ConnectionScope.PerSession, this.mockDbDriver.Object);
                sessionBase.BeginTransaction();
                sessionBase.CallCreateCommand(sqlQuery);
            }
Example #8
0
            public WhenCallingCommandCompleted_WithConnectionScopePerTransaction_ThereIsNoTransaction_AndTheConnectionIsOpen()
            {
                this.mockConnection.Setup(x => x.State).Returns(ConnectionState.Open);

                var mockDbDriver = new Mock<IDbDriver>();
                mockDbDriver.Setup(x => x.GetConnection(ConnectionScope.PerTransaction)).Returns(mockConnection.Object);

                var sessionBase = new TestSessionBase(ConnectionScope.PerTransaction, mockDbDriver.Object);
                sessionBase.CallCommandCompleted();
            }
            public WhenCallingDispose_AndTheConnectionScopeIsPerTransaction()
            {
                this.mockConnection.Setup(x => x.CreateCommand()).Returns(this.mockCommand.Object);

                var mockDbDriver = new Mock<IDbDriver>();
                mockDbDriver.Setup(x => x.CreateConnection()).Returns(this.mockConnection.Object);

                this.sessionBase = new TestSessionBase(ConnectionScope.PerTransaction, mockDbDriver.Object);
                this.sessionBase.CallConfigureCommand(new SqlQuery(""));
                this.sessionBase.Dispose();
            }
            public WhenCallingConfigureCommand_WithConnectionScopePerTransaction_ThereIsATransaction_AndTheConnectionIsClosed()
            {
                this.mockConnection.Setup(x => x.State).Returns(ConnectionState.Closed);
                this.mockConnection.Setup(x => x.BeginTransaction(It.IsAny<IsolationLevel>())).Returns(this.mockTransaction.Object);
                this.mockConnection.Setup(x => x.CreateCommand()).Returns(this.mockCommand.Object);

                this.mockDbDriver.Setup(x => x.CreateConnection()).Returns(this.mockConnection.Object);

                var sessionBase = new TestSessionBase(ConnectionScope.PerTransaction, this.mockDbDriver.Object);
                sessionBase.BeginTransaction();
                sessionBase.CallConfigureCommand(sqlQuery);
            }
            public WhenCallingConfigureCommand_WithConnectionScopePerSession_AndThereIsNoTransaction()
            {
                this.mockDbDriver.Setup(x => x.CreateConnection()).Returns(this.mockConnection.Object);
                this.mockConnection.Setup(x => x.CreateCommand()).Returns(this.mockCommand.Object);

                var sessionBase = new TestSessionBase(ConnectionScope.PerSession, this.mockDbDriver.Object);
                sessionBase.CallConfigureCommand(sqlQuery);
            }