public void should_open_session() { //act UnitOfWork.Do(uow => { }); //assert A.CallTo(() => SessionScopeFactory.Open()).MustHaveHappened(); }
public void should_open_session_and_get_result() { //act var result = UnitOfWork.Do(uow => 1); //assert A.CallTo(() => SessionScopeFactory.Open()).MustHaveHappened(); result.Should().Be(1); }
public UnitOfWorkNamedStorageScenario() { SessionScopeFactory = A.Fake <ISessionScopeFactory>(); SessionScope = A.Fake <ISessionScope>(); A.CallTo(() => SessionScopeFactory.Open()).Returns(SessionScope); Func <string, ISessionScopeFactory> sessionScopeFactoryExtractor = name => (name == "SuperStorage" ? SessionScopeFactory: null); UnitOfWork.SessionScopeFactoryExtractor = sessionScopeFactoryExtractor; }
public UnitOfWorkScenario() { SessionScopeFactory = A.Fake <ISessionScopeFactory>(); SessionScope = A.Fake <ISessionScope>(); A.CallTo(() => SessionScopeFactory.Open()).Returns(SessionScope); Func <string, ISessionScopeFactory> sessionScopeFactoryExtractor = name => (name == UnitOfWorkSettings.Default.StorageName ? SessionScopeFactory : null); UnitOfWork.SessionScopeFactoryExtractor = sessionScopeFactoryExtractor; }
public void should_open_session() { //act UnitOfWork.Do(uow => { }, new UnitOfWorkSettings { StorageName = "SuperStorage" }); //assert A.CallTo(() => SessionScopeFactory.Open()).MustHaveHappened(); }
public void should_open_session() { //act var task = UnitOfWork.DoAsync(uow => { }); task.Wait(); //assert A.CallTo(() => SessionScopeFactory.Open()).MustHaveHappened(); }
public void should_not_open_new_session_and_not_commit_nested_unit_of_work() { //act UnitOfWork.Do(uow => UnitOfWork.Do(nested => { })); //assert A.CallTo(() => SessionScopeFactory.Open()).MustHaveHappened(Repeated.Exactly.Once); A.CallTo(() => SessionScope.Commit()).MustHaveHappened(Repeated.Exactly.Once); }
public void should_open_session_and_get_result() { //act var result = UnitOfWork.Do(uow => "super", new UnitOfWorkSettings { StorageName = "SuperStorage" }); //assert A.CallTo(() => SessionScopeFactory.Open()).MustHaveHappened(); result.Should().Be("super"); }