public ISessionFactory CreateSessionFactory() { lock (locker) { var sessionFactory = Configure.SessionFactories.SingleOrDefault(s => s.ConnectionName == this.chosenConnectionName); if (sessionFactory == null) { if (this.log.IsDebug) { this.log.Debug( LogMessages.FluentConfiguration_CreatingSessionFactory, this.chosenConnectionName, this.chosenDbDriver.GetType().Name, this.chosenSqlDialect.GetType().Name); } sessionFactory = new SessionFactory(this.chosenConnectionName, this.chosenDbDriver, this.chosenSqlDialect); if (this.sessionFactoryCreated != null) { sessionFactory = this.sessionFactoryCreated(sessionFactory); } Configure.SessionFactories.Add(sessionFactory); } return sessionFactory; } }
public WhenCallingOpenAsyncReadOnlySession_MultipleTimes() { var sessionFactory = new SessionFactory("SqlConnection", new Mock<IDbDriver>().Object, new Mock<ISqlDialect>().Object); this.readOnlyAsyncSession1 = sessionFactory.OpenAsyncReadOnlySession(); this.readOnlyAsyncSession2 = sessionFactory.OpenAsyncReadOnlySession(); }
public WhenCallingOpenReadOnlySession_SpecifyingConnectionScope() { var mockDbDriver = new Mock<IDbDriver>(); mockDbDriver.Setup(x => x.GetConnection(ConnectionScope.PerSession)); var sessionFactory = new SessionFactory("SqlConnection", mockDbDriver.Object, new Mock<ISqlDialect>().Object); this.readOnlySession = sessionFactory.OpenReadOnlySession(ConnectionScope.PerSession); }
public WhenCallingOpenAsyncReadOnlySession() { var mockDbDriver = new Mock<IDbDriver>(); mockDbDriver.Setup(x => x.CreateConnection()); var mockSqlDialect = new Mock<ISqlDialect>(); mockSqlDialect.Setup(x => x.SqlCharacters).Returns(this.sqlCharacters); var sessionFactory = new SessionFactory("SqlConnection", mockDbDriver.Object, mockSqlDialect.Object); this.readOnlyAsyncSession = sessionFactory.OpenAsyncReadOnlySession(); }
public WhenConstructed() { this.sessionFactory = new SessionFactory(this.connectionName, this.dbDriver, this.sqlDialect); }
public WhenCallingOpenSession_SpecifyingConnectionScope() { var mockDbDriver = new Mock<IDbDriver>(); mockDbDriver.Setup(x => x.CreateConnection()).Returns(new Mock<IDbConnection>().Object); var mockSqlDialect = new Mock<ISqlDialect>(); mockSqlDialect.Setup(x => x.SqlCharacters).Returns(this.sqlCharacters); var sessionFactory = new SessionFactory("SqlConnection", mockDbDriver.Object, mockSqlDialect.Object); this.session = sessionFactory.OpenSession(ConnectionScope.PerSession); }
public WhenCallingOpenSession() { var sessionFactory = new SessionFactory("SqlConnection", new Mock<IDbDriver>().Object, new Mock<ISqlDialect>().Object); this.session = sessionFactory.OpenSession(); }