public void Should_Run_Compilation_Test_For_Context() { //Arrange Database.SetInitializer(new DropCreateDatabaseAlways <TestDataContext>()); var consoleOutLogger = new ConsoleOutLogger("Performance", LogLevel.All, true, true, true, ""); var context = new TestDataContext(Settings.Default.Connection, new FooMappingConfiguration(), consoleOutLogger); //Act IEnumerable <Foo> result = null; try { var query = new FindFoo(); context.RunStartUpPerformanceTest(query, consoleOutLogger, maxAllowableMilliseconds: -1); } catch (Exception e) { Assert.IsTrue(e.Message.Contains("Context Compilation in")); } //Assert Assert.IsNull(result); }
public void Should_Throw_An_Error_When_Query_Is_To_Slow() { //Arrange Database.SetInitializer(new CreateDatabaseIfNotExists <TestDataContext>()); var consoleOutLogger = new ConsoleOutLogger("Performance", LogLevel.All, true, true, true, ""); var context = new TestDataContext(Settings.Default.Connection, new FooMappingConfiguration(), consoleOutLogger); //Act IEnumerable <Foo> result = null; try { result = new FindFoo().RunPerformanceTest(context, consoleOutLogger, maxAllowableMilliseconds: -1); } catch (Exception e) { Console.WriteLine(e.Message); Assert.IsTrue(e.Message.Contains("FindFoo")); } //Assert Assert.IsNull(result); }
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 FindFoo(); //Act IEnumerable<Foo> items = query.Execute(context); //Assert context.VerifyAllExpectations(); items.ShouldNotBeNull(); }
public void When_Calling_Output_Sql_with_Context_It_Outputs_SQL() { //arrange var target = new FindFoo(); var context = container.Resolve <IDataContext>(); //act string sqlOutput = target.OutputSQLStatement(context); //assert sqlOutput.ShouldNotBeNull(); sqlOutput.ShouldContain("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 FindFoo(); //Act IEnumerable <Foo> items = query.Execute(context); //Assert context.VerifyAllExpectations(); items.ShouldNotBeNull(); }
public void Should_Execute_Query_With_Performance_Info() { //Arrange var consoleOutLogger = new ConsoleOutLogger("Performance", LogLevel.All, true, true, true, ""); var context = new TestDataContext(Settings.Default.Connection, new FooMappingConfiguration(), consoleOutLogger); List<Foo> nullResult = context.AsQueryable<Foo>().ToList(); //Act IEnumerable<Foo> result = null; result = new FindFoo().RunPerformanceTest(context, consoleOutLogger, false); //Assert Assert.IsNotNull(result); }
public void Should_Execute_Query_With_Performance_Info() { //Arrange Database.SetInitializer(new DropCreateDatabaseAlways <TestDataContext>()); var consoleOutLogger = new ConsoleOutLogger("Performance", LogLevel.All, true, true, true, ""); var context = new TestDataContext(Settings.Default.Connection, new FooMappingConfiguration(), consoleOutLogger); List <Foo> nullResult = context.AsQueryable <Foo>().ToList(); //Act IEnumerable <Foo> result = null; result = new FindFoo().RunPerformanceTest(context, consoleOutLogger, false); //Assert Assert.IsNotNull(result); }
public void Should_Throw_An_Error_When_Query_Is_To_Slow() { //Arrange var consoleOutLogger = new ConsoleOutLogger("Performance", LogLevel.All, true, true, true, ""); var context = new TestDataContext(Settings.Default.Connection, new FooMappingConfiguration(), consoleOutLogger); //Act IEnumerable<Foo> result = null; try { result = new FindFoo().RunPerformanceTest(context, consoleOutLogger, maxAllowableMilliseconds: -1); } catch (Exception e) { Assert.IsTrue(e.Message.Contains("Query FindFoo")); } //Assert Assert.IsNull(result); }
public void When_Paging_Should_Affect_The_Base_Query_Before_It_Is_Executed() { //Arrange var targetFoo = new Foo(); 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 FindFoo(); //Act IEnumerable<Foo> retVal = query.Skip(4).Take(1).Execute(context); //Assert retVal.First().Should().BeSameAs(targetFoo); }
public void When_Paging_Should_Affect_The_Base_Query_Before_It_Is_Executed() { //Arrange var targetFoo = new Foo(); 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 FindFoo(); //Act IEnumerable <Foo> retVal = query.Skip(4).Take(1).Execute(context); //Assert retVal.First().ShouldBeSame(targetFoo); }
public void Should_Run_Compilation_Test_For_Context() { //Arrange var consoleOutLogger = new ConsoleOutLogger("Performance", LogLevel.All, true, true, true, ""); var context = new TestDataContext(Settings.Default.Connection, new FooMappingConfiguration(), consoleOutLogger); //Act IEnumerable<Foo> result = null; try { var query = new FindFoo(); context.RunStartUpPerformanceTest(query, consoleOutLogger, maxAllowableMilliseconds: -1); } catch (Exception e) { Assert.IsTrue(e.Message.Contains("Context Compilation in")); } //Assert Assert.IsNull(result); }
public void When_Calling_Output_Sql_with_Context_It_Outputs_SQL() { //arrange var target = new FindFoo(); var context = container.Resolve<IDataContext>(); //act string sqlOutput = target.OutputSQLStatement(context); //assert sqlOutput.Should().NotBeNull(); sqlOutput.Should().Contain("FROM"); }