public void Query_NotExecuted() { var runner = RunnerFactory.Create(); var result = runner.Query(new QueryNotExecuted()); result.Should().BeNullOrEmpty(); }
public void Query_Executed() { var runner = RunnerFactory.Create(); var result = runner.Query(new QueryExecuted()); result.Should().Be("TEST"); }
public void SqlQuery_Combine_string() { var runner = RunnerFactory.Create(); var query = SqlQuery.Combine("SELECT 'TEST'", r => r.AsEnumerable <string>().First()); var result = runner.Query(query); result.Should().Be("TEST"); }
public void TestQuery1_Test() { var target = RunnerFactory.Create(); var result = target.Query(new TestQuery1()); result.TestInt.Should().Be(5); result.TestString.Should().Be("TEST"); }
public void StreamingResults_Query() { var runner = RunnerFactory.Create(); var stream = runner.QueryStream(new Query()); var result = stream.AsEnumerable <int>().ToList(); result.Should().ContainInOrder(1, 2, 3); stream.Dispose(); }
public void MapOnto_MappedTest() { var target = RunnerFactory.Create(); var result = target.Query(new MapOntoQuery_MappedRecord()); result.Id.Should().Be(1); result.Name.Should().Be("TEST"); result.Value.Should().Be("VALUE"); }
public void SqlQuery_PerformanceReport() { string report = null; var runner = RunnerFactory.Create(b => b.MonitorPerformance(s => report = s)); var result = runner.Query(new Query()); result.Should().Be("TEST"); report.Should().NotBeNull(); }
public async Task StreamingResultsSimpleAsync() { var runner = RunnerFactory.Create(); var stream = await runner.QueryStreamAsync("SELECT 1 UNION SELECT 2 UNION SELECT 3"); var result = stream.AsEnumerable <int>().ToList(); result.Should().ContainInOrder(1, 2, 3); stream.Dispose(); }
public void Batch_SimpleSql() { var runner = RunnerFactory.Create(); var batch = runner.CreateBatch(); var result = batch.Add <string>("SELECT 'TEST';"); runner.Execute(batch); var list = result.GetValue(); list.Count.Should().Be(1); list[0].Should().Be("TEST"); }
public async Task CommandAndQueryBatch_AsTask() { var runner = RunnerFactory.Create(); var batch = runner.CreateBatch(); var promise = batch.Add(new QuerySimpleQuery()); var task = promise.AsTask(TimeSpan.FromSeconds(10)); runner.Execute(batch); var result = await task; result.Should().Be("TEST"); }
public async Task AsyncStreamResults_Tests() { var runner = RunnerFactory.Create(); var stream = runner.QueryStream("SELECT 1 UNION SELECT 2 UNION SELECT 3"); var result = stream.AsEnumerableAsync <int>(); var sum = 0; await foreach (var i in result) { sum += i; } sum.Should().Be(6); }
public void Query2_Stringify() { var runner = RunnerFactory.Create(); var parameters = new QueryValues { Value1 = 5, Value2 = 3.14f, Value3 = "TEST" }; var query = new Query(parameters); var result = runner.ObjectStringifier.Stringify(query); result.Should().NotBeNullOrEmpty(); }
public void ParameterObject_Test() { var runner = RunnerFactory.Create(); var parameters = new QueryValues { Value1 = 5, Value2 = 3.14f, Value3 = "TEST" }; var result = runner.Query(new Query(parameters)); result.Value1.Should().Be(5); result.Value2.Should().Be(3.14f); result.Value3.Should().Be("TEST"); }
public void CommandAndQueryBatch_Transaction() { var runner = RunnerFactory.Create(b => b.UseTransaction(IsolationLevel.Serializable)); var batch = runner.CreateBatch(); batch.Add(new CreateTempTableCommand()); var result = batch.Add(new QueryTempTableQuery()); runner.Execute(batch); result.IsComplete.Should().Be(true); var list = result.GetValue(); list.Should().NotBeNull(); list.Should().BeEquivalentTo(1, 3, 5, 7); }
public void SqlQuery_Combine_string_Cached() { // Quick test for cacheMappings=true // We can't really test at this level that the cache was correctly utilized, but we can // test that repeated invocations don't break. Evidence that, at least, the cache // isn't making things stop working. var runner = RunnerFactory.Create(); var query = SqlQuery.Combine("SELECT 'TEST'", r => r.AsEnumerable <string>().First(), true); var result = runner.Query(query); result.Should().Be("TEST"); // Run it again, to make sure it still works result = runner.Query(query); result.Should().Be("TEST"); }
public void CommandAndQueryBatch_SimpleSql() { var runner = RunnerFactory.Create(); var batch = runner.CreateBatch(); batch.Add(@" CREATE TEMPORARY TABLE castiron_test ( [Value] INT NOT NULL ); INSERT INTO castiron_test ([Value]) VALUES (1),(3),(5),(7);"); var result = batch.Add <int>("SELECT * FROM castiron_test;"); runner.Execute(batch); result.IsComplete.Should().Be(true); var list = result.GetValue(); list.Should().NotBeNull(); list.Should().BeEquivalentTo(1, 3, 5, 7); }