コード例 #1
0
        public void TestChangeErrorOutputAddColumn()
        {
            Microsoft.SqlServer.Dts.Runtime.Package package = new Microsoft.SqlServer.Dts.Runtime.Package();
            Executable exec = package.Executables.Add("STOCK:PipelineTask");

            Microsoft.SqlServer.Dts.Runtime.TaskHost thMainPipe = exec as Microsoft.SqlServer.Dts.Runtime.TaskHost;
            MainPipe dataFlowTask        = thMainPipe.InnerObject as MainPipe;
            ComponentEventHandler events = new ComponentEventHandler();

            dataFlowTask.Events = DtsConvert.GetExtendedInterface(events as IDTSComponentEvents);

            IDTSComponentMetaData100 textFileSplitter = dataFlowTask.ComponentMetaDataCollection.New();

            textFileSplitter.Name             = "Row Splitter Test";
            textFileSplitter.ComponentClassID = typeof(Martin.SQLServer.Dts.TextFileSplitter).AssemblyQualifiedName;
            CManagedComponentWrapper instance = textFileSplitter.Instantiate();

            instance.ProvideComponentProperties();

            Boolean exceptionThrown = false;

            try
            {
                instance.InsertOutputColumnAt(textFileSplitter.OutputCollection[1].ID, 0, "New Error Message", String.Empty);
            }
            catch (COMException ex)
            {
                Assert.AreEqual(MessageStrings.CantChangeOutputProperties("Error"), ex.Message, "Exception Message Wrong");
                exceptionThrown = true;
            }

            Assert.IsTrue(exceptionThrown, "Exception Not Thrown");
        }
コード例 #2
0
        public void TestSetOutputColumnDefaults()
        {
            Microsoft.SqlServer.Dts.Runtime.Package package = new Microsoft.SqlServer.Dts.Runtime.Package();
            Executable exec = package.Executables.Add("STOCK:PipelineTask");

            Microsoft.SqlServer.Dts.Runtime.TaskHost thMainPipe = exec as Microsoft.SqlServer.Dts.Runtime.TaskHost;
            MainPipe dataFlowTask = thMainPipe.InnerObject as MainPipe;

            IDTSComponentMetaData100 textFileSplitter = dataFlowTask.ComponentMetaDataCollection.New();
            ComponentEventHandler    events           = new ComponentEventHandler();

            dataFlowTask.Events               = DtsConvert.GetExtendedInterface(events as IDTSComponentEvents);
            textFileSplitter.Name             = "Row Splitter Test";
            textFileSplitter.ComponentClassID = typeof(Martin.SQLServer.Dts.TextFileSplitter).AssemblyQualifiedName;
            CManagedComponentWrapper instance = textFileSplitter.Instantiate();

            instance.ProvideComponentProperties();
            IDTSOutput100       output = textFileSplitter.OutputCollection.New();
            IDTSOutputColumn100 actual = output.OutputColumnCollection.New();

            ManageColumns.SetOutputColumnDefaults(actual, 1252);

            Assert.AreEqual(DataType.DT_STR, actual.DataType, "DataType is wrong");
            Assert.AreEqual(255, actual.Length, "Length is wrong");
            Assert.AreEqual(DTSRowDisposition.RD_NotUsed, actual.ErrorRowDisposition, "Row Disposition is wrong");
            Assert.AreEqual(DTSRowDisposition.RD_NotUsed, actual.TruncationRowDisposition, "Truncate Disposition is wrong");
        }
