Exemple #1
0
 public void Load(IPropertyBag propertyBag, int errorLog)
 {
     PropertyPath    = PropertyBagHelper.ReadPropertyBag <string>(propertyBag, PropertyPathPropertyName);
     XPath           = PropertyBagHelper.ReadPropertyBag <string>(propertyBag, XPathPropertyName);
     PromoteProperty = PropertyBagHelper.ReadPropertyBag <bool>(propertyBag, PromoteProperytName);
     ThrowIfNoMatch  = PropertyBagHelper.ReadPropertyBag <bool>(propertyBag, ThrowIfNoMatchPropertyName);
 }
Exemple #2
0
 public virtual void Load(IPropertyBag pb, int errlog)
 {
     NewNamespace  = PropertyBagHelper.ReadPropertyBag(pb, NewNamespacePropertyName, NewNamespace);
     NamespaceForm = PropertyBagHelper.ReadPropertyBag(pb, NamespaceFormPropertyName, NamespaceForm);
     XPath         = PropertyBagHelper.ReadPropertyBag(pb, XPathPropertyName, XPath);
     ShouldUpdateMessageTypeContext = PropertyBagHelper.ReadPropertyBag(pb, ShouldUpdateMessageTypeContextPropertyName, ShouldUpdateMessageTypeContext);
 }
Exemple #3
0
 public void Load(IPropertyBag propertyBag, int errorLog)
 {
     PropertyPath    = PropertyBagHelper.ReadPropertyBag(propertyBag, PropertyPathPropertyName, PropertyPath);
     XPath           = PropertyBagHelper.ReadPropertyBag(propertyBag, XPathPropertyName, XPath);
     PromoteProperty = PropertyBagHelper.ReadPropertyBag(propertyBag, PromoteProperytName, PromoteProperty);
     ThrowIfNoMatch  = PropertyBagHelper.ReadPropertyBag(propertyBag, ThrowIfNoMatchPropertyName, ThrowIfNoMatch);
 }
        private string HiddenProperties(IPropertyBag propertyBag, ContextValueCollection contexts)
        {
            string hidden = String.Empty;
            string props  = String.Empty;
            ContextValueCollection saved_context = null;


            hidden = PropertyBagHelper.ReadPropertyBag <string>(propertyBag, "HiddenProperties", "Properties,Namespaces");

            if (hidden == null)
            {
                return("Properties,Namespaces");
            }

            props = PropertyBagHelper.ReadPropertyBag <string>(propertyBag, "Properties", String.Empty);

            saved_context = ContextValueCollection.Deserialize(props);


            foreach (ContextValue context in saved_context)
            {
                if (contexts.Contains(context) == false)
                {
                    if (hidden.IndexOf(context.ToString()) < 0)
                    {
                        hidden = String.Format("{0},{1}", hidden, context.ToString());
                    }
                }
            }


            return(hidden.Replace(",,", ","));
        }
Exemple #5
0
        public void Merge_Files_2_Part_Primary_Key()
        {
            // Arrange
            TestHelper testHelper = new TestHelper();

            DataConnection    connection        = testHelper.TestConnection(); // Get a test connection
            PropertyBagHelper propertyBagHelper = new PropertyBagHelper(connection);

            propertyBagHelper.Set <Int32>(PropertyBagItemTypeEnum.RowsToSkip, 1);
            propertyBagHelper.Set <Boolean>(PropertyBagItemTypeEnum.HasHeaderRecord, true);

            DataItemDefinition definition = testHelper.TestDefinition(TestHelper.TestFile_GenericFixedWidth);      // Get the test definition of what to merge from (but also to)

            DataTable baseData  = testHelper.PopulateDataTable(TestHelper.TestFile_GenericFixedWidth, connection); // Get the data
            DataTable mergeData = testHelper.PopulateDataTable(TestHelper.TestFile_MergeData, connection);         // Get the data

            Stream        testStream = new MemoryStream();                                                         // A blank stream to write data to
            IDataProvider provider   = new FixedWidthFileProvider();                                               // A flat file provider to use to write the data

            // Act
            provider.Connect(definition, connection, testStream); // Connect to the blank stream
            provider.Write(baseData, "");                         // Write the data to the empty stream
            provider.Write(mergeData, "");                        // Write some more records with some updates and some adds
            DataTable mergedData = provider.Read("");             // Get the new data set back

            // Assert
            Assert.True(mergedData.Rows.Count == (baseData.Rows.Count + mergeData.Rows.Count) - 1); // Expect of the total of 8 rows, 2 should merge
        }
