public void When_Paging_Should_Affect_The_Base_Query_Before_It_Is_Executed() { //Arrange var targetFoo = new Foo { Name = "Test" }; var context = MockRepository.GenerateStrictMock <IDataContext>(); context.Expect(x => x.AsQueryable <Foo>()).Return(new List <Foo> { new Foo(), new Foo(), new Foo(), new Foo(), targetFoo }.AsQueryable()).Repeat.Once(); var query = new FindFooName(); //Act IEnumerable <string> retVal = query.Skip(4).Take(1).Execute(context); //Assert retVal.First().Should().Be(targetFoo.Name); }
public void When_Calling_Output_Sql_with_Context_It_Outputs_SQL() { //arrange var target = new FindFooName(); var context = container.Resolve <IDataContext>(); //act string sqlOutput = target.OutputQuery(context); //assert sqlOutput.Should().NotBeNull(); sqlOutput.Should().Contain("FROM"); }
public void When_Executed_Returns_An_IEnumerable_Of_Items() { //Arrange var context = MockRepository.GenerateStrictMock<IDataContext>(); context.Expect(x => x.AsQueryable<Foo>()).Return(new List<Foo>().AsQueryable()).Repeat.Once(); var query = new FindFooName(); //Act IEnumerable<string> items = query.Execute(context); //Assert context.VerifyAllExpectations(); items.ShouldNotBeNull(); }
public void When_Executed_Returns_An_IEnumerable_Of_Items() { //Arrange var context = MockRepository.GenerateStrictMock <IDataContext>(); context.Expect(x => x.AsQueryable <Foo>()).Return(new List <Foo>().AsQueryable()).Repeat.Once(); var query = new FindFooName(); //Act IEnumerable <string> items = query.Execute(context); //Assert context.VerifyAllExpectations(); items.Should().NotBeNull(); }
public void When_Paging_Should_Affect_The_Base_Query_Before_It_Is_Executed() { //Arrange var targetFoo = new Foo {Name = "Test"}; var context = MockRepository.GenerateStrictMock<IDataContext>(); context.Expect(x => x.AsQueryable<Foo>()).Return(new List<Foo> { new Foo(), new Foo(), new Foo(), new Foo(), targetFoo }.AsQueryable()).Repeat.Once(); var query = new FindFooName(); //Act IEnumerable<string> retVal = query.Skip(4).Take(1).Execute(context); //Assert retVal.First().Should().Be(targetFoo.Name); }
public void When_Calling_Output_Sql_with_Context_It_Outputs_SQL() { //arrange var target = new FindFooName(); var context = container.Resolve<IDataContext>(); //act string sqlOutput = target.OutputSQLStatement(context); //assert sqlOutput.ShouldNotBeNull(); sqlOutput.ShouldContain("from"); }