コード例 #3
0
        public void TestAddNumberOfRowsOutputColumns()
        {
            Microsoft.SqlServer.Dts.Runtime.Package package = new Microsoft.SqlServer.Dts.Runtime.Package();
            Executable exec = package.Executables.Add("STOCK:PipelineTask");

            Microsoft.SqlServer.Dts.Runtime.TaskHost thMainPipe = exec as Microsoft.SqlServer.Dts.Runtime.TaskHost;
            MainPipe dataFlowTask = thMainPipe.InnerObject as MainPipe;

            IDTSComponentMetaData100 textFileSplitter = dataFlowTask.ComponentMetaDataCollection.New();
            ComponentEventHandler    events           = new ComponentEventHandler();

            dataFlowTask.Events               = DtsConvert.GetExtendedInterface(events as IDTSComponentEvents);
            textFileSplitter.Name             = "Row Splitter Test";
            textFileSplitter.ComponentClassID = typeof(Martin.SQLServer.Dts.TextFileSplitter).AssemblyQualifiedName;
            CManagedComponentWrapper instance = textFileSplitter.Instantiate();

            instance.ProvideComponentProperties();
            IDTSOutput100 actual = textFileSplitter.OutputCollection.New();

            ManageColumns.AddNumberOfRowsOutputColumns(actual);

            Assert.AreEqual(3, actual.OutputColumnCollection.Count, "Number of Columns is wrong");
            Assert.AreEqual(MessageStrings.KeyValueColumnName, actual.OutputColumnCollection[0].Name, "Column Name is wrong");
            Assert.AreEqual(DataType.DT_STR, actual.OutputColumnCollection[0].DataType, "DataType is wrong");
            Assert.AreEqual(255, actual.OutputColumnCollection[0].Length, "Length is wrong");
            Assert.AreEqual(MessageStrings.KeyValueColumnDescription, actual.OutputColumnCollection[0].Description, "Description is wrong");
            Assert.AreEqual(MessageStrings.NumberOfRowsColumnName, actual.OutputColumnCollection[1].Name, "Column Name is wrong");
            Assert.AreEqual(DataType.DT_I8, actual.OutputColumnCollection[1].DataType, "DataType is wrong");
            Assert.AreEqual(0, actual.OutputColumnCollection[1].Length, "Length is wrong");
            Assert.AreEqual(MessageStrings.NumberOfRowsColumnDescription, actual.OutputColumnCollection[1].Description, "Description is wrong");
            Assert.AreEqual(MessageStrings.KeyValueStatusColumnName, actual.OutputColumnCollection[2].Name, "Column Name is wrong");
            Assert.AreEqual(DataType.DT_STR, actual.OutputColumnCollection[2].DataType, "DataType is wrong");
            Assert.AreEqual(255, actual.OutputColumnCollection[2].Length, "Length is wrong");
            Assert.AreEqual(MessageStrings.KeyValueStatusColumnDescription, actual.OutputColumnCollection[2].Description, "Description is wrong");
        }
コード例 #4
0
        public void TestIDTSOutputCreator()
        {
            Microsoft.SqlServer.Dts.Runtime.Package package = new Microsoft.SqlServer.Dts.Runtime.Package();
            Executable exec = package.Executables.Add("STOCK:PipelineTask");

            Microsoft.SqlServer.Dts.Runtime.TaskHost thMainPipe = exec as Microsoft.SqlServer.Dts.Runtime.TaskHost;
            MainPipe dataFlowTask = thMainPipe.InnerObject as MainPipe;

            IDTSComponentMetaData100 textFileSplitter = dataFlowTask.ComponentMetaDataCollection.New();
            ComponentEventHandler    events           = new ComponentEventHandler();

            dataFlowTask.Events               = DtsConvert.GetExtendedInterface(events as IDTSComponentEvents);
            textFileSplitter.Name             = "Row Splitter Test";
            textFileSplitter.ComponentClassID = typeof(Martin.SQLServer.Dts.TextFileSplitter).AssemblyQualifiedName;
            CManagedComponentWrapper instance = textFileSplitter.Instantiate();

            instance.ProvideComponentProperties();

            IDTSOutput100 output = textFileSplitter.OutputCollection.New();

            output.Name = "New # Output";
            output.ErrorRowDisposition = DTSRowDisposition.RD_NotUsed;

            ManageProperties.AddOutputProperties(output.CustomPropertyCollection);

            ManageColumns.AddNumberOfRowsOutputColumns(output);

            ManageProperties propertyManager = new ManageProperties();

            propertyManager.PostErrorEvent += new PostErrorDelegate(this.PostError);
            errorMessages = new List <string>();

            SSISOutput actual = new SSISOutput(output, null);

            Assert.IsNotNull(actual, "SSISOutput is null");
            Assert.IsNotNull(actual.CustomPropertyCollection, "Custom Property Collection is null");
            Assert.IsNotNull(actual.OutputColumnCollection, "Column Collection is null");
            Assert.AreEqual(3, actual.CustomPropertyCollection.Count, "Custom Property Collection Count is Wrong");
            Assert.AreEqual(3, actual.OutputColumnCollection.Count, "Output Column Collection Count is Wrong");
            Assert.IsNotNull(ManageProperties.GetPropertyValue(actual.CustomPropertyCollection, ManageProperties.typeOfOutput));
            Assert.IsNotNull(ManageProperties.GetPropertyValue(actual.CustomPropertyCollection, ManageProperties.rowTypeValue));
            Assert.IsNotNull(ManageProperties.GetPropertyValue(actual.CustomPropertyCollection, ManageProperties.masterRecordID));
            Assert.AreEqual("_NewOutput", actual.Name, "Name is incorrect");
            Assert.AreEqual(DTSRowDisposition.RD_NotUsed, actual.ErrorRowDisposition, "Error Row Disposition is incorrect");
        }