Exemplo n.º 1
0
        public void DapperReaderNode_can_perform_simple_select_and_emits_items(TestTable[] tests)
        {
            DapperExtensions.DapperExtensions.SqlDialect = new SqliteDialect();

            using (var con = new SQLiteConnection("Data Source=:memory:;Version=3;New=True;"))
            {
                con.Open();
                con.Execute("create table TestTable(Id int, Timestamp datetime, Name varchar(50));");
                foreach (var test in tests)
                {
                    con.Insert(test);
                }

                var context = new EtlPipelineContext();

                var emitter = new TestEmitter <TestTable>();
                var node    = new DapperReaderNode <TestTable>(() => con, "select Id, Timestamp, Name from TestTable;");
                node.SetEmitter(emitter);
                node.Execute(context);

                emitter.HasSignalledEnd.Should().BeTrue();
                var results = emitter.EmittedItems;
                results.Count.Should().Be(tests.Length);
                results.Should().HaveSameCount(tests);
                results.Should().BeEquivalentTo(tests, config => config.Excluding(x => x.IsFrozen));
            }
        }
Exemplo n.º 2
0
        public void DapperReaderNode_raises_error_and_signals_end_with_bad_query()
        {
            using (var con = new SQLiteConnection("Data Source=:memory:;Version=3;New=True;"))
            {
                con.Open();

                var context = new EtlPipelineContext();

                var emitter      = new TestEmitter <TestTable>();
                var errorHandler = new TestErrorHandler();
                var node         = new DapperReaderNode <TestTable>(() => con, "select Id, Timestamp, Name from TestTable;");
                node.SetEmitter(emitter).SetErrorHandler(errorHandler);
                node.Execute(context);

                errorHandler.Errors.Should().HaveCount(1);
                emitter.HasSignalledEnd.Should().BeTrue();
            }
        }