Beispiel #1
0
        public void SqlQuery_Tests()
        {
            var runner = RunnerFactory.Create();
            var result = runner.Query(new Query());

            result.Should().Be("TEST");
        }
        public void Execute_TypedOutputParameter()
        {
            var runner = RunnerFactory.Create();
            var result = runner.Execute(new CommandWithTypedOutputParameter());

            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");
        }
Beispiel #4
0
        public void SqlQuery_Combine()
        {
            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 SqlQueryRawCommand_GetParameters()
        {
            var runner = RunnerFactory.Create();
            var result = runner.Query(new CommandWithParameter());

            result.Should().NotBeNull();
            result.Value.Should().Be("TEST");
        }
Beispiel #6
0
        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");
        }
Beispiel #7
0
        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();
        }
Beispiel #8
0
        public void GetResultEnumerable_Map_Parameter()
        {
            var runner = RunnerFactory.Create();
            var result = runner.Query(new QueryWithResultSetAndParameterQuery(), new EnumerateMapParameterMaterializer());

            result.Should().NotBeNull();
            result.OutputParameterValue.Should().Be("param");
            result.ResultSetValue.Should().Be("result");
        }
Beispiel #9
0
        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();
        }
Beispiel #10
0
        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();
        }
Beispiel #11
0
        public void SqlQuery_ViewCommandBeforeExecution()
        {
            string report = null;
            var    runner = RunnerFactory.Create(b => b.ViewCommandBeforeExecution(s =>
            {
                report = s.Trim();
            }));
            var result = runner.Query(new Query());

            result.Should().Be("TEST");
            report.Should().Be("SELECT 'TEST';");
        }
Beispiel #12
0
        public void CreateAndQueryStoredProc_Test()
        {
            var runner = RunnerFactory.Create();
            var batch  = runner.CreateBatch();

            batch.Add(new CreateTempStoredProcCommand());
            var result = batch.Add(new ExecuteStoredProcQuery());

            runner.Execute(batch);

            result.IsComplete.Should().BeTrue();
            result.GetValue().Should().Be("TEST");
        }
Beispiel #13
0
        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");
        }
Beispiel #14
0
        public void 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 = task.Result;

            result.Should().Be("TEST");
        }
Beispiel #15
0
        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();
        }
Beispiel #16
0
        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");
        }
Beispiel #17
0
        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);
        }
Beispiel #18
0
        public void GetResultEnumerable_Parameter_Map()
        {
            Result Read(IDataResults result)
            {
                var results     = result.AsEnumerable <string>();
                var paramValue  = result.GetOutputParameter <string>("value");
                var firstResult = results.First();

                return(new Result
                {
                    OutputParameterValue = paramValue,
                    ResultSetValue = firstResult
                });
            }

            var    runner     = RunnerFactory.Create();
            Action getResults = () => runner.Query(new QueryWithResultSetAndParameterQuery(), Read);

            getResults.Should().Throw <SqlQueryException>();
        }
Beispiel #19
0
        public void CommandAndQueryBatch_SimpleSql()
        {
            var runner = RunnerFactory.Create();
            var batch  = runner.CreateBatch();

            batch.Add(@"
                CREATE 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);
        }