public void ShouldGetConnectionNoOpenTest()
        {
            Mockery mockery;
            MockAdoNetAmbientAware ambientAware;
            IConnectionFactory mockConnectionFactory;
            IDbConnection mockDbConnection;

            mockery = new Mockery();
            mockConnectionFactory = mockery.NewMock<IConnectionFactory>();
            mockDbConnection = mockery.NewMock<IDbConnection>();

            Expect.Once.On(mockConnectionFactory).Method("GetConnection").Will(Return.Value(mockDbConnection));

            ambientAware = new MockAdoNetAmbientAware(MOCK_CONNECTION_STRING, mockConnectionFactory);

            ambientAware.BypassGetConnection(false);

            mockery.VerifyAllExpectationsHaveBeenMet();
        }
        public void ShouldGetConnectionWithOpenTest()
        {
            Mockery mockery;
            MockAdoNetAmbientAware ambientAware;
            IConnectionFactory mockConnectionFactory;
            IDbConnection mockDbConnection;

            mockery = new Mockery();
            mockConnectionFactory = mockery.NewMock<IConnectionFactory>();
            mockDbConnection = mockery.NewMock<IDbConnection>();

            Expect.Once.On(mockConnectionFactory).Method("GetConnection").Will(Return.Value(mockDbConnection));
            Expect.AtLeastOnce.On(mockDbConnection).SetProperty("ConnectionString").To("myConnectionString");
            Expect.AtLeastOnce.On(mockDbConnection).Method("Open").WithNoArguments();

            ambientAware = new MockAdoNetAmbientAware(MOCK_CONNECTION_STRING, mockConnectionFactory);

            ambientAware.BypassGetConnection(true);

            mockery.VerifyAllExpectationsHaveBeenMet();
        }
        public void ShouldFailOnNullConnectionGetConnectionFromFactoryTest()
        {
            Mockery mockery;
            MockAdoNetAmbientAware ambientAware;
            IConnectionFactory mockConnectionFactory;

            mockery = new Mockery();
            mockConnectionFactory = mockery.NewMock<IConnectionFactory>();

            Expect.Once.On(mockConnectionFactory).Method("GetConnection").Will(Return.Value(null));

            ambientAware = new MockAdoNetAmbientAware(MOCK_CONNECTION_STRING, mockConnectionFactory);

            ambientAware.BypassGetConnection(false);
        }