Exemple #6
0
        public void ToStringOrDefaultTest()
        {
            object property = PropertyBagHelper.ReadPropertyBag(_propertyBag, TestStringString);
            string value    = PropertyBagHelper.ToStringOrDefault(property, "WrongValue");

            Assert.AreEqual(TestString, value);
        }
Exemple #7
0
        /// <summary>
        /// Saves current component configuration into the property bag.
        /// </summary>
        /// <param name="pb">Configuration property bag.</param>
        /// <param name="fClearDirty">Not used.</param>
        /// <param name="fSaveAllProperties">Not used.</param>
        void IPersistPropertyBag.Save(Microsoft.BizTalk.Component.Interop.IPropertyBag pb, bool fClearDirty, bool fSaveAllProperties)
        {
            string envelopeSpecNames = String.Empty;

            foreach (var item in this.EnvelopeSpecNames)
            {
                if (envelopeSpecNames == String.Empty)
                {
                    envelopeSpecNames = item.SchemaName;
                    continue;
                }

                envelopeSpecNames += String.Format("|{0}", item.SchemaName);
            }

            string documentSpecNames = String.Empty;

            foreach (var item in this.documentSpecNames)
            {
                if (documentSpecNames == String.Empty)
                {
                    documentSpecNames = item.SchemaName;
                    continue;
                }

                documentSpecNames += String.Format("|{0}", item.SchemaName);
            }
            PropertyBagHelper.WritePropertyBag(pb, "DocumentSpecNames", documentSpecNames);
            PropertyBagHelper.WritePropertyBag(pb, "EnvelopeSpecNames", envelopeSpecNames);
            PropertyBagHelper.WritePropertyBag(pb, "RecoverableInterchangeProcessing", this.RecoverableInterchangeProcessing);
            PropertyBagHelper.WritePropertyBag(pb, "ValidateDocument", this.ValidateDocument);
        }
Exemple #8
0
        /// <summary>
        /// Loads configuration property for component.
        /// </summary>
        /// <param name="pb">Configuration property bag.</param>
        /// <param name="errlog">Error status (not used in this code).</param>
        void IPersistPropertyBag.Load(Microsoft.BizTalk.Component.Interop.IPropertyBag pb, Int32 errlog)
        {
            string strEnvelopes = (string)propertyHelper.ReadPropertyBag(pb, "EnvelopeSpecNames");

            if (strEnvelopes != null && strEnvelopes.Length > 0)
            {
                string[] strEnvArray = strEnvelopes.Split('|');

                this.envelopeSpecNames.Clear();
                for (int lowerBound = strEnvArray.GetLowerBound(0); lowerBound <= strEnvArray.GetUpperBound(0); ++lowerBound)
                {
                    Schema schema = new Schema(strEnvArray[lowerBound]);
                    this.envelopeSpecNames.Add(schema);
                }
            }

            string strDocuments = (string)propertyHelper.ReadPropertyBag(pb, "DocumentSpecNames");

            if (strDocuments != null && strDocuments.Length > 0)
            {
                string[] strDocArray = strDocuments.Split('|');

                this.DocumentSpecNames.Clear();
                for (int lowerBound = strDocArray.GetLowerBound(0); lowerBound <= strDocArray.GetUpperBound(0); ++lowerBound)
                {
                    Schema schema = new Schema(strDocArray[lowerBound]);
                    this.DocumentSpecNames.Add(schema);
                }
            }

            this.RecoverableInterchangeProcessing = PropertyBagHelper.ReadPropertyBag <Boolean>(pb, "RecoverableInterchangeProcessing", this.RecoverableInterchangeProcessing);
            this.ValidateDocument = PropertyBagHelper.ReadPropertyBag <Boolean>(pb, "ValidateDocument", this.ValidateDocument);
        }
