public virtual void ShouldPassOptionsToFactoryMethodAndReturnExpectedSession() { var actualSession = new NullOrmSession(); var actualOptions = new {}; var called = false; var builder = new OrmSessionBuilder<NullOrmSession>(options => { options.Should().Be(actualOptions); called = true; return actualSession; }); builder.BuildSession(actualOptions).Should().Be.SameInstanceAs(actualSession); called.Should().Be.True(); }
public virtual void FactoryMethodShouldBeExecutedInsideConstructionScope() { var called = false; var builder = new OrmSessionBuilder<NullOrmSession>(options => { InternalEnvironment.IsInsideConstructionScope.Should().Be.True(); called = true; return new NullOrmSession(); }); InternalEnvironment.IsInsideConstructionScope.Should().Be.False(); builder.BuildSession(); InternalEnvironment.IsInsideConstructionScope.Should().Be.False(); called.Should().Be.True(); }
public virtual void ShouldSetNameCorrectly() { var builder = new OrmSessionBuilder(options => new NullOrmSession(), "Test"); builder.BuildSession(); builder.Name.Should().Be("Test"); builder = new OrmSessionBuilder(() => new NullOrmSession(), "Test"); builder.BuildSession(); builder.Name.Should().Be("Test"); builder = new OrmSessionBuilder<NullOrmSession>(() => new NullOrmSession(), "Test"); builder.BuildSession(); builder.Name.Should().Be("Test"); builder = new OrmSessionBuilder<NullOrmSession>(options => new NullOrmSession()); builder.BuildSession(); builder.Name.Should().Be(typeof (NullOrmSession).FullName); builder = new OrmSessionBuilder<NullOrmSession>(() => new NullOrmSession()); builder.BuildSession(); builder.Name.Should().Be(typeof (NullOrmSession).FullName); }