public void should_get_it_from_session_scope() { //arrange A.CallTo(() => SessionScope.AsQueryable <TestEntity>()).Returns(A.Dummy <IQueryable <TestEntity> >()); //act var result = Repository.AsQueryable(); //assert A.CallTo(() => SessionScope.AsQueryable <TestEntity>()).MustHaveHappened(Repeated.Exactly.Once); result.Should().NotBeNull(); }
public void UsingLinqViaSessionScopeVariable() { ActiveRecordStarter.Initialize(GetConfigSource(), typeof(Widget)); using (ISessionScope scope = new SessionScope()) { Recreate(); Widget.DeleteAll(); var widgets = from w in scope.AsQueryable <Widget>() select w; Assert.IsNotNull(widgets); Assert.AreEqual(0, widgets.Count()); Widget widget = new Widget { Name = "Hello world" }; widget.Save(); widgets = from w in scope.AsQueryable <Widget>() where w.Name == "Hello World" select w; Assert.IsNotNull(widgets); Assert.AreEqual(1, widgets.Count()); } }
public void UsingLinqViaSessionScopeVariable() { ActiveRecordStarter.Initialize(GetConfigSource(), typeof(Widget)); using (ISessionScope scope = new SessionScope()) { Recreate(); Widget.DeleteAll(); var widgets = from w in scope.AsQueryable<Widget>() select w; Assert.IsNotNull(widgets); Assert.AreEqual(0, widgets.Count()); Widget widget = new Widget { Name = "Hello world" }; widget.Save(); widgets = from w in scope.AsQueryable<Widget>() where w.Name == "Hello World" select w; Assert.IsNotNull(widgets); Assert.AreEqual(1, widgets.Count()); } }