Пример #1
0
        public void SessionImpl_Disposes_Connection_On_Dispose()
        {
            var fixture = new PersistenceAdapterFixture();
            var session = new SessionImpl(fixture.Connection);

            session.Dispose();

            fixture.ConnectionMock.Verify(c => c.Dispose());
        }
Пример #2
0
        public void SessionImpl_Raises_InvalidOperationException_If_Connection_Is_Closed_On_Close()
        {
            var fixture = new PersistenceAdapterFixture();

            fixture.ConnectionMock.Setup(c => c.State).Returns(ConnectionState.Closed);

            using (var session = new SessionImpl(fixture.Connection))
                AssertRaise <InvalidOperationException>(() => { session.Close(); });
        }
Пример #3
0
        public void SessionImpl_Raises_OperationInvalidException_If_Connection_Has_Already_Been_Opened_On_Open()
        {
            var fixture = new PersistenceAdapterFixture();

            fixture.ConnectionMock.Setup(c => c.State).Returns(ConnectionState.Open);

            using (var session = new SessionImpl(fixture.Connection))
                AssertRaise <InvalidOperationException>(() => { session.Open(); });
        }
Пример #4
0
        public void SessionFactoryImpl_Can_Set_Persistence_Adapter()
        {
            var fixture = new PersistenceAdapterFixture();
            var factory = new SessionFactoryImpl();

            Assert.IsNull(factory.Adapter);

            Assert.AreEqual(factory, factory.SetAdapter(fixture.PersistenceAdapter));
            Assert.AreEqual(fixture.PersistenceAdapter, factory.Adapter);
        }
Пример #5
0
        public void SessionFactoryImpl_Can_Open_Session()
        {
            var fixture = new PersistenceAdapterFixture();
            var session = new SessionFactoryImpl()
                          .SetConnectionString("test")
                          .SetAdapter(fixture.PersistenceAdapter)
                          .OpenSession();

            Assert.IsNotNull(session);
            Assert.AreEqual(fixture.Connection, session.Connection);
        }
Пример #6
0
        public void SessionImpl_Can_Be_Closed()
        {
            var fixture = new PersistenceAdapterFixture();

            fixture.ConnectionMock.Setup(c => c.State).Returns(ConnectionState.Open);

            using (var session = new SessionImpl(fixture.Connection))
                session.Close();

            fixture.ConnectionMock.Verify(c => c.Close());
        }