Пример #1
0
        public void TestCopyFileToConnection()
        {
            var file1 = Path.GetTempFileName();

            File.WriteAllText(file1, "f1,f2,f3\nv1,v2,v3");

            var element = new ProcessBuilder("CopyFile")
                          .Connection("output")
                          .Provider("SqlServer")
                          .Database("TestOutput")
                          .Action("Copy")
                          .From(file1)
                          .To("output")
                          .Process();

            var process = ProcessFactory.CreateSingle(element, new TestLogger());

            process.ExecuteScaler();
            var expected  = Common.CleanIdentifier(Path.GetFileNameWithoutExtension(file1));
            var sqlServer = element.GetDefaultOf <TflConnection>(c => {
                c.Name     = "test";
                c.Provider = "sqlserver";
                c.Database = "TestOutput";
            }).Connection;

            var rows = sqlServer.GetConnection().Query(string.Format("SELECT f1, f2, f3 FROM {0}", expected)).ToArray();

            Assert.AreEqual(1, rows.Length);
            Assert.AreEqual("v1", rows[0].f1);
            Assert.AreEqual("v2", rows[0].f2);
            Assert.AreEqual("v3", rows[0].f3);
        }