Exemple #9
0
 public virtual void Save(IPropertyBag pb, bool fClearDirty,
                          bool fSaveAllProperties)
 {
     PropertyBagHelper.WritePropertyBag(pb, NamespaceToModifyPropertyName, NamespaceToModify);
     PropertyBagHelper.WritePropertyBag(pb, NewNamespacePropertyName, NewNamespace);
     PropertyBagHelper.WritePropertyBag(pb, ShouldUpdateMessagewTypeContextPropertyName, ShouldUpdateMessageTypeContext);
 }
        /// <summary>
        /// Get a test connection for use with the readers
        /// </summary>
        /// <returns>A test connection</returns>
        public DataConnection TestConnection()
        {
            DataConnection connection = new DataConnection()
            {
                ProviderType = DataProviderType.FixedWidthFileProvider,
                LastUpdated  = DateTime.Now,
                Id           = Guid.NewGuid(),
                PropertyBag  =
                    (new FixedWidthFileProvider()).PropertyBagTypes()
                    .Select(type =>
                            new PropertyBagItem()
                {
                    Value    = type.DefaultValue,
                    ItemType = type
                })
                    .ToList()
            };

            // Create a property bag helper to set some defaults
            PropertyBagHelper propertyBagHelper = new PropertyBagHelper(connection);

            propertyBagHelper.Set <Boolean>(PropertyBagItemTypeEnum.HasHeaderRecord, true);
            propertyBagHelper.Set <Int32>(PropertyBagItemTypeEnum.RowsToSkip, 1);

            return(connection);
        }
 public void Load(IPropertyBag propertyBag, int errorLog)
 {
     SourcePropertyPath      = PropertyBagHelper.ReadPropertyBag(propertyBag, SourcePropertyPathPropertyName, SourcePropertyPath);
     DestinationPropertyPath = PropertyBagHelper.ReadPropertyBag(propertyBag, DestinationPropertyPathPropertyName, DestinationPropertyPath);
     ListName     = PropertyBagHelper.ReadPropertyBag(propertyBag, ListNamePropertyName, ListName);
     DefaultValue = PropertyBagHelper.ReadPropertyBag(propertyBag, DefaultValuePropertyName, DefaultValue);
 }
 public void Save(IPropertyBag propertyBag, bool clearDirty, bool saveAllProperties)
 {
     PropertyBagHelper.WritePropertyBag(propertyBag, SourcePropertyPathPropertyName, SourcePropertyPath);
     PropertyBagHelper.WritePropertyBag(propertyBag, DestinationPropertyPathPropertyName, DestinationPropertyPath);
     PropertyBagHelper.WritePropertyBag(propertyBag, ListNamePropertyName, ListName);
     PropertyBagHelper.WritePropertyBag(propertyBag, DefaultValuePropertyName, DefaultValue);
 }
        /// <summary>
        /// Create and set up a csv reader based on the data item definition given
        /// </summary>
        /// <param name="textReader">The text reader to inject in to the CSV reader</param>
        /// <param name="definition">The definition of the file</param>
        /// <returns>The newly configured CSV Reader</returns>
        private static CsvReader SetupReader(TextReader textReader, DataConnection connection, DataItemDefinition definition)
        {
            // Produce a new CSV Reader
            CsvReader result = new CsvReader(textReader);

            // Create a helper to read the property bag items
            PropertyBagHelper propertyBagHelper = new PropertyBagHelper(connection);

            // Configure the CSV Reader
            result.Configuration.HasHeaderRecord = (definition == null) ? true :
                                                   propertyBagHelper.Get <Boolean>(PropertyBagItemTypeEnum.HasHeaderRecord, true);
            result.Configuration.BadDataFound = null; // Don't pipe bad data
            result.Configuration.CultureInfo  = (definition == null) ?
                                                CultureInfo.CurrentCulture : definition.Culture;
            result.Configuration.TrimOptions = TrimOptions.Trim;
            result.Configuration.Delimiter   = (definition == null) ? "," :
                                               propertyBagHelper.Get <String>(PropertyBagItemTypeEnum.DelimiterCharacter, ",");
            result.Configuration.Quote = (definition == null) ? '"' :
                                         propertyBagHelper.Get <Char>(PropertyBagItemTypeEnum.QuoteCharacter, '"');
            result.Configuration.IgnoreQuotes = (definition == null) ? true :
                                                propertyBagHelper.Get <Boolean>(PropertyBagItemTypeEnum.IgnoreQuotes, true);
            result.Configuration.MissingFieldFound        = null;
            result.Configuration.ReadingExceptionOccurred = null;

            // Send the reader back
            return(result);
        }
