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()); }
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(); }); }
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(); }); }
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); }
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); }
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()); }