Esempio n. 1
0
        public void SetupScenerio()
        {
            var dbSource = SqlServerTestUtils.CreateDev2TestingDbSource();

            ResourceCatalog.Instance.SaveResource(Guid.Empty, dbSource, "");
            scenarioContext.Add("dbSource", dbSource);

            var sqlBulkInsert = new DsfSqlBulkInsertActivity();

            sqlBulkInsert.Database  = dbSource;
            sqlBulkInsert.TableName = "SqlBulkInsertSpecFlowTestTable_for_" + scenarioContext.ScenarioInfo.Title.Replace(' ', '_');
            if (scenarioContext.ScenarioInfo.Title.Replace(' ', '_') == "Import_data_into_Table_Batch_size_is_1")
            {
                var tableNameUniqueNameGuid = CommonSteps.GetGuid();
                CreateIsolatedSQLTable(tableNameUniqueNameGuid);
                scenarioContext.Add("tableNameUniqueNameGuid", tableNameUniqueNameGuid);
                sqlBulkInsert.TableName += "_" + tableNameUniqueNameGuid;
            }
            var dataColumnMappings = new List <DataColumnMapping>
            {
                new DataColumnMapping
                {
                    InputColumn  = "[[rs(*).Col1]]",
                    OutputColumn = new DbColumn
                    {
                        ColumnName = "Col1",
                        DataType   = typeof(Int32),
                        MaxLength  = 100
                    },
                },
                new DataColumnMapping
                {
                    InputColumn  = "[[rs(*).Col2]]",
                    OutputColumn = new DbColumn
                    {
                        ColumnName = "Col2",
                        DataType   = typeof(String),
                        MaxLength  = 100
                    }
                },
                new DataColumnMapping
                {
                    InputColumn  = "[[rs(*).Col3]]",
                    OutputColumn = new DbColumn
                    {
                        ColumnName = "Col3",
                        DataType   = typeof(Guid),
                        MaxLength  = 100
                    }
                }
            };

            sqlBulkInsert.InputMappings = dataColumnMappings;
            TestStartNode = new FlowStep
            {
                Action = sqlBulkInsert
            };

            scenarioContext.Add("activity", sqlBulkInsert);
        }