Exemple #14
0
 public void Save(IPropertyBag propertyBag, bool clearDirty, bool saveAllProperties)
 {
     PropertyBagHelper.WritePropertyBag(propertyBag, PropertyPathPropertyName, PropertyPath);
     PropertyBagHelper.WritePropertyBag(propertyBag, XPathPropertyName, XPath);
     PropertyBagHelper.WritePropertyBag(propertyBag, PromoteProperytName, PromoteProperty);
     PropertyBagHelper.WritePropertyBag(propertyBag, ThrowIfNoMatchPropertyName, ThrowIfNoMatch);
 }
Exemple #15
0
        public void WritePropertyBagComplexObjectTest()
        {
            PropertyBagHelper.WritePropertyBag(_propertyBag, TestXmlDocumentString, new XmlDocument());
            var property = PropertyBagHelper.ReadPropertyBag <XmlDocument>(_propertyBag, TestXmlDocumentString);

            Assert.IsNotNull(property);
        }
 public void Load(IPropertyBag propertyBag, int errorLog)
 {
     SourcePropertyPath      = PropertyBagHelper.ReadPropertyBag(propertyBag, SourcePropertyPathPropertyName, SourcePropertyPath);
     DestinationPropertyPath = PropertyBagHelper.ReadPropertyBag(propertyBag, DestinationPropertyPathPropertyName, DestinationPropertyPath);
     TableName        = PropertyBagHelper.ReadPropertyBag(propertyBag, TableNamePropertyName, TableName);
     DefaultValue     = PropertyBagHelper.ReadPropertyBag(propertyBag, DefaultValuePropertyName, DefaultValue);
     ThrowIfNotExists = PropertyBagHelper.ReadPropertyBag(propertyBag, ThrowIfNotExistsPropertyName, ThrowIfNotExists);
 }
Exemple #17
0
        public void ToStringOrDefaultTestDefaultValue()
        {
            string defaultValue = "DefaultValue";
            object property     = PropertyBagHelper.ReadPropertyBag(_propertyBag, "Wrong" + TestStringString);
            string value        = PropertyBagHelper.ToStringOrDefault(property, defaultValue);

            Assert.AreEqual(defaultValue, value);
        }
