public void Will_get_unexpect_error()
        {
            var stubConnection = MockRepository.GenerateStub<IDbConnection>();
            var mockCommand = MockRepository.GenerateMock<IDbCommand>();
            mockCommand.Expect(c => c.Connection = stubConnection);
            mockCommand.Expect(c => c.Connection = null);
            mockCommand.Stub(c => c.ExecuteNonQuery()).Throw(new TestException());

            var executor = new Executor(stubConnection);
            try
            {
                executor.ExecuteNonQuery(mockCommand);
                Assert.False(true, "exception was expected");
            }
            catch (TestException)
            {
            }

            Assert.Throws<ExpectationViolationException>("IDbCommand.set_Connection(null); Expected #1, Actual #0.", () => mockCommand.VerifyAllExpectations());
        }
        public void Will_get_unexpect_error()
        {
            var stubConnection = MockRepository.GenerateStub<IDbConnection>();
            var mockCommand = MockRepository.GenerateMock<IDbCommand>();
            mockCommand.Expect(c => c.Connection = stubConnection);
            mockCommand.Expect(c => c.Connection = null);
            mockCommand.Stub(c => c.ExecuteNonQuery()).Throw(new TestException());

            var executor = new Executor(stubConnection);
            try
            {
                executor.ExecuteNonQuery(mockCommand);
                Assert.Fail("exception was expected");
            }
            catch (TestException)
            {
            }

            mockCommand.VerifyAllExpectations();
        }