Exemple #18
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="dataTable"></param>
        /// <returns></returns>
        public static String DataTableToString(DataItemDefinition definition, DataConnection connection, DataTable dataTable)
        {
            String result = ""; // New empty string to populate

            // Create a helper to read the property bag items
            PropertyBagHelper propertyBagHelper = new PropertyBagHelper(connection);

            // Get the stream from the file
            using (MemoryStream textStream = new MemoryStream())
            {
                // Set up the writer
                StreamWriter streamWriter = new StreamWriter(textStream);
                using (CsvWriter writer = SetupWriter(definition, streamWriter))
                {
                    // Do we need to write a header?
                    if (propertyBagHelper.Get <Boolean>(PropertyBagItemTypeEnum.HasHeaderRecord, false))
                    {
                        // Loop the header records and output the header record line manually
                        definition.ItemProperties
                        .Where(prop => prop.PropertyType == DataItemPropertyType.Property)
                        .ToList()
                        .ForEach(
                            header =>
                        {
                            writer.WriteField(header.Name);
                        });

                        // Move to the next line and flush the data
                        writer.NextRecord();
                        streamWriter.Flush();
                    }

                    // Loop through the actual records and add them to the csv
                    foreach (DataRow row in dataTable.Rows)
                    {
                        // Loop the header records and output the header record line manually
                        definition.ItemProperties
                        .Where(prop => prop.PropertyType == DataItemPropertyType.Property)
                        .ToList()
                        .ForEach(
                            property =>
                        {
                            writer.WriteField(DataFormatHelper.WriteData(row[property.Name], property, definition), property.Quoted);
                        });

                        // Move to the next line and flush the data
                        writer.NextRecord();
                        streamWriter.Flush();
                    }

                    // Put the data back in the buffer
                    textStream.Position = 0;
                    result = ((new StreamReader(textStream)).ReadToEnd() ?? "");
                }
            }

            return(result); // Send the formatted flat file data back
        }
        public void Load(IPropertyBag propertyBag, int errorLog)
        {
            var recoverableInterchangeProcessing = PropertyBagHelper.ReadPropertyBag(propertyBag, RecoverableInterchangeProcessingPropertyName);

            if (recoverableInterchangeProcessing != null)
            {
                RecoverableInterchangeProcessing = (bool)recoverableInterchangeProcessing;
            }
        }
        public void Save(IPropertyBag propertyBag, bool clearDirty, bool saveAllProperties)
        {
            var props = this.GetType().GetProperties(System.Reflection.BindingFlags.Public | System.Reflection.BindingFlags.Instance);

            foreach (var prop in props)
            {
                if (prop.CanRead & prop.CanWrite)
                {
                    PropertyBagHelper.WritePropertyBag(propertyBag, prop.Name, prop.GetValue(this));
                }
            }
        }
        public void Load(IPropertyBag propertyBag, int errorLog)
        {
            var props = this.GetType().GetProperties(System.Reflection.BindingFlags.Public | System.Reflection.BindingFlags.Instance);

            foreach (var prop in props)
            {
                if (prop.CanRead & prop.CanWrite)
                {
                    prop.SetValue(this, PropertyBagHelper.ReadPropertyBag(propertyBag, prop.Name, prop.GetValue(this)));
                }
            }
        }
Exemple #22
0
        /// <summary>
        /// Set up a new csv writer based on the definition given
        /// </summary>
        /// <param name="definition">The data item definition</param>
        /// <returns></returns>
        private static CsvWriter SetupWriter(DataItemDefinition definition, TextWriter textWriter)
        {
            // Create the new writer
            CsvWriter writer = new CsvWriter(textWriter);

            // Create a helper to read the property bag items
            PropertyBagHelper propertyBagHelper = new PropertyBagHelper(definition);

            // Force all fields to be quoted or not
            writer.Configuration.QuoteAllFields =
                propertyBagHelper.Get <Boolean>(PropertyBagItemTypeEnum.QuoteAllFields, false);

            return(writer);
        }
Exemple #23
0
        public virtual void Load(IPropertyBag pb, int errlog)
        {
            NamespaceToModify =
                PropertyBagHelper.ToStringOrDefault(PropertyBagHelper.ReadPropertyBag(pb, NamespaceToModifyPropertyName),
                                                    string.Empty);

            NewNamespace = PropertyBagHelper.ToStringOrDefault(PropertyBagHelper.ReadPropertyBag(pb, NewNamespacePropertyName), string.Empty);

            var shouldUpdateMessageTypeContext = PropertyBagHelper.ReadPropertyBag(pb, ShouldUpdateMessagewTypeContextPropertyName);

            if ((shouldUpdateMessageTypeContext != null))
            {
                ShouldUpdateMessageTypeContext = ((bool)(shouldUpdateMessageTypeContext));
            }
        }
        public void Custom_Dates_Can_Be_Read()
        {
            // Arrange
            TestHelper        testHelper        = new TestHelper();
            DataConnection    connection        = testHelper.TestConnection();
            PropertyBagHelper propertyBagHelper = new PropertyBagHelper(connection);

            propertyBagHelper.Set <Int32>(PropertyBagItemTypeEnum.RowsToSkip, 1);
            propertyBagHelper.Set <Boolean>(PropertyBagItemTypeEnum.HasHeaderRecord, true);

            // Act
            DataTable data = testHelper.PopulateDataTable(TestHelper.TestFile_GenericFixedWidth, connection); // Get the data

            // Assert
            Assert.True(data.Rows.Count != 0); // It actually got some data rows
            Object row0Date = data.Rows[0]["PostDate"];
            Object row1Date = data.Rows[1]["PostDate"];
            Object row2Date = data.Rows[2]["PostDate"];
            Object row3Date = data.Rows[3]["PostDate"];

            // "10/17/2012"
            Assert.True(
                (row0Date != DBNull.Value) &&
                ((DateTime)row0Date).Day == 17 &&
                ((DateTime)row0Date).Month == 10 &&
                ((DateTime)row0Date).Year == 2012);

            // "01/14/2013"
            Assert.True(
                (row1Date != DBNull.Value) &&
                ((DateTime)row1Date).Day == 14 &&
                ((DateTime)row1Date).Month == 1 &&
                ((DateTime)row1Date).Year == 2013);

            // "XX/YY/2012"
            Assert.True((row2Date == DBNull.Value));

            // "11/21/2012"
            Assert.True(
                (row3Date != DBNull.Value) &&
                ((DateTime)row3Date).Day == 21 &&
                ((DateTime)row3Date).Month == 11 &&
                ((DateTime)row3Date).Year == 2012);
        }
        /// <summary>
        /// Read the raw data file and populate the in-memory data table with it
        /// </summary>
        /// <param name="rawData">The raw flat file data from wherever it came from</param>
        /// <returns>If the translation was successful</returns>
        public static DataTable TextToDataTable(DataItemDefinition definition, DataConnection connection, String rawData)
        {
            // Create a list of data items to return
            DataTable dataItems = definition.ToDataTable();

            // Create a helper to read the property bag items
            PropertyBagHelper propertyBagHelper = new PropertyBagHelper(connection);

            // Raw data has something to convert?
            if ((rawData ?? "") != "")
            {
                // Open up a text reader to stream the data to the CSV Reader
                using (TextReader textReader = new StringReader(rawData))
                {
                    // Get properties needed to process the file (total lines to skip etc.)
                    Int32 lineNo      = 0;
                    Int32 linesToSkip =
                        propertyBagHelper.Get <Int32>(PropertyBagItemTypeEnum.RowsToSkip, 0) +
                        (propertyBagHelper.Get <Boolean>(PropertyBagItemTypeEnum.HasHeaderRecord, false) ? 1 : 0);

                    // Loop each line of the file (ignoring lines that do not need to be processed)
                    String line = "";
                    while ((line = textReader.ReadLine()) != null)
                    {
                        // Is this a line we should be processing
                        if (lineNo >= linesToSkip)
                        {
                            DataRow row = dataItems.NewRow(); // The new row to populate based on the defintion

                            // Process the row
                            if (ProcessRow(line, row, definition))
                            {
                                dataItems.Rows.Add(row); // Add the row if processing was successful
                            }
                        }

                        lineNo++; // Increment the line number counter
                    }
                }
            }

            return(dataItems); // Send the datatable back
        }
        public void Boolean_Values_Of_Different_Types()
        {
            // Arrange
            TestHelper        testHelper        = new TestHelper();
            DataConnection    connection        = testHelper.TestConnection();
            PropertyBagHelper propertyBagHelper = new PropertyBagHelper(connection);

            propertyBagHelper.Set <Boolean>(PropertyBagItemTypeEnum.HasHeaderRecord, false);

            // Act
            DataTable data = testHelper.PopulateDataTable(TestHelper.TestFile_DataTypes, connection); // Get the data

            // Assert
            Assert.True(data.Rows.Count != 0);                                               // It actually got some data rows
            Assert.True((data.Rows.Count == 5) && (Boolean)data.Rows[0]["Active"] == true);  // Check row 0's expected result
            Assert.True((data.Rows.Count == 5) && (Boolean)data.Rows[1]["Active"] == true);  // Check row 1's expected result
            Assert.True((data.Rows.Count == 5) && (Boolean)data.Rows[2]["Active"] == true);  // Check row 2's expected result
            Assert.True((data.Rows.Count == 5) && (Boolean)data.Rows[3]["Active"] == false); // Check row 3's expected result
            Assert.True((data.Rows.Count == 5) && (Boolean)data.Rows[4]["Active"] == false); // Check row 4's expected result
        }
        public virtual void Load(IPropertyBag pb, int errlog)
        {
            NewNamespace = PropertyBagHelper.ToStringOrDefault(PropertyBagHelper.ReadPropertyBag(pb, NewNamespacePropertyName), string.Empty);

            var namespaceForm = PropertyBagHelper.ReadPropertyBag(pb, NamespaceFormPropertyName);

            if ((namespaceForm != null))
            {
                NamespaceForm = ((NamespaceFormEnum)(namespaceForm));
            }

            XPath = PropertyBagHelper.ToStringOrDefault(PropertyBagHelper.ReadPropertyBag(pb, XPathPropertyName), string.Empty);

            var shouldUpdateMessageTypeContext = PropertyBagHelper.ReadPropertyBag(pb, ShouldUpdateMessageTypeContextPropertyName);

            if ((shouldUpdateMessageTypeContext != null))
            {
                ShouldUpdateMessageTypeContext = ((bool)(shouldUpdateMessageTypeContext));
            }
        }
        public void Boolean_Values_Of_Different_Types()
        {
            // Arrange
            TestHelper        testHelper        = new TestHelper();
            DataConnection    connection        = testHelper.TestConnection();
            PropertyBagHelper propertyBagHelper = new PropertyBagHelper(connection);

            propertyBagHelper.Set <Int32>(PropertyBagItemTypeEnum.RowsToSkip, 0); // Override the default setting to 0 rows to skip

            // Act
            DataTable data = testHelper.PopulateDataTable(TestHelper.TestFile_DataTypes, connection); // Get the data

            // Assert
            Assert.True(data.Rows.Count != 0);                                                    // It actually got some data rows
            Assert.True((data.Rows.Count == 6) && (Boolean)data.Rows[0]["BooleanType"] == true);  // Check row 0's expected result
            Assert.True((data.Rows.Count == 6) && (Boolean)data.Rows[1]["BooleanType"] == false); // Check row 1's expected result
            Assert.True((data.Rows.Count == 6) && (Boolean)data.Rows[2]["BooleanType"] == true);  // Check row 2's expected result
            Assert.True((data.Rows.Count == 6) && (Boolean)data.Rows[3]["BooleanType"] == false); // Check row 3's expected result
            Assert.True((data.Rows.Count == 6) && (Boolean)data.Rows[4]["BooleanType"] == true);  // Check row 4's expected result
            Assert.True((data.Rows.Count == 6) && (Boolean)data.Rows[5]["BooleanType"] == false); // Check row 5's expected result
        }
        public void Data_Read_From_Headers()
        {
            // Arrange
            TestHelper        testHelper        = new TestHelper();
            DataConnection    connection        = testHelper.TestConnection(); // Get a test connection
            PropertyBagHelper propertyBagHelper = new PropertyBagHelper(connection);

            propertyBagHelper.Set <Int32>(PropertyBagItemTypeEnum.RowsToSkip, 1);
            propertyBagHelper.Set <Boolean>(PropertyBagItemTypeEnum.HasHeaderRecord, true);

            // Act
            DataTable data    = testHelper.PopulateDataTable(TestHelper.TestFile_GenericFixedWidth, connection); // Get the data
            DataRow   dataRow = (data.Rows.Count >= 1) ? data.Rows[0] : null;                                    // Get row 3 to check the data against later

            // Assert
            Assert.True(data.Rows.Count == 530);                                                  // Should be 530 rows (532 including the header and spacer)
            Assert.True(data.Columns.Contains("Description"));                                    // Should be a column that was found even though it had no quotes
            Assert.True(dataRow != null && ((String)dataRow["Description"]).Trim() == "TXNPUES"); // The third row should have some data for the unquoted header
            Assert.True(dataRow != null && ((String)dataRow["Ref"]).Trim() == "RHMXWPCP");        // The third row should have some data for the unquoted header
            Assert.True(dataRow != null && (Boolean)dataRow["Post"]);                             // The third row should have some data for the unquoted header
        }
Exemple #30
0
 public void Load(IPropertyBag propertyBag, int errorLog)
 {
     Expression = PropertyBagHelper.ReadPropertyBag(propertyBag, ExpressionPropertyName, Expression);
     XPath      = PropertyBagHelper.ReadPropertyBag(propertyBag, XPathPropertyName, XPath);
 }