Example #1
0
        public PatientInfo()
        {
            SQLServerInfo sqlInfo = new SQLServerInfo();

            this.connectionString = sqlInfo.connectionString;

            hl7v2.Clear();
        }
        public void Clear(int count)
        {
            StringDictionary stringDictionary = Helpers.CreateStringDictionary(count);

            stringDictionary.Clear();
            Assert.Equal(0, stringDictionary.Count);

            stringDictionary.Clear();
            Assert.Equal(0, stringDictionary.Count);
        }
Example #3
0
        /// <summary>
        /// Iterate through the object array passed in.  For each element in the object array
        /// passed-in, a new role is added to the collection.
        /// </summary>
        /// <param name="savedState">The object array returned by the SaveViewState() method in
        /// the previous page visit.</param>
        void IStateManager.LoadViewState(object savedState)
        {
            if (savedState != null)
            {
                object [] state = (object[])savedState;

                roles.Clear();

                for (int i = 0; i < state.Length; i++)
                {
                    roles.Add((string)state[i], String.Empty);
                }
            }
        }
Example #4
0
 /// <summary>
 /// 构造方法:创建并初始化Editor类型对象。
 /// </summary>
 public Editor()
 {
     StringDictionary.Clear();
     Int32Dictionary.Clear();
     BooleanDictionary.Clear();
     DoubleDictionary.Clear();
 }
Example #5
0
        /// <summary>
        /// Changes the code tex template and returns it
        /// </summary>
        /// <param name="f"></param>
        /// <returns></returns>
        public string AddCode(MyFile f)
        {
            StringDictionary fields = new StringDictionary();
            string           temp   = f.Path;

            foreach (WhiteList wl in _whiteList)
            {
                if (f.Extension == wl.Extension)
                {
                    fields.Add("Language", wl.Language);
                    break;
                }
            }

            temp = reg.Replace(temp, "/");
            fields.Add("Path", temp);
            string output = "";

            output += re.Replace(TexCodeTemplate, delegate(Match match)
            {
                return(fields[match.Groups[1].Value]);
            });

            output += "\n";
            fields.Clear();
            return(output);
        }
Example #6
0
    void collection_StringDictionary()
    {
        ClearConsole();
        StringDictionary dict = new StringDictionary();

        dict.Add("cat", "feline");
        dict.Add("dog", "canine");
        Debug.Log(dict["cat"]);
        Debug.Log(dict["test"] == null);
        Debug.Log(dict.ContainsKey("cat"));
        Debug.Log(dict.ContainsKey("puppet"));
        Debug.Log(dict.ContainsValue("feline"));
        Debug.Log(dict.ContainsValue("perls"));
        Debug.Log(dict.IsSynchronized);
        foreach (DictionaryEntry entry in dict)
        {
            Debug.Log(entry.Key + " " + entry.Value);
        }
        foreach (string key in dict.Keys)
        {
            Debug.Log(key);
        }
        foreach (string value in dict.Values)
        {
            Debug.Log(value);
        }
        dict.Remove("cat");
        Debug.Log(dict.Count);
        dict.Clear();
        Debug.Log(dict.Count);
    }
Example #7
0
        public void Reset()
        {
            if (m_listParameters != null)
            {
                m_listParameters.Clear();

                m_listParameters.Add("desc", String.Empty);
                m_listParameters.Add("a", String.Empty);
                m_listParameters.Add("b", String.Empty);
                m_listParameters.Add("name", String.Empty);
                m_listParameters.Add("result", String.Empty);
                m_listParameters.Add("arg1", String.Empty);
                m_listParameters.Add("arg2", String.Empty);
                m_listParameters.Add("arg3", String.Empty);
            }
        }
Example #8
0
        private void PopulateQueryString()
        {
            string query = base.Query;

            if (query == string.Empty || query == null)
            {
                return;
            }

            if (_queryString == null)
            {
                _queryString = new StringDictionary();
            }

            _queryString.Clear();

            query = query.Substring(1); //remove the ?

            string[] pairs = query.Split(new char[] { '&' });
            foreach (string s in pairs)
            {
                string[] pair = s.Split(new char[] { '=' });

                _queryString[pair[0]] = (pair.Length > 1) ? pair[1] : string.Empty;
            }
        }
Example #9
0
        public void UpdateList()
        {
            combolist.Items.Clear();
//	        if (cbmsvs.Checked) foreach (object mope in Globe.Lib.fx.MSVSMACROS.vals.Keys)
//	        {
//	            combolist.Items.Add(string.Format("$({0})",mope));
//	        }
//	        if (cbuser.Checked) foreach (object mope in Globe.Lib.fx.Constants)
//	        {
//	            if (mope is IConstant)
//	            {
//	                IConstant poo =(mope) as IConstant;
//	                if (poo.Alias!=null)
//	                {
//	                    if (poo.Alias!=string.Empty) combolist.Items.Add(string.Format("$({0})",poo.Alias));
//	                }
//	                //this.combolist.Items.Add(string.Format("$({0})",mope));
//	            }
//	        }
            if (cbsys.Checked)
            {
                StringDictionary sd = RunProcess.EnvVars("explorer.exe", @"c:\windows\");
                foreach (DictionaryEntry de in sd)
                {
                    combolist.Items.Add(string.Format("$({0})", de.Key));
                }
                sd.Clear();
                sd = null;
            }
        }
Example #10
0
        protected void Parse(string rawValue)
        {
            m_params.Clear();
            string[] keyPairs = rawValue.Split(';');
            m_dispType = keyPairs[0];

            for (int i = 1; i < keyPairs.Length; i++)
            {
                string keyPair = keyPairs[i];
                int    index   = keyPair.IndexOf('=');
                if (index < 0)
                {
                    Logger.Error(
                        "ContentDispositionEx.Parse: invalid key pair '{0}'",
                        keyPair);
                    continue;
                }
                string key   = keyPair.Substring(0, index).Trim();
                string value = keyPair.Substring(index + 1).Trim();
                if (value.StartsWith("\"") && value.EndsWith("\"") && value.Length > 1)
                {
                    value = value.Substring(1, value.Length - 1);
                    value = value.Replace("\\\"", "\"").Trim();
                }
                key           = key.ToLower();
                m_params[key] = value;
            }
        }
        public static void Main()
        {
            // Creates and initializes a new StringDictionary.
            StringDictionary myCol = new StringDictionary();

            myCol.Add("red", "rojo");
            myCol.Add("green", "verde");
            myCol.Add("blue", "azul");
            Console.WriteLine("Count:    {0}", myCol.Count);

            // Display the contents of the collection using foreach. This is the preferred method.
            Console.WriteLine("Displays the elements using foreach:");
            PrintKeysAndValues1(myCol);

            // Display the contents of the collection using the enumerator.
            Console.WriteLine("Displays the elements using the IEnumerator:");
            PrintKeysAndValues2(myCol);

            // Display the contents of the collection using the Keys, Values, Count, and Item properties.
            Console.WriteLine("Displays the elements using the Keys, Values, Count, and Item properties:");
            PrintKeysAndValues3(myCol);

            // Copies the StringDictionary to an array with DictionaryEntry elements.
            DictionaryEntry[] myArr = new DictionaryEntry[myCol.Count];
            myCol.CopyTo(myArr, 0);

            // Displays the values in the array.
            Console.WriteLine("Displays the elements in the array:");
            Console.WriteLine("   KEY        VALUE");
            for (int i = 0; i < myArr.Length; i++)
            {
                Console.WriteLine("   {0,-10} {1}", myArr[i].Key, myArr[i].Value);
            }
            Console.WriteLine();

            // Searches for a value.
            if (myCol.ContainsValue("amarillo"))
            {
                Console.WriteLine("The collection contains the value \"amarillo\".");
            }
            else
            {
                Console.WriteLine("The collection does not contain the value \"amarillo\".");
            }
            Console.WriteLine();

            // Searches for a key and deletes it.
            if (myCol.ContainsKey("green"))
            {
                myCol.Remove("green");
            }
            Console.WriteLine("The collection contains the following elements after removing \"green\":");
            PrintKeysAndValues1(myCol);

            // Clears the entire collection.
            myCol.Clear();
            Console.WriteLine("The collection contains the following elements after it is cleared:");
            PrintKeysAndValues1(myCol);
        }
Example #12
0
 // Copy the StringDictionary to another StringDictionary.
 // This is not as efficient as directly setting the property, but it avoids having to expose a public setter on the property.
 internal static void CopyStringDictionary(StringDictionary source, StringDictionary dest)
 {
     dest.Clear();
     foreach (string key in source)
     {
         dest[key] = source[key];
     }
 }
Example #13
0
 public void Clear()
 {
     _infoStringDictionary.Clear();
     _creationTime = DateTime.Now;
     _revisionTime = DateTime.Now;
     _printTime    = DateTime.Now;
     _backupTime   = DateTime.Now;
 }
Example #14
0
        void initRfid(TextBox tb, TextBox tbFocus)
        {
            try
            {
                #region write/get rfid
                //read rfid code text
                var tmprfid = "";
                m_dicCardInfo.Clear();

                SetMsg(lnlTotal, "开始获取RFID号。");

                for (int i = 0; i < 5; i++)
                {
                    GetInventNo();
                    if (m_dicCardInfo.Count > 0)
                    {
                        break;
                    }
                }

                foreach (var item in this.m_dicCardInfo.Keys)
                {
                    tmprfid = item.ToString();
                }
                if (tmprfid.Length > 0)
                {
                    _rfidStrForSet = Encryption.HexStringToString(tmprfid.ToString(), Encoding.UTF8);



                    var tmpmsg = "扫到:" + _rfidStrForSet;

                    if (checkInList(_rfidStrForSet, false))
                    {
                        tb.Focus();
                        tmpmsg = "已扫,并与货架绑定。" + _rfidStrForSet;
                    }
                    else
                    {
                        tb.Text = _rfidStrForSet;
                        tbFocus.Focus();
                    }


                    SetMsg(lnlTotal, tmpmsg);

                    tmpmsg += ",RFID:" + tmprfid;

                    //MessageBox.Show(tmpmsg);
                }

                #endregion
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
            }
        }
Example #15
0
        //重新加载所有类型
        private void ReloadAllTypes()
        {
            _keyAndValue.Clear();
            addedInfo.Clear();
            _allStationManageTypes.Clear();

            _allStationManageTypes = _operateStation.GetAllManageType();
            LoadAllTypes(_allStationManageTypes);
        }
Example #16
0
        /// <summary>
        /// Build a dictionary for <select_column_name_list>
        /// to map the lower-case column names returned by Ingres
        /// to the original camel-case names expected by EF.
        /// We care because EF is searching on the camel-case names,
        /// not the lower-case names returned by the DBMS.
        /// </summary>
        /// <param name="commandText"></param>
        public void BuildNameDictionary(string commandText)
        {
            string tokenPrior = null;

            nameDictionary.Clear();

            if (commandText == null ||  // safety check for no text
                commandText.Length == 0)
            {
                return;
            }

            string[] tokens = commandText.Split(
                (char[])null,    // split the string using whitespace delimiters
                StringSplitOptions.RemoveEmptyEntries);

            if (tokens[0].Equals("SELECT") != true)
            {
                return;
            }

            // A typical CommandText might look like:
            //   SELECT  FIRST 1
            //     "Project1"."C1" AS "C1",
            //     "Project1"."MigrationId" AS "MigrationId",
            //     "Project1"."Model" AS "Model",
            //     "Project1"."ProductVersion" AS "ProductVersion"
            //   FROM ( SELECT ...

            // Each token is split off from CommandText using a whitespace delim.
            // The token might be a qualifier like "mytable"."mycolumn" but we
            // don't care since EF will add an alias AS "myalias" to such a
            // qualified identifier and we will add that alias name to the dict.
            // The token might contain a comma at the the end, but we will
            // use that comma as a signal to add the identifier to the dict.
            // Commas at the end of identifiers and the FROM keyword are used
            // to signal adding the preceding identifier to the dictionary.
            foreach (string token in tokens)
            {
                if (token.Equals("FROM"))  // stop scan at first FROM keyword
                {
                    BuildNameDictionaryItem(tokenPrior);
                    return;
                }
                if (token.Equals(","))  // just in case of standalone comma
                {
                    BuildNameDictionaryItem(tokenPrior);
                    continue;
                }
                if (token.EndsWith(","))
                {
                    BuildNameDictionaryItem(token);
                    continue;
                }
                tokenPrior = token;  // remember prior token
            }
        }  // end BuildNameDictionary()
Example #17
0
        /// <summary>
        ///     Loads the message presets.
        /// </summary>
        /// <param name="dbClient">The database client.</param>
        internal void LoadMessagePresets(IQueryAdapter dbClient)
        {
            UserMessagePresets.Clear();
            RoomMessagePresets.Clear();
            SupportTicketHints.Clear();
            ModerationTemplates.Clear();
            dbClient.SetQuery("SELECT type,message FROM moderation_presets WHERE enabled = 2");
            DataTable table = dbClient.GetTable();

            dbClient.SetQuery("SELECT word,hint FROM moderation_tickethints");
            DataTable table2 = dbClient.GetTable();

            dbClient.SetQuery("SELECT * FROM moderation_templates");
            DataTable table3 = dbClient.GetTable();

            if (table == null || table2 == null)
            {
                return;
            }

            foreach (DataRow dataRow in table.Rows)
            {
                string item = (string)dataRow["message"];
                string a    = dataRow["type"].ToString().ToLower();

                if (a != "message")
                {
                    switch (a)
                    {
                    case "roommessage":
                        RoomMessagePresets.Add(item);
                        break;
                    }
                }
                else
                {
                    UserMessagePresets.Add(item);
                }
            }

            foreach (DataRow dataRow2 in table2.Rows)
            {
                SupportTicketHints.Add((string)dataRow2[0], (string)dataRow2[1]);
            }

            foreach (DataRow dataRow3 in table3.Rows)
            {
                ModerationTemplates.Add(uint.Parse(dataRow3["id"].ToString()),
                                        new ModerationTemplate(uint.Parse(dataRow3["id"].ToString()),
                                                               short.Parse(dataRow3["category"].ToString()), dataRow3["cName"].ToString(),
                                                               dataRow3["caption"].ToString(), dataRow3["warning_message"].ToString(),
                                                               dataRow3["ban_message"].ToString(), short.Parse(dataRow3["ban_hours"].ToString()),
                                                               dataRow3["avatar_ban"].ToString() == "1", dataRow3["mute"].ToString() == "1",
                                                               dataRow3["trade_lock"].ToString() == "1"));
            }
        }
        protected override void OnTextChanged(EventArgs e)
        {
            if (linkText != null && linkText.Count > 0)
            {
                int p = this.SelectionStart;
                if (p > 0)
                {
                    Select(p - 1, 1);
                }
                if (GetSelectionLink() == 1)
                {
                    return;
                }
                SelectedRtf = "";
                if (!this.Rtf.Contains("\\v0"))
                {
                    currentText = "";
                    linkText.Clear();
                }
                if (linkText.Count > 0)                                          // Text.Length > linkText.Count)
                {
                    currentText = Text.Substring(Text.LastIndexOf("#Edit") + 5); //Text.Substring(Text.IndexOf(linkText[linkText.Keys[linkText.Count - 1].]) + linkText.Values[linkText.Count - 1].Lenght);
                }
                else
                {
                    currentText = "";
                }
            }
            else
            {
                currentText = Text;
            }

            IsEmail = IsFax = false;
            if (currentText.Trim().Length > 0 && SearchType)
            {
                if (Regex.IsMatch(currentText.Trim(), "([A-Za-z0-9]+([-+._][A-Za-z0-9]+)*@[A-Za-z0-9]+([-._][A-Za-z0-9]+)*.[A-Za-z]{2,})"))
                {
                    IsEmail = true;
                }
                else
                {
                    if (Regex.IsMatch(currentText.Trim().Replace(" ", ""), "^(\\+\\d|\\d).*\\d.*\\d"))
                    {
                        IsFax = true;
                    }
                }
            }
            else
            if (Pids != null)
            {
                Pids.Clear();
            }

            base.OnTextChanged(e);
        }
        private void InitializeMappings()
        {
            using (ILogMethod method = Log.LogMethod(this.DYN_MODULE_NAME, "InitializeMappings"))
            {
                IDictionary <string, IMonitorHandler> handlerInstances = null;

                try
                {
                    _handlerMappings = new StringDictionary <IMonitorHandler>();
                    handlerInstances = new StringDictionary <IMonitorHandler>();

                    foreach (var mappingType in _handlerMappingTypes.AsParallel())
                    {
                        MonitorHandlerBase handler        = null;
                        string             mappingTypeKey = mappingType.Value.FullName;

                        if (handlerInstances.ContainsKey(mappingTypeKey))
                        {
                            handler = handlerInstances[mappingTypeKey] as MonitorHandlerBase;
                        }
                        else
                        {
                            handler = Activator.CreateInstance(mappingType.Value, true) as MonitorHandlerBase;
                            handlerInstances.Add(mappingTypeKey, handler);
                        }

                        if (handler == null)
                        {
                            continue;
                        }
                        if (!_handlerMappings.ContainsKey(mappingType.Key))
                        {
                            _handlerMappings.Add(mappingType.Key, handler);
                        }
                    }

                    const string faultKey = "-1_-1";
                    _faultHandler = _handlerMappings[faultKey];
                }
                catch (Exception ex)
                {
                    method.Exception(ex);
                }
                finally
                {
                    if (handlerInstances != null)
                    {
                        handlerInstances.Clear();
                        handlerInstances = null;
                    }
                }
            }
        }
Example #20
0
        public void ClearProps()
        {
            string id = props[strPropID];
            bool   ll = LongLiver;

            props.Clear();

            props[strPropID] = id;
            if (ll)
            {
                LongLiver = true;
            }
        }
Example #21
0
        void UpdateOpts(string optsString)
        {
            StringCollection tmpUrls;
            StringDictionary tmpOpts;

            Util.GetOpt(optsString, out tmpUrls, out tmpOpts);
            opts.Clear();

            foreach (string optName in tmpOpts.Keys)
            {
                opts.Add(optName, tmpOpts[optName]);
            }
        }
        private static void ReadMap(StringDictionary map, TextReader reader, string mapName)
        {
            map.Clear();

            var mappings = reader.ReadLine().Replace(string.Format("{0}:", mapName), string.Empty).Split(new[] { ';' },
                                                                                                         StringSplitOptions.
                                                                                                         RemoveEmptyEntries);

            foreach (string mapping in mappings)
            {
                string[] parts = mapping.Split(new[] { ':' }, StringSplitOptions.RemoveEmptyEntries);
                map.Add(parts[0], parts[1]);
            }
        }
Example #23
0
        /// <summary>
        /// Disposes the object and frees ressources for the Garbage Collector.
        /// </summary>
        /// <param name="disposing">If true, the object gets disposed.</param>
        protected virtual void Dispose(bool disposing)
        {
            if (this.IsDisposed)
            {
                return;
            }

            if (disposing)
            {
                _ChangedProperties.Clear();
                _BrokenRules.Clear();
                _IsDisposed = true;
            }
        }
Example #24
0
 /// <summary>
 /// Очистка парсера уровня
 /// </summary>
 private void Clear()
 {
     m_width  = 0;
     m_height = 0;
     if (null != m_Dictionary)
     {
         m_Dictionary.Clear();
     }
     if (null != m_LevelArray)
     {
         m_LevelArray.Clear();
     }
     m_nDictionaryKeySize = 1;
 }
        protected override object SetItems(object editValue, object[] value)
        {
            StringDictionary dictionary = editValue as StringDictionary;

            if (dictionary == null)
            {
                throw new ArgumentNullException("editValue");
            }
            dictionary.Clear();
            foreach (EditableDictionaryEntry entry in value)
            {
                dictionary[entry.Name] = entry.Value;
            }
            return(dictionary);
        }
Example #26
0
        public void Empty()
        {
            StringDictionary sd = new StringDictionary();

            Assert.AreEqual(0, sd.Count, "Count");
            Assert.IsFalse(sd.IsSynchronized, "IsSynchronized");
            Assert.AreEqual(0, sd.Keys.Count, "Keys");
            Assert.AreEqual(0, sd.Values.Count, "Values");
            Assert.IsNotNull(sd.SyncRoot, "SyncRoot");
            Assert.IsFalse(sd.ContainsKey("a"), "ContainsKey");
            Assert.IsFalse(sd.ContainsValue("1"), "ContainsValue");
            sd.CopyTo(new DictionaryEntry[0], 0);
            Assert.IsNotNull(sd.GetEnumerator(), "GetEnumerator");
            sd.Remove("a");              // doesn't exists
            sd.Clear();
        }
Example #27
0
        static void Main(string[] args)
        {
            StringDictionary myCol = new StringDictionary();

            myCol.Add("red", "rojo");
            myCol.Add("green", "varde");
            myCol.Add("blue", "azul");
            Console.WriteLine("Initial contens of the StringDictionary.");
            PrintKeysAndValues(myCol);
            myCol.Remove("green");
            Console.WriteLine("The collection contains the following elements after removing \"green\":");
            PrintKeysAndValues(myCol);
            myCol.Clear();
            Console.WriteLine("The collection contains the following elements after it is cleared:");
            PrintKeysAndValues(myCol);
        }
Example #28
0
        /// <summary>
        /// Changes the pdf tex template and returns it
        /// </summary>
        /// <param name="f"></param>
        /// <returns></returns>
        public string AddPDF(MyFile f)
        {
            StringDictionary fields = new StringDictionary();
            string           temp   = f.Path;

            temp = reg.Replace(temp, "/");
            fields.Add("Path", temp);
            string output = "";

            output += re.Replace(TexPDFTemplate, delegate(Match match)
            {
                return(fields[match.Groups[1].Value]);
            });

            output += "\n";
            fields.Clear();
            return(output);
        }
Example #29
0
        /// <summary>
        /// 获取画面控件数据
        /// </summary>
        protected void GetGrpDataItem()
        {
            try
            {
                dicItemData.Clear();
                dicConds.Clear();
                dicLikeConds.Clear();

                this.dicItemData[MasterTableWHS.m_users.user_no] = this.txtUserId.Text.Trim();

                //数据加密处理  this.txtPaswd.Text;
                this.dicItemData[MasterTableWHS.m_users.user_pwd] = Common.EncryptPassWord(this.txtPaswd.Text);

                this.dicConds[MasterTableWHS.m_users.user_no]  = "true";
                this.dicConds[MasterTableWHS.m_users.user_pwd] = "true";
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
Example #30
0
        public void SomeElements()
        {
            StringDictionary sd = new StringDictionary();

            for (int i = 0; i < 10; i++)
            {
                sd.Add(i.ToString(), (i * 10).ToString());
            }
            Assert.AreEqual("10", sd["1"], "this[1]");
            Assert.AreEqual(10, sd.Count, "Count-10");
            Assert.AreEqual(10, sd.Keys.Count, "Keys");
            Assert.AreEqual(10, sd.Values.Count, "Values");
            Assert.IsTrue(sd.ContainsKey("2"), "ContainsKey");
            Assert.IsTrue(sd.ContainsValue("20"), "ContainsValue");
            DictionaryEntry[] array = new DictionaryEntry[10];
            sd.CopyTo(array, 0);
            sd.Remove("1");
            Assert.AreEqual(9, sd.Count, "Count-9");
            sd.Clear();
            Assert.AreEqual(0, sd.Count, "Count-0");
        }
 public virtual bool runTest()
 {
     Console.WriteLine(s_strTFPath + " " + s_strTFName + " , for " + s_strClassMethod + " , Source ver: " + s_strDtTmVer);
     int iCountErrors = 0;
     int iCountTestcases = 0;
     IntlStrings intl;
     String strLoc = "Loc_000oo";
     StringDictionary sd; 
     string [] values = 
     {
         "",
         " ",
         "a",
         "aa",
         "text",
         "     spaces",
         "1",
         "$%^#",
         "2222222222222222222222222",
         System.DateTime.Today.ToString(),
         Int32.MaxValue.ToString()
     };
     string [] keys = 
     {
         "zero",
         "one",
         " ",
         "",
         "aa",
         "1",
         System.DateTime.Today.ToString(),
         "$%^#",
         Int32.MaxValue.ToString(),
         "     spaces",
         "2222222222222222222222222"
     };
     string itm;         
     try
     {
         intl = new IntlStrings(); 
         Console.WriteLine("--- create dictionary ---");
         strLoc = "Loc_001oo"; 
         iCountTestcases++;
         sd = new StringDictionary();
         Console.WriteLine("1. set Item on empty dictionary");
         iCountTestcases++;
         for (int i = 0; i < keys.Length; i++) 
         {
             if (sd.Count > 0)
                 sd.Clear();
             sd[keys[i]] = values[i];
             if (sd.Count != 1) 
             {
                 iCountErrors++;
                 Console.WriteLine("Err_0001a_{0}, didn't add item with {0} key", i);
             }
             if (String.Compare(sd[keys[i]], values[i], false) != 0) 
             {
                 iCountErrors++;
                 Console.WriteLine("Err_0001b_{0}, added wrong value", i);
             }
         }
         Console.WriteLine("2. set Item on filled dictionary");  
         strLoc = "Loc_002oo"; 
         int len = values.Length;
         iCountTestcases++;
         sd.Clear();
         for (int i = 0; i < len; i++) 
         {
             sd.Add(keys[i], values[i]);
         }
         if (sd.Count != len) 
         {
             iCountErrors++;
             Console.WriteLine("Err_0002a, count is {0} instead of {1}", sd.Count, len);
         } 
         for (int i = 0; i < len; i++) 
         {
             iCountTestcases++;
             itm = "item" + i;
             sd[keys[i]] = itm;
             if (String.Compare(sd[keys[i]], itm, false) != 0) 
             {
                 iCountErrors++;
                 Console.WriteLine("Err_0002b_{0}, returned {1} instead of {2}", i, sd[keys[i]], itm);
             } 
         }
         Console.WriteLine("3. set Item on dictionary with duplicate values ");
         strLoc = "Loc_003oo"; 
         iCountTestcases++;
         sd.Clear();
         string intlStr = intl.GetString(MAX_LEN, true, true, true);
         string intlStr1 = intl.GetString(MAX_LEN, true, true, true);
         sd.Add("keykey1", intlStr);        
         for (int i = 0; i < len; i++) 
         {
             sd.Add(keys[i], values[i]);
         }
         sd.Add("keykey2", intlStr);        
         if (sd.Count != len+2) 
         {
             iCountErrors++;
             Console.WriteLine("Err_0003a, count is {0} instead of {1}", sd.Count, len+2);
         } 
         iCountTestcases++;
         sd["keykey1"] = intlStr1;
         if (String.Compare(sd["keykey1"], intlStr1, false) != 0) 
         {
             iCountErrors++;
             Console.WriteLine("Err_0003b, returned {1} instead of {2}", sd["keykey1"],intlStr1);
         } 
         iCountTestcases++;
         sd["keykey2"] = intlStr1;
         if (String.Compare(sd["keykey2"], intlStr1, false) != 0) 
         {
             iCountErrors++;
             Console.WriteLine("Err_0003c, returned {1} instead of {2}", sd["keykey2"],intlStr1);
         } 
         Console.WriteLine("4. set Item on dictionary with intl strings");
         strLoc = "Loc_004oo"; 
         string [] intlValues = new string [len*2];
         string [] intlSets = new string [len];
         for (int i = 0; i < len*2; i++) 
         {
             string val = intl.GetString(MAX_LEN, true, true, true);
             while (Array.IndexOf(intlValues, val) != -1 )
                 val = intl.GetString(MAX_LEN, true, true, true);
             intlValues[i] = val;
         } 
         for (int i = 0; i < len; i++) 
         {
             intlSets[i] = intl.GetString(MAX_LEN, true, true, true);
         } 
         sd.Clear();
         for (int i = 0; i < len; i++) 
         {
             sd.Add(intlValues[i+len], intlValues[i]);
         }
         if (sd.Count != len) 
         {
             iCountErrors++;
             Console.WriteLine("Err_0004a, count is {0} instead of {1}", sd.Count, len);
         }
         for (int i = 0; i < len; i++) 
         {
             iCountTestcases++;
             sd[intlValues[i+len]] = intlSets[i];
             if (String.Compare(sd[intlValues[i+len]], intlSets[i], false) != 0) 
             {
                 iCountErrors++;
                 Console.WriteLine("Err_0002b_{0}, returned {1} instead of {2}", i, sd[intlValues[i+len]], intlSets[i]);
             } 
         }
         Console.WriteLine("5. Case sensitivity");
         strLoc = "Loc_005oo"; 
         iCountTestcases++;
         sd.Clear();
         string [] intlValuesUpper = new string [len];
         for (int i = 0; i < len * 2; i++) 
         {
             intlValues[i] = intlValues[i].ToLower();
         }
         for (int i = 0; i < len; i++) 
         {
             intlValuesUpper[i] = intlValues[i].ToUpper();
         } 
         sd.Clear();
         Console.WriteLine(" ... add Lowercased ...");
         for (int i = 0; i < len; i++) 
         {
             sd.Add(intlValues[i+len], intlValues[i]);     
         }
         if (sd.Count != len) 
         {
             iCountErrors++;
             Console.WriteLine("Err_0005a, count is {0} instead of {1}", sd.Count, len);
         } 
         Console.WriteLine(" ... set to Uppercased ..."); 
         for (int i = 0; i < len; i++) 
         {
             iCountTestcases++;
             sd[intlValues[i+len]] = intlValuesUpper[i];
             if (String.Compare(sd[intlValues[i+len]], intlValuesUpper[i], false) != 0) 
             {
                 iCountErrors++;
                 Console.WriteLine("Err_0005b_{0}, returned {1} instead of {2}", i, sd[intlValues[i+len]], intlValuesUpper[i]);
             } 
         }
         Console.WriteLine("6. set Item(null)");
         strLoc = "Loc_006oo"; 
         iCountTestcases++;
         try 
         {
             sd[null] = intlStr;
             iCountErrors++;
             Console.WriteLine("Err_0006a, no exception");
         }
         catch (ArgumentNullException ex) 
         {
             Console.WriteLine("  expected exception: " + ex.Message);
         }
         catch (Exception e) 
         {
             iCountErrors++;
             Console.WriteLine("Err_0006b, unexpected exception: {0}", e.ToString());
         }
         Console.WriteLine("7. set Item to null");
         strLoc = "Loc_007oo"; 
         iCountTestcases++;
         if (!sd.ContainsKey(keys[0]) ) 
         {
             sd.Add(keys[0], values[0]);
         }
         sd[keys[0]] = null;
         if ( sd[keys[0]] != null )
         {
             iCountErrors++;
             Console.WriteLine("Err_0007, returned non-null");
         }
     } 
     catch (Exception exc_general ) 
     {
         ++iCountErrors;
         Console.WriteLine (s_strTFAbbrev + " : Error Err_general!  strLoc=="+ strLoc +", exc_general==\n"+exc_general.ToString());
     }
     if ( iCountErrors == 0 )
     {
         Console.WriteLine( "Pass.   "+s_strTFPath +" "+s_strTFName+" ,iCountTestcases=="+iCountTestcases);
         return true;
     }
     else
     {
         Console.WriteLine("Fail!   "+s_strTFPath+" "+s_strTFName+" ,iCountErrors=="+iCountErrors+" , BugNums?: "+s_strActiveBugNums );
         return false;
     }
 }
    public virtual bool runTest()
    {
        Console.WriteLine(s_strTFPath + " " + s_strTFName + " , for " + s_strClassMethod + " , Source ver: " + s_strDtTmVer);
        int iCountErrors = 0;
        int iCountTestcases = 0;
        IntlStrings intl;
        String strLoc = "Loc_000oo";
        StringDictionary sd; 
        string [] values = 
        {
            "",
            " ",
            "a",
            "aa",
            "text",
            "     spaces",
            "1",
            "$%^#",
            "2222222222222222222222222",
            System.DateTime.Today.ToString(),
            Int32.MaxValue.ToString()
        };
        string [] keys = 
        {
            "zero",
            "one",
            " ",
            "",
            "aa",
            "1",
            System.DateTime.Today.ToString(),
            "$%^#",
            Int32.MaxValue.ToString(),
            "     spaces",
            "2222222222222222222222222"
        };
        int cnt = 0;            
        string ind;            
        try
        {
            intl = new IntlStrings(); 
            Console.WriteLine("--- create collection ---");
            strLoc = "Loc_001oo"; 
            iCountTestcases++;
            sd = new StringDictionary();
            Console.WriteLine("1. add simple strings");
            for (int i = 0; i < values.Length; i++) 
            {
                iCountTestcases++;
                cnt = sd.Count;
                sd.Add(keys[i], values[i]);
                if (sd.Count != cnt+1) 
                {
                    iCountErrors++;
                    Console.WriteLine("Err_0001_{0}a, count is {1} instead of {2}", i, sd.Count, cnt+1);
                } 
                iCountTestcases++;
                if (!sd.ContainsValue(values[i])) 
                {
                    iCountErrors++;
                    Console.WriteLine("Err_0001_{0}b, collection doesn't contain value of new item", i);
                } 
                iCountTestcases++;
                if (!sd.ContainsKey(keys[i])) 
                {
                    iCountErrors++;
                    Console.WriteLine("Err_0001_{0}c, collection doesn't contain key of new item", i);
                } 
                iCountTestcases++;
                if (String.Compare(sd[keys[i]], values[i], false) != 0) 
                {
                    iCountErrors++;
                    Console.WriteLine("Err_0001_{0}d, returned item \"{1}\" instead of \"{2}\"", i, sd[keys[i]], values[i]);
                } 
            }
            Console.WriteLine("2. add intl strings");
            int len = values.Length;
            string [] intlValues = new string [len * 2];
            for (int i = 0; i < len * 2; i++) 
            {
                string val = intl.GetString(MAX_LEN, true, true, true);
                while (Array.IndexOf(intlValues, val) != -1 )
                    val = intl.GetString(MAX_LEN, true, true, true);
                intlValues[i] = val;
            } 
            Boolean caseInsensitive = false;
            for (int i = 0; i < len * 2; i++) 
            {
                if(intlValues[i].Length!=0 && intlValues[i].ToLower()==intlValues[i].ToUpper())
                    caseInsensitive = true;
            }            
            Console.WriteLine(" initial number of items: " + sd.Count);
            strLoc = "Loc_002oo"; 
            for (int i = 0; i < len; i++) 
            {
                iCountTestcases++;
                cnt = sd.Count;
                sd.Add(intlValues[i+len], intlValues[i]);
                if (sd.Count != cnt+1) 
                {
                    iCountErrors++;
                    Console.WriteLine("Err_0002_{0}a, count is {1} instead of {2}", i, sd.Count, cnt+1);
                } 
                iCountTestcases++;
                if (!sd.ContainsValue(intlValues[i])) 
                {
                    iCountErrors++;
                    Console.WriteLine("Err_0002_{0}b, collection doesn't contain value of new item", i);
                } 
                iCountTestcases++;
                if (!sd.ContainsKey(intlValues[i+len])) 
                {
                    iCountErrors++;
                    Console.WriteLine("Err_0002_{0}c, collection doesn't contain key of new item", i);
                } 
                ind = intlValues[i+len];
                iCountTestcases++;
                if (String.Compare(sd[ind], intlValues[i], false) != 0) 
                {
                    iCountErrors++;
                    Console.WriteLine("Err_0002_{0}d, returned item \"{1}\" instead of \"{2}\"", i, sd[ind], intlValues[i]);
                } 
            }
            Console.WriteLine("3. Case sensitivity");
            string [] intlValuesLower = new string [len * 2];
            for (int i = 0; i < len * 2; i++) 
            {
                intlValues[i] = intlValues[i].ToUpper();
            }
            for (int i = 0; i < len * 2; i++) 
            {
                intlValuesLower[i] = intlValues[i].ToLower();
            } 
            sd.Clear();
            Console.WriteLine(" initial number of items: " + sd.Count);
            strLoc = "Loc_003oo"; 
            for (int i = 0; i < len; i++) 
            {
                iCountTestcases++;
                cnt = sd.Count;
                sd.Add(intlValues[i+len], intlValues[i]);
                if (sd.Count != cnt+1) 
                {
                    iCountErrors++;
                    Console.WriteLine("Err_0003_{0}a, count is {1} instead of {2}", i, sd.Count, cnt+1);
                } 
                iCountTestcases++;
                if (!sd.ContainsValue(intlValues[i])) 
                {
                    iCountErrors++;
                    Console.WriteLine("Err_0003_{0}b, collection doesn't contain value of new item", i);
                } 
                iCountTestcases++;
                if (!sd.ContainsKey(intlValues[i+len])) 
                {
                    iCountErrors++;
                    Console.WriteLine("Err_0003_{0}c, collection doesn't contain key of new item", i);
                } 
                iCountTestcases++;
                if (!caseInsensitive && sd.ContainsValue(intlValuesLower[i])) 
                {
                    iCountErrors++;
                    Console.WriteLine("Err_0003_{0}d, collection contains lowercase value of new item", i);
                } 
                iCountTestcases++;
                if ( !sd.ContainsKey(intlValuesLower[i+len])) 
                {
                    iCountErrors++;
                    Console.WriteLine("Err_0003_{0}e, collection doesn't contain lowercase key of new item", i);
                } 
            }
            Console.WriteLine("4. Add (string, null) ");
            Console.WriteLine(" initial number of items: " + sd.Count);
            strLoc = "Loc_004oo"; 
            iCountTestcases++;
            cnt = sd.Count;
            sd.Add("keykey", null);
            iCountTestcases++;
            if (sd.Count != cnt+1) 
            {
                iCountErrors++;
                Console.WriteLine("Err_0004a, count is {0} instead of {1}", sd.Count, cnt+1);
            } 
            iCountTestcases++;
            if (!sd.ContainsValue(null)) 
            {
                iCountErrors++;
                Console.WriteLine("Err_0004b, collection doesn't contain null");
            }
            iCountTestcases++;
            if (sd["keykey"] != null) 
            {
                iCountErrors++;
                Console.WriteLine("Err_0004c, returned non-null on place of null");
            } 
            Console.WriteLine("5. Add (null, string) ");
            Console.WriteLine(" initial number of items: " + sd.Count);
            strLoc = "Loc_005oo"; 
            iCountTestcases++;
            try 
            {
                sd.Add(null, "item");
                iCountErrors++;
                Console.WriteLine("Err_0005a, ArgumentNullException Expected");
            }
			//                                                                                                                                     
			catch (System.ArgumentNullException e)
			{
				Console.WriteLine("expected exception: {0}", e.ToString());
			} 
            catch (Exception e) 
            {
                iCountErrors++;
                Console.WriteLine("Err_0005b, unexpected exception: " + e.ToString());
            }
            Console.WriteLine("6. Add (key, value) with duplicate key ");
            Console.WriteLine(" initial number of items: " + sd.Count);
            strLoc = "Loc_006oo"; 
            iCountTestcases++;
            string k = intl.GetString(MAX_LEN, true, true, true);
            if (! sd.ContainsKey(k)) 
            {
                sd.Add(k, "newItem");
            }
            if (! sd.ContainsKey(k)) 
            {
                iCountErrors++;
                Console.WriteLine("Err_0005a,failed to add item");
            }
            else 
            {
                try 
                {
                    sd.Add(k, "itemitemitem");
                    iCountErrors++;
                    Console.WriteLine("Err_0005b, no exception");
                }
                catch (ArgumentException ex) 
                {
                    Console.WriteLine("  expected exception: " + ex.Message);
                }
                catch (Exception e) 
                {
                    iCountErrors++;
                    Console.WriteLine("Err_0005c, unexpected exception: " + e.ToString());
                }
            }
        } 
        catch (Exception exc_general ) 
        {
            ++iCountErrors;
            Console.WriteLine (s_strTFAbbrev + " : Error Err_general!  strLoc=="+ strLoc +", exc_general==\n"+exc_general.ToString());
        }
        if ( iCountErrors == 0 )
        {
            Console.WriteLine( "Pass.   "+s_strTFPath +" "+s_strTFName+" ,iCountTestcases=="+iCountTestcases);
            return true;
        }
        else
        {
            Console.WriteLine("Fail!   "+s_strTFPath+" "+s_strTFName+" ,iCountErrors=="+iCountErrors+" , BugNums?: "+s_strActiveBugNums );
            return false;
        }
    }
        private void InitializeMappings()
        {
            using (ILogMethod method = Log.LogMethod(this.DYN_MODULE_NAME, "InitializeMappings"))
            {
                IDictionary<string, IMonitorHandler> handlerInstances = null;

                try
                {
                    _handlerMappings = new StringDictionary<IMonitorHandler>();
                    handlerInstances = new StringDictionary<IMonitorHandler>();

                    foreach (var mappingType in _handlerMappingTypes.AsParallel())
                    {
                        MonitorHandlerBase handler = null;
                        string mappingTypeKey = mappingType.Value.FullName;

                        if (handlerInstances.ContainsKey(mappingTypeKey))
                        {
                            handler = handlerInstances[mappingTypeKey] as MonitorHandlerBase;
                        }
                        else
                        {
                            handler = Activator.CreateInstance(mappingType.Value, true) as MonitorHandlerBase;
                            handlerInstances.Add(mappingTypeKey, handler);
                        }

                        if (handler == null) continue;
                        if (!_handlerMappings.ContainsKey(mappingType.Key))
                        {
                            _handlerMappings.Add(mappingType.Key, handler);
                        }
                    }

                    const string faultKey = "-1_-1";
                    _faultHandler = _handlerMappings[faultKey];
                }
                catch (Exception ex)
                {
                    method.Exception(ex);
                }
                finally
                {
                    if (handlerInstances != null)
                    {
                        handlerInstances.Clear();
                        handlerInstances = null;
                    }
                }
            }
        }
 public virtual bool runTest()
 {
     Console.WriteLine(s_strTFPath + " " + s_strTFName + " , for " + s_strClassMethod + " , Source ver: " + s_strDtTmVer);
     int iCountErrors = 0;
     int iCountTestcases = 0;
     IntlStrings intl;
     String strLoc = "Loc_000oo";
     StringDictionary sd; 
     string [] values = 
     {
         "",
         " ",
         "a",
         "aa",
         "text",
         "     spaces",
         "1",
         "$%^#",
         "2222222222222222222222222",
         System.DateTime.Today.ToString(),
         Int32.MaxValue.ToString()
     };
     string [] keys = 
     {
         "zero",
         "one",
         " ",
         "",
         "aa",
         "1",
         System.DateTime.Today.ToString(),
         "$%^#",
         Int32.MaxValue.ToString(),
         "     spaces",
         "2222222222222222222222222"
     };
     int cnt = 0;            
     try
     {
         intl = new IntlStrings(); 
         Console.WriteLine("--- create dictionary ---");
         strLoc = "Loc_001_oo"; 
         iCountTestcases++;
         sd = new StringDictionary();
         Console.WriteLine("1. Count of empty dictionary");
         strLoc = "Loc_001oo"; 
         iCountTestcases++;
         cnt = sd.Count;
         if ( cnt != 0) 
         {
             iCountErrors++;
             Console.WriteLine("Err_0001a, count is {0} instead of {1} after default ctor", sd.Count, 0);
         }
         sd.Clear();
         cnt = sd.Count;
         if ( cnt != 0) 
         {
             iCountErrors++;
             Console.WriteLine("Err_0001b, count is {0} instead of {1} after Clear()", sd.Count, 0);
         }
         Console.WriteLine("2. add simple strings and Clear()");
         strLoc = "Loc_002oo"; 
         iCountTestcases++;
         cnt = sd.Count;
         for (int i = 0; i < values.Length; i++) 
         {    
             sd.Add(keys[i], values[i]);
         }
         if (sd.Count != values.Length) 
         {
             iCountErrors++;
             Console.WriteLine("Err_0002a, count is {0} instead of {1}", sd.Count, values.Length);
         }
         iCountTestcases++;
         sd.Clear();
         cnt = sd.Count;
         if ( cnt != 0) 
         {
             iCountErrors++;
             Console.WriteLine("Err_0002b, count is {0} instead of {1} after Clear()", sd.Count, 0);
         }
         Console.WriteLine("3. add intl strings and Clear()");
         strLoc = "Loc_003oo"; 
         int len = values.Length;
         string [] intlValues = new string [len * 2];
         for (int i = 0; i < len * 2; i++) 
         {
             string val = intl.GetString(MAX_LEN, true, true, true);
             while (Array.IndexOf(intlValues, val) != -1 )
                 val = intl.GetString(MAX_LEN, true, true, true);
             intlValues[i] = val;
         } 
         cnt = sd.Count;
         iCountTestcases++;
         for (int i = 0; i < len; i++) 
         {    
             sd.Add(intlValues[i+len], intlValues[i]);
         }
         if (sd.Count != (cnt + len)) 
         {
             iCountErrors++;
             Console.WriteLine("Err_0003a, count is {0} instead of {1}", sd.Count, cnt + len);
         }
         iCountTestcases++;
         sd.Clear();
         cnt = sd.Count;
         if ( cnt != 0) 
         {
             iCountErrors++;
             Console.WriteLine("Err_0003b, count is {0} instead of {1} after Clear()", sd.Count, 0);
         }
     } 
     catch (Exception exc_general ) 
     {
         ++iCountErrors;
         Console.WriteLine (s_strTFAbbrev + " : Error Err_general!  strLoc=="+ strLoc +", exc_general==\n"+exc_general.ToString());
     }
     if ( iCountErrors == 0 )
     {
         Console.WriteLine( "Pass.   "+s_strTFPath +" "+s_strTFName+" ,iCountTestcases=="+iCountTestcases);
         return true;
     }
     else
     {
         Console.WriteLine("Fail!   "+s_strTFPath+" "+s_strTFName+" ,iCountErrors=="+iCountErrors+" , BugNums?: "+s_strActiveBugNums );
         return false;
     }
 }
Example #35
0
 public virtual bool runTest()
 {
     Console.WriteLine(s_strTFPath + " " + s_strTFName + " , for " + s_strClassMethod + " , Source ver: " + s_strDtTmVer);
     int iCountErrors = 0;
     int iCountTestcases = 0;
     IntlStrings intl;
     String strLoc = "Loc_000oo";
     StringDictionary sd; 
     string [] values = 
     {
         "",
         " ",
         "a",
         "aa",
         "text",
         "     spaces",
         "1",
         "$%^#",
         "2222222222222222222222222",
         System.DateTime.Today.ToString(),
         Int32.MaxValue.ToString()
     };
     string [] keys = 
     {
         "zero",
         "one",
         " ",
         "",
         "aa",
         "1",
         System.DateTime.Today.ToString(),
         "$%^#",
         Int32.MaxValue.ToString(),
         "     spaces",
         "2222222222222222222222222"
     };
     int cnt = 0;
     try
     {
         intl = new IntlStrings(); 
         Console.WriteLine("--- create dictionary ---");
         strLoc = "Loc_001oo"; 
         iCountTestcases++;
         sd = new StringDictionary();
         Console.WriteLine("1. Remove() from empty dictionary");
         iCountTestcases++;
         if (sd.Count > 0)
             sd.Clear();
         for (int i = 0; i < keys.Length; i++) 
         {
             sd.Remove(keys[0]);
         }
         Console.WriteLine("2. Remove() on filled dictionary");  
         strLoc = "Loc_002oo"; 
         int len = values.Length;
         iCountTestcases++;
         sd.Clear();
         for (int i = 0; i < len; i++) 
         {
             sd.Add(keys[i], values[i]);
         }
         if (sd.Count != len) 
         {
             iCountErrors++;
             Console.WriteLine("Err_0002a, count is {0} instead of {1}", sd.Count, len);
         } 
         for (int i = 0; i < len; i++) 
         {
             iCountTestcases++;
             cnt = sd.Count;
             sd.Remove(keys[i]);
             if (sd.Count != cnt - 1) 
             {
                 iCountErrors++;
                 Console.WriteLine("Err_0002b_{0}, didn't remove element with {0} key", i);
             } 
             iCountTestcases++;
             if ( sd.ContainsValue(values[i]) ) 
             {
                 iCountErrors++;
                 Console.WriteLine("Err_0002c_{0}, removed wrong value", i);
             } 
             iCountTestcases++;
             if ( sd.ContainsKey(keys[i]) ) 
             {
                 iCountErrors++;
                 Console.WriteLine("Err_0002d_{0}, removed wrong value", i);
             } 
         }
         Console.WriteLine("3. Remove() on dictionary with duplicate values ");
         strLoc = "Loc_003oo"; 
         iCountTestcases++;
         sd.Clear();
         string intlStr = intl.GetString(MAX_LEN, true, true, true);
         sd.Add("keykey1", intlStr);        
         for (int i = 0; i < len; i++) 
         {
             sd.Add(keys[i], values[i]);
         }
         sd.Add("keykey2", intlStr);        
         if (sd.Count != len+2) 
         {
             iCountErrors++;
             Console.WriteLine("Err_0003a, count is {0} instead of {1}", sd.Count, len+2);
         } 
         iCountTestcases++;
         sd.Remove("keykey2");
         if (!sd.ContainsValue(intlStr)) 
         {
             iCountErrors++;
             Console.WriteLine("Err_0003b, removed both duplicates");
         }
         if ( sd.ContainsKey("keykey2") ) 
         {
             iCountErrors++;
             Console.WriteLine("Err_0003c, removed not given instance");
         }
         if (! sd.ContainsKey("keykey1") ) 
         {
             iCountErrors++;
             Console.WriteLine("Err_0003d, removed wrong instance");
         }
         Console.WriteLine("4. Remove() from dictionary with intl strings");
         strLoc = "Loc_004oo"; 
         string [] intlValues = new string [len*2];
         for (int i = 0; i < len*2; i++) 
         {
             string val = intl.GetString(MAX_LEN, true, true, true);
             while (Array.IndexOf(intlValues, val) != -1 )
                 val = intl.GetString(MAX_LEN, true, true, true);
             intlValues[i] = val;
         } 
         sd.Clear();
         for (int i = 0; i < len; i++) 
         {
             sd.Add(intlValues[i+len], intlValues[i]);
         }
         if (sd.Count != len) 
         {
             iCountErrors++;
             Console.WriteLine("Err_0004a, count is {0} instead of {1}", sd.Count, len);
         }
         for (int i = 0; i < len; i++) 
         {
             iCountTestcases++;
             cnt = sd.Count;
             sd.Remove(intlValues[i+len]);
             if (sd.Count != cnt - 1) 
             {
                 iCountErrors++;
                 Console.WriteLine("Err_0004b_{0}, didn't remove element with {0} key", i+len);
             } 
             iCountTestcases++;
             if ( sd.ContainsValue(intlValues[i]) ) 
             {
                 iCountErrors++;
                 Console.WriteLine("Err_0004c_{0}, removed wrong value", i);
             } 
             iCountTestcases++;
             if ( sd.ContainsKey(intlValues[i+len]) ) 
             {
                 iCountErrors++;
                 Console.WriteLine("Err_0004d_{0}, removed wrong key", i);
             } 
         }
         Console.WriteLine("5. Case sensitivity");
         strLoc = "Loc_005oo"; 
         iCountTestcases++;
         sd.Clear();
         string [] intlValuesUpper = new string [len];
         for (int i = 0; i < len * 2; i++) 
         {
             intlValues[i] = intlValues[i].ToLower();
         }
         for (int i = 0; i < len; i++) 
         {
             intlValuesUpper[i] = intlValues[i+len].ToUpper();
         } 
         sd.Clear();
         Console.WriteLine(" ... add Lowercased ...");
         for (int i = 0; i < len; i++) 
         {
             sd.Add(intlValues[i+len], intlValues[i]);     
         }
         if (sd.Count != len) 
         {
             iCountErrors++;
             Console.WriteLine("Err_0005a, count is {0} instead of {1}", sd.Count, len);
         } 
         Console.WriteLine(" ... remove Uppercased ..."); 
         for (int i = 0; i < len; i++) 
         {
             iCountTestcases++;
             cnt = sd.Count;
             sd.Remove(intlValuesUpper[i]);
             if (sd.Count != cnt - 1) 
             {
                 iCountErrors++;
                 Console.WriteLine("Err_0005b_{0}, didn't remove element with {0} lower key", i+len);
             } 
             iCountTestcases++;
             if ( sd.ContainsValue(intlValues[i]) ) 
             {
                 iCountErrors++;
                 Console.WriteLine("Err_0005c_{0}, removed wrong value", i);
             } 
             iCountTestcases++;
             if ( sd.ContainsKey(intlValuesUpper[i]) ) 
             {
                 iCountErrors++;
                 Console.WriteLine("Err_0005d_{0}, removed wrong key", i);
             } 
         }
         Console.WriteLine("6. Remove(null)");
         strLoc = "Loc_006oo"; 
         iCountTestcases++;
         try 
         {
             sd.Remove(null);
             iCountErrors++;
             Console.WriteLine("Err_0006a, no exception");
         }
         catch (NullReferenceException ex) 
         {
             Console.WriteLine("  expected exception: " + ex.Message);
         }
         catch (Exception e) 
         {
             iCountErrors++;
             Console.WriteLine("Err_0006b, unexpected exception: {0}", e.ToString());
         }
     } 
     catch (Exception exc_general ) 
     {
         ++iCountErrors;
         Console.WriteLine (s_strTFAbbrev + " : Error Err_general!  strLoc=="+ strLoc +", exc_general==\n"+exc_general.ToString());
     }
     if ( iCountErrors == 0 )
     {
         Console.WriteLine( "Pass.   "+s_strTFPath +" "+s_strTFName+" ,iCountTestcases=="+iCountTestcases);
         return true;
     }
     else
     {
         Console.WriteLine("Fail!   "+s_strTFPath+" "+s_strTFName+" ,iCountErrors=="+iCountErrors+" , BugNums?: "+s_strActiveBugNums );
         return false;
     }
 }
Example #36
0
    // pseudo SAX reader
    public static void xmlparse(string fname)
    {
        XmlReader reader = new XmlTextReader(fname);
        string line;

        urls    =       new ArrayList();
        int cnt  = 0;
        // http://msdn.microsoft.com/en-us/library/1z92b1d4.aspx
        // http://msdn.microsoft.com/en-us/library/system.xml.xmlreader.readsubtree.aspx
        while (reader.Read()) {
        if (reader.MoveToContent() == XmlNodeType.Element &&
            reader.Name == "formvals") {

            XmlReader inner = reader.ReadSubtree();
            StringDictionary myCol = new StringDictionary();
            while (inner.Read()) {

                if (inner.MoveToContent() == XmlNodeType.Element &&
                    inner.Name == "input") {

                    inner.MoveToFirstAttribute();
        // to avoid dependency on the attribute order, key them by the attribute name
        // amended with the unique count of the current input element.
                    myCol.Add(String.Format("{0}-{1}", inner.Name, cnt.ToString()), inner.Value);
                    inner.MoveToNextAttribute();
                    myCol.Add(String.Format("{0}-{1}", inner.Name, cnt.ToString()), inner.Value);
                    cnt++;
                }

                DictionaryEntry[] myArr = new DictionaryEntry[myCol.Count];
                myCol.CopyTo(myArr, 0);

                for (int i = 0; i < myArr.Length; i++) {

                    try{

                        string inputNameRegExp = @"name\-(?<input>\d+)";
                        MatchCollection myMatchCollection =
                            Regex.Matches(myArr[i].Key.ToString(), inputNameRegExp );

                        foreach (Match myMatch in myMatchCollection) {

                            string pos =  myMatch.Groups["input"].Value.ToString();
                            // do not use StringDictionary for final formvals or you have your keyc converted to lower case.
                            formvals.Add(myCol[String.Format("name-{0}", pos)], myCol[String.Format("value-{0}", pos)]);

                        }
                    } catch (Exception e) {
                        Console.WriteLine(e.ToString());
                    }

                }
                myCol.Clear();
            }
            foreach ( KeyValuePair<string, string> kvp in formvals )
                Console.WriteLine("formvals[ {0} ] = {1}", kvp.Key, kvp.Value);

            inner.Close();

        }
        if (reader.MoveToContent() == XmlNodeType.Element &&   reader.Name == "url") {
            line    =       reader.ReadString();
            urls.Add(line);
            Console.WriteLine(line);
        }
        }
    }
 public virtual bool runTest()
 {
     Console.WriteLine(s_strTFPath + " " + s_strTFName + " , for " + s_strClassMethod + " , Source ver: " + s_strDtTmVer);
     int iCountErrors = 0;
     int iCountTestcases = 0;
     String strLoc = "Loc_000oo";
     StringDictionary sd; 
     IEnumerator en; 
     DictionaryEntry curr;        
     string [] values = 
     {
         "a",
         "aa",
         "",
         " ",
         "text",
         "     spaces",
         "1",
         "$%^#",
         "2222222222222222222222222",
         System.DateTime.Today.ToString(),
         Int32.MaxValue.ToString()
     };
     string [] keys = 
     {
         "zero",
         "one",
         " ",
         "",
         "aa",
         "1",
         System.DateTime.Today.ToString(),
         "$%^#",
         Int32.MaxValue.ToString(),
         "     spaces",
         "2222222222222222222222222"
     };
     try
     {
         Console.WriteLine("--- create dictionary ---");
         strLoc = "Loc_001oo"; 
         iCountTestcases++;
         sd = new StringDictionary();
         Console.WriteLine("1. Enumerator for empty dictionary");
         Console.WriteLine("     - get type");
         iCountTestcases++;
         en = sd.GetEnumerator();
         string type = en.GetType().ToString();
         if ( type.IndexOf("Enumerator", 0) == 0 ) 
         {
             iCountErrors++;
             Console.WriteLine("Err_0001a, type is not Enumerator");
         }
         Console.WriteLine("     - MoveNext");
         iCountTestcases++;
         bool res = en.MoveNext();
         if ( res ) 
         {
             iCountErrors++;
             Console.WriteLine("Err_0001b, MoveNext returned true");
         }
         Console.WriteLine("     - Current");
         iCountTestcases++;
         try 
         {
             curr = (DictionaryEntry)en.Current;
             iCountErrors++;
             Console.WriteLine("Err_0001c, no exception");
         }
         catch (InvalidOperationException ex) 
         {
             Console.WriteLine("  expected exception: " + ex.Message);
         }
         catch (Exception e) 
         {
             iCountErrors++;
             Console.WriteLine("Err_0001d, unexpected exception: {0}", e.ToString());
         }
         Console.WriteLine("2. GetEnumerator for filled collection");
         strLoc = "Loc_002oo"; 
         iCountTestcases++;
         for (int i = 0; i < values.Length; i++) 
         {
             sd.Add(keys[i], values[i]);
         }
         Console.WriteLine("     - get type");
         iCountTestcases++;
         en = sd.GetEnumerator();
         type = en.GetType().ToString();
         if ( type.IndexOf("Enumerator", 0) == 0 ) 
         {
             iCountErrors++;
             Console.WriteLine("Err_0002a, type is not Enumerator");
         }
         Console.WriteLine("     - MoveNext and Current within collection");
         for (int i = 0; i < sd.Count; i++) 
         {
             iCountTestcases++;
             res = en.MoveNext();
             if ( !res ) 
             {
                 iCountErrors++;
                 Console.WriteLine("Err_0002b_{0}, MoveNext returned false", i);
             }
             iCountTestcases++;
             curr = (DictionaryEntry)en.Current;
             if (! sd.ContainsValue(curr.Value.ToString()) ) 
             {
                 iCountErrors++;
                 Console.WriteLine("Err_0002c_{0}, Current dictionary doesn't contain value from enumerator", i);
             }
             iCountTestcases++;
             if (! sd.ContainsKey(curr.Key.ToString()) ) 
             {
                 iCountErrors++;
                 Console.WriteLine("Err_0002d_{0}, Current dictionary doesn't contain key from enumerator", i);
             }
             iCountTestcases++;
             if ( String.Compare(sd[curr.Key.ToString()], curr.Value.ToString(), false) != 0 ) 
             {
                 iCountErrors++;
                 Console.WriteLine("Err_0002e_{0}, Value for current Key is different in dictionary", i);
             }
             iCountTestcases++;
             DictionaryEntry curr1 = (DictionaryEntry)en.Current;
             if (! curr.Equals(curr1) ) 
             {
                 iCountErrors++;
                 Console.WriteLine("Err_0002f_{0}, second call of Current returned different result", i);
             }
         }
         res = en.MoveNext();
         Console.WriteLine("     - MoveNext outside of the collection");
         iCountTestcases++;
         res = en.MoveNext();
         if ( res ) 
         {
             iCountErrors++;
             Console.WriteLine("Err_0002g, MoveNext returned true");
         }
         Console.WriteLine("     - Current outside of the collection");
         iCountTestcases++;
         try 
         {
             curr = (DictionaryEntry)en.Current;
             iCountErrors++;
             Console.WriteLine("Err_0002h, no exception");
         }
         catch (InvalidOperationException ex) 
         {
             Console.WriteLine("  expected exception: " + ex.Message);
         }
         catch (Exception e) 
         {
             iCountErrors++;
             Console.WriteLine("Err_0002i, unexpected exception: {0}", e.ToString());
         }
         Console.WriteLine("     - Reset");
         iCountTestcases++;
         en.Reset();
         Console.WriteLine("     - get Current after Reset");
         iCountTestcases++;
         try 
         {
             curr = (DictionaryEntry)en.Current;
             iCountErrors++;
             Console.WriteLine("Err_0002j, no exception");
         }
         catch (InvalidOperationException ex) 
         {
             Console.WriteLine("  expected exception: " + ex.Message);
         }
         catch (Exception e) 
         {
             iCountErrors++;
             Console.WriteLine("Err_0002k, unexpected exception: {0}", e.ToString());
         }
         Console.WriteLine("3. Enumerator and modified dictionary");
         strLoc = "Loc_003oo"; 
         iCountTestcases++;
         if (sd.Count < 1) 
         {
             for (int i = 0; i < values.Length; i++) 
             {
                 sd.Add(keys[i], values[i]);
             }
         }
         iCountTestcases++;
         en = sd.GetEnumerator();
         Console.WriteLine("     - MoveNext");
         res = en.MoveNext();
         if (!res) 
         {
             iCountErrors++;
             Console.WriteLine("Err_0003a, MoveNext returned false");
         }
         Console.WriteLine("     - modify collection");
         curr = (DictionaryEntry)en.Current;
         int cnt = sd.Count;
         iCountTestcases++;
         sd.Remove(keys[0]);
         if ( sd.Count != cnt - 1 ) 
         {
             iCountErrors++;
             Console.WriteLine("Err_0003b, didn't remove item with 0th key");
         }
         Console.WriteLine("     - get Current");
         iCountTestcases++;
         DictionaryEntry curr2 = (DictionaryEntry)en.Current;
         if (! curr.Equals(curr2) ) 
         {
             iCountErrors++;
             Console.WriteLine("Err_0003c, current returned different value after midification");
         }
         Console.WriteLine("     - call MoveNext");
         iCountTestcases++;
         try 
         {
             res = en.MoveNext();
             iCountErrors++;
             Console.WriteLine("Err_0003d, no exception");
         }
         catch (InvalidOperationException ex) 
         {
             Console.WriteLine("  expected exception: " + ex.Message);
         }
         catch (Exception e) 
         {
             iCountErrors++;
             Console.WriteLine("Err_0003e, unexpected exception: {0}", e.ToString());
         }
         Console.WriteLine("4. Modify dictionary after enumerated beyond the end");
         strLoc = "Loc_004oo"; 
         iCountTestcases++;
         sd.Clear();
         for (int i = 0; i < values.Length; i++) 
         {
             sd.Add(keys[i], values[i]);
         }
         iCountTestcases++;
         en = sd.GetEnumerator();
         for (int i = 0; i < sd.Count; i ++) 
         {
             en.MoveNext();
         }
         Console.WriteLine("     - get Current at the end of the dictionary");
         curr = (DictionaryEntry)en.Current;
         Console.WriteLine("     - modify collection");
         curr = (DictionaryEntry)en.Current;
         cnt = sd.Count;
         iCountTestcases++;
         sd.Remove(keys[0]);
         if ( sd.Count != cnt - 1 ) 
         {
             iCountErrors++;
             Console.WriteLine("Err_0004b, didn't remove item with 0th key");
         }
         Console.WriteLine("     - get Current after modifying");
         iCountTestcases++;
         curr2 = (DictionaryEntry)en.Current;
         if (! curr.Equals(curr2) ) 
         {
             iCountErrors++;
             Console.WriteLine("Err_0004c, current returned different value after midification");
         }
         Console.WriteLine("     - call MoveNext after modifying");
         iCountTestcases++;
         try 
         {
             res = en.MoveNext();
             iCountErrors++;
             Console.WriteLine("Err_0004d, no exception");
         }
         catch (InvalidOperationException ex) 
         {
             Console.WriteLine("  expected exception: " + ex.Message);
         }
         catch (Exception e) 
         {
             iCountErrors++;
             Console.WriteLine("Err_0004e, unexpected exception: {0}", e.ToString());
         }
     } 
     catch (Exception exc_general ) 
     {
         ++iCountErrors;
         Console.WriteLine (s_strTFAbbrev + " : Error Err_general!  strLoc=="+ strLoc +", exc_general==\n"+exc_general.ToString());
     }
     if ( iCountErrors == 0 )
     {
         Console.WriteLine( "Pass.   "+s_strTFPath +" "+s_strTFName+" ,iCountTestcases=="+iCountTestcases);
         return true;
     }
     else
     {
         Console.WriteLine("Fail!   "+s_strTFPath+" "+s_strTFName+" ,iCountErrors=="+iCountErrors+" , BugNums?: "+s_strActiveBugNums );
         return false;
     }
 }
Example #38
0
 public virtual bool runTest()
 {
     Console.WriteLine(s_strTFPath + " " + s_strTFName + " , for " + s_strClassMethod + " , Source ver: " + s_strDtTmVer);
     int iCountErrors = 0;
     int iCountTestcases = 0;
     IntlStrings intl;
     String strLoc = "Loc_000oo";
     StringDictionary sd; 
     string ind;
     string [] values = 
     {
         "",
         " ",
         "a",
         "aa",
         "text",
         "     spaces",
         "1",
         "$%^#",
         "2222222222222222222222222",
         System.DateTime.Today.ToString(),
         Int32.MaxValue.ToString()
     };
     string [] keys = 
     {
         "zero",
         "one",
         " ",
         "",
         "aa",
         "1",
         System.DateTime.Today.ToString(),
         "$%^#",
         Int32.MaxValue.ToString(),
         "     spaces",
         "2222222222222222222222222"
     };
     int cnt = 0;            
     try
     {
         intl = new IntlStrings(); 
         Console.WriteLine("--- create collection ---");
         strLoc = "Loc_001oo"; 
         iCountTestcases++;
         sd = new StringDictionary();
         Console.WriteLine("1. Check for empty dictionary");
         for (int i = 0; i < values.Length; i++) 
         {
             iCountTestcases++;
             if (sd.ContainsValue(values[i])) 
             {
                 iCountErrors++;
                 Console.WriteLine("Err_0001_{0}, returned true for empty dictionary", i);
             }
         } 
         Console.WriteLine("2. add simple strings and verify ContainsValue()");
         strLoc = "Loc_002oo"; 
         iCountTestcases++;
         cnt = values.Length;
         for (int i = 0; i < cnt; i++) 
         {
             sd.Add(keys[i], values[i]);
         }
         if (sd.Count != cnt) 
         {
             iCountErrors++;
             Console.WriteLine("Err_0002a, count is {0} instead of {1}", sd.Count, cnt);
         } 
         for (int i = 0; i < cnt; i++) 
         {
             iCountTestcases++;
             if (!sd.ContainsValue(values[i])) 
             {
                 iCountErrors++;
                 Console.WriteLine("Err_0002_{0}b, collection doesn't contain value \"{1}\"", i, values[i]);
             } 
             iCountTestcases++;
             if (!sd.ContainsKey(keys[i])) 
             {
                 iCountErrors++;
                 Console.WriteLine("Err_0002_{0}c, collection doesn't contain key \"{1}\"", i, keys[i]);
             } 
         }
         Console.WriteLine("3. add intl strings and verify ContainsValue()");
         strLoc = "Loc_003oo"; 
         int len = values.Length;
         string [] intlValues = new string [len*2];
         for (int i = 0; i < len*2; i++) 
         {
             string val = intl.GetString(MAX_LEN, true, true, true);
             while (Array.IndexOf(intlValues, val) != -1 )
                 val = intl.GetString(MAX_LEN, true, true, true);
             intlValues[i] = val;
         } 
         Boolean caseInsensitive = false;
         for (int i = 0; i < len * 2; i++) 
         {
             if(intlValues[i].Length!=0 && intlValues[i].ToLower()==intlValues[i].ToUpper())
                 caseInsensitive = true;
         }
         for (int i = 0; i < len; i++) 
         {
             iCountTestcases++;
             cnt = sd.Count;
             sd.Add(intlValues[i+len], intlValues[i]);
             if (sd.Count != cnt+1) 
             {
                 iCountErrors++;
                 Console.WriteLine("Err_0003_{0}a, count is {1} instead of {2}", i, sd.Count, cnt+1);
             } 
             iCountTestcases++;
             if (!sd.ContainsValue(intlValues[i])) 
             {
                 iCountErrors++;
                 Console.WriteLine("Err_0003_{0}b, collection doesn't contain value of new item", i);
             } 
             iCountTestcases++;
             if (!sd.ContainsKey(intlValues[i+len])) 
             {
                 iCountErrors++;
                 Console.WriteLine("Err_0003_{0}c, collection doesn't contain key of new item", i);
             } 
             ind = intlValues[i+len];
             iCountTestcases++;
             if (String.Compare(sd[ind], intlValues[i], false) != 0) 
             {
                 iCountErrors++;
                 Console.WriteLine("Err_0003_{0}d, returned item \"{1}\" instead of \"{2}\"", i, sd[ind], intlValues[i]);
             } 
         }
         Console.WriteLine("4. add null string with non-null key and verify ContainsValue()");
         strLoc = "Loc_004oo"; 
         iCountTestcases++;
         cnt = sd.Count;
         string k = "keykey";
         sd.Add(k, null);
         if (sd.Count != cnt+1) 
         {
             iCountErrors++;
             Console.WriteLine("Err_0004a, count is {1} instead of {2}", sd.Count, cnt+1);
         } 
         iCountTestcases++;
         if (!sd.ContainsValue(null)) 
         {
             iCountErrors++;
             Console.WriteLine("Err_0004b, dictionary doesn't contain value null");
         }
         Console.WriteLine("5. Case sensitivity");
         strLoc = "Loc_005oo"; 
         iCountTestcases++;
         sd.Clear();
         if (sd.Count != 0) 
         {
             iCountErrors++;
             Console.WriteLine("Err_0005, count is {1} instead of {2} after Clear()", sd.Count, 0);
         } 
         string [] intlValuesLower = new string [len * 2];
         for (int i = 0; i < len * 2; i++) 
         {
             intlValues[i] = intlValues[i].ToUpper();
         }
         for (int i = 0; i < len * 2; i++) 
         {
             intlValuesLower[i] = intlValues[i].ToLower();
         } 
         sd.Clear();
         for (int i = 0; i < len; i++) 
         {
             iCountTestcases++;
             cnt = sd.Count;
             sd.Add(intlValues[i+len], intlValues[i]);     
             if (sd.Count != cnt+1) 
             {
                 iCountErrors++;
                 Console.WriteLine("Err_0005_{0}a, count is {1} instead of {2}", i, sd.Count, cnt+1);
             } 
             iCountTestcases++;
             if (!sd.ContainsValue(intlValues[i])) 
             {
                 iCountErrors++;
                 Console.WriteLine("Err_0005_{0}b, collection doesn't contain value of new item", i);
             } 
             iCountTestcases++;
             if (!sd.ContainsKey(intlValues[i+len])) 
             {
                 iCountErrors++;
                 Console.WriteLine("Err_0005_{0}c, collection doesn't contain key of new item", i);
             } 
             iCountTestcases++;
             if (!caseInsensitive && sd.ContainsValue(intlValuesLower[i])) 
             {
                 iCountErrors++;
                 Console.WriteLine("Err_0005_{0}d, collection contains lowercase value of new item", i);
             } 
             iCountTestcases++;
             if ( !sd.ContainsKey(intlValuesLower[i+len])) 
             {
                 iCountErrors++;
                 Console.WriteLine("Err_0005_{0}e, collection doesn't contain lowercase key of new item", i);
             } 
         }
     } 
     catch (Exception exc_general ) 
     {
         ++iCountErrors;
         Console.WriteLine (s_strTFAbbrev + " : Error Err_general!  strLoc=="+ strLoc +", exc_general==\n"+exc_general.ToString());
     }
     if ( iCountErrors == 0 )
     {
         Console.WriteLine( "Pass.   "+s_strTFPath +" "+s_strTFName+" ,iCountTestcases=="+iCountTestcases);
         return true;
     }
     else
     {
         Console.WriteLine("Fail!   "+s_strTFPath+" "+s_strTFName+" ,iCountErrors=="+iCountErrors+" , BugNums?: "+s_strActiveBugNums );
         return false;
     }
 }
Example #39
0
 public virtual bool runTest()
 {
     Console.WriteLine(s_strTFPath + " " + s_strTFName + " , for " + s_strClassMethod + " , Source ver: " + s_strDtTmVer);
     int iCountErrors = 0;
     int iCountTestcases = 0;
     IntlStrings intl;
     String strLoc = "Loc_000oo";
     StringDictionary sd; 
     string [] values = 
     {
         "",
         " ",
         "a",
         "aa",
         "tExt",
         "     spAces",
         "1",
         "$%^#",
         "2222222222222222222222222",
         System.DateTime.Today.ToString(),
         Int32.MaxValue.ToString()
     };
     string [] keys = 
     {
         "zero",
         "one",
         " ",
         "",
         "aa",
         "1",
         System.DateTime.Today.ToString(),
         "$%^#",
         Int32.MaxValue.ToString(),
         "     spaces",
         "2222222222222222222222222"
     };
     Array arr;
     ICollection vs;         
     int ind;
     try
     {
         intl = new IntlStrings(); 
         Console.WriteLine("--- create dictionary ---");
         strLoc = "Loc_001oo"; 
         iCountTestcases++;
         sd = new StringDictionary();
         Console.WriteLine("1. get Values for empty dictionary");
         iCountTestcases++;
         if (sd.Count > 0)
             sd.Clear();
         if (sd.Values.Count != 0) 
         {
             iCountErrors++;
             Console.WriteLine("Err_0001, returned Values.Count = {0}", sd.Values.Count);
         }
         Console.WriteLine("2. get Values on filled dictionary");  
         strLoc = "Loc_002oo"; 
         int len = values.Length;
         iCountTestcases++;
         sd.Clear();
         for (int i = 0; i < len; i++) 
         {
             sd.Add(keys[i], values[i]);
         }
         if (sd.Count != len) 
         {
             iCountErrors++;
             Console.WriteLine("Err_0002a, count is {0} instead of {1}", sd.Count, len);
         } 
         vs = sd.Values;
         if (vs.Count != len) 
         {
             iCountErrors++;
             Console.WriteLine("Err_0002a, returned Values.Count = {0}", vs.Count);
         }
         arr = Array.CreateInstance(typeof(string), len);
         vs.CopyTo(arr, 0);
         for (int i = 0; i < len; i++) 
         {
             iCountTestcases++;
             ind = Array.IndexOf(arr, values[i]);
             if (ind < 0) 
             {
                 iCountErrors++;
                 Console.WriteLine("Err_0002b_{0}, Values doesn't contain \"{1}\" value. Search result: {2}", i, keys[i], ind);
             } 
         }
         Console.WriteLine("3. get Values on dictionary with duplicate values ");
         strLoc = "Loc_003oo"; 
         iCountTestcases++;
         sd.Clear();
         string intlStr = intl.GetString(MAX_LEN, true, true, true);
         sd.Add("keykey1", intlStr);        
         for (int i = 0; i < len; i++) 
         {
             sd.Add(keys[i], values[i]);
         }
         sd.Add("keykey2", intlStr);        
         if (sd.Count != len+2) 
         {
             iCountErrors++;
             Console.WriteLine("Err_0003a, count is {0} instead of {1}", sd.Count, len+2);
         } 
         iCountTestcases++;
         vs = sd.Values;
         if (vs.Count != sd.Count) 
         {
             iCountErrors++;
             Console.WriteLine("Err_0003b, returned Values.Count = {0}", vs.Count);
         }
         arr = Array.CreateInstance(typeof(string), len+2);
         vs.CopyTo(arr, 0);
         for (int i = 0; i < len; i++) 
         {
             iCountTestcases++;
             ind = Array.IndexOf(arr, values[i]);
             if (ind < 0) 
             {
                 iCountErrors++;
                 Console.WriteLine("Err_0003c_{0}, Values doesn't contain \"{1}\" value", i, keys[i]);
             } 
         }
         iCountTestcases++;
         ind = Array.IndexOf(arr, intlStr);
         if (ind < 0) 
         {
             iCountErrors++;
             Console.WriteLine("Err_0003c, Values doesn't contain {0} value", intlStr);
         } 
         Console.WriteLine("4. get Values for dictionary with intl strings");
         strLoc = "Loc_004oo"; 
         string [] intlValues = new string [len*2];
         for (int i = 0; i < len*2; i++) 
         {
             string val = intl.GetString(MAX_LEN, true, true, true);
             while (Array.IndexOf(intlValues, val) != -1 )
                 val = intl.GetString(MAX_LEN, true, true, true);
             intlValues[i] = val;
         } 
         sd.Clear();
         for (int i = 0; i < len; i++) 
         {
             sd.Add(intlValues[i+len], intlValues[i]);
         }
         if (sd.Count != len) 
         {
             iCountErrors++;
             Console.WriteLine("Err_0004a, count is {0} instead of {1}", sd.Count, len);
         }
         vs = sd.Values;
         if (vs.Count != len) 
         {
             iCountErrors++;
             Console.WriteLine("Err_0004b, returned Values.Count = {0}", vs.Count);
         }
         arr = Array.CreateInstance(typeof(string), len);
         vs.CopyTo(arr, 0);
         for (int i = 0; i < arr.Length; i++) 
         {
             iCountTestcases++;
             ind = Array.IndexOf(arr, intlValues[i]);
             if (ind < 0) 
             {
                 iCountErrors++;
                 Console.WriteLine("Err_0004c_{0}, Values doesn't contain \"{1}\" value", i, intlValues[i]);
             } 
         }
         Console.WriteLine("5. Change dictinary and verify case sensitivity");
         strLoc = "Loc_005oo"; 
         iCountTestcases++;
         sd.Clear();
         for (int i = 0; i < len; i++) 
         {
             sd.Add(keys[i], values[i]);
         }
         if (sd.Count != len) 
         {
             iCountErrors++;
             Console.WriteLine("Err_0005a, count is {0} instead of {1}", sd.Count, len);
         } 
         vs = sd.Values;
         if (vs.Count != len) 
         {
             iCountErrors++;
             Console.WriteLine("Err_0005a, returned Values.Count = {0}", vs.Count);
         }
         Console.WriteLine("     - remove element from the dictionary");
         sd.Remove(keys[0]);
         if (sd.Count != len-1) 
         {
             iCountErrors++;
             Console.WriteLine("Err_0005b, didn't remove element");
         } 
         if (vs.Count != len-1) 
         {
             iCountErrors++;
             Console.WriteLine("Err_0005c, Values were not updated after removal");
         }
         iCountTestcases++;
         arr = Array.CreateInstance(typeof(string), sd.Count);
         vs.CopyTo(arr, 0);
         ind = Array.IndexOf(arr, values[0]);
         if (ind >= 0) 
         {
             iCountErrors++;
             Console.WriteLine("Err_0005d, Values still contains removed value " + ind);
         } 
         Console.WriteLine("     - add element to the dictionary");
         sd.Add(keys[0], "new item");
         if (sd.Count != len) 
         {
             iCountErrors++;
             Console.WriteLine("Err_0005e, didn't add element");
         } 
         if (vs.Count != len) 
         {
             iCountErrors++;
             Console.WriteLine("Err_0005f, Values were not updated after addition");
         }
         iCountTestcases++;
         arr = Array.CreateInstance(typeof(string), sd.Count);
         vs.CopyTo(arr, 0);
         ind = Array.IndexOf(arr, "new item");
         if (ind < 0) 
         {
             iCountErrors++;
             Console.WriteLine("Err_0005g, Values doesn't contain added value ");
         } 
         Console.WriteLine("     - set to uppercase");
         sd[keys[0]] = "UPPERCASE";
         if (sd.Count != len) 
         {
             iCountErrors++;
             Console.WriteLine("Err_0005h, Count changed after set");
         } 
         if (vs.Count != len) 
         {
             iCountErrors++;
             Console.WriteLine("Err_0005j, Values.Count changed after set");
         }
         iCountTestcases++;
         arr = Array.CreateInstance(typeof(string), sd.Count);
         vs.CopyTo(arr, 0);
         ind = Array.IndexOf(arr, "UPPERCASE");
         if (ind < 0) 
         {
             iCountErrors++;
             Console.WriteLine("Err_0005k, Values doesn't contain value we just set ");
         } 
         ind = Array.IndexOf(arr, "uppercase");
         if (ind >= 0) 
         {
             iCountErrors++;
             Console.WriteLine("Err_0005m, Values contains lowercase version of value we just set ");
         } 
     } 
     catch (Exception exc_general ) 
     {
         ++iCountErrors;
         Console.WriteLine (s_strTFAbbrev + " : Error Err_general!  strLoc=="+ strLoc +", exc_general==\n"+exc_general.ToString());
     }
     if ( iCountErrors == 0 )
     {
         Console.WriteLine( "Pass.   "+s_strTFPath +" "+s_strTFName+" ,iCountTestcases=="+iCountTestcases);
         return true;
     }
     else
     {
         Console.WriteLine("Fail!   "+s_strTFPath+" "+s_strTFName+" ,iCountErrors=="+iCountErrors+" , BugNums?: "+s_strActiveBugNums );
         return false;
     }
 }
 public virtual bool runTest()
 {
     Console.WriteLine(s_strTFPath + " " + s_strTFName + " , for " + s_strClassMethod + " , Source ver: " + s_strDtTmVer);
     int iCountErrors = 0;
     int iCountTestcases = 0;
     IntlStrings intl;
     String strLoc = "Loc_000oo";
     StringDictionary sd; 
     string [] values = 
     {
         "",
         " ",
         "a",
         "aa",
         "text",
         "     spaces",
         "1",
         "$%^#",
         "2222222222222222222222222",
         System.DateTime.Today.ToString(),
         Int32.MaxValue.ToString()
     };
     string [] keys = 
     {
         "zero",
         "one",
         " ",
         "",
         "aa",
         "1",
         System.DateTime.Today.ToString(),
         "$%^#",
         Int32.MaxValue.ToString(),
         "     spaces",
         "2222222222222222222222222"
     };
     Array destination;
     int cnt = 0;            
     try
     {
         intl = new IntlStrings(); 
         Console.WriteLine("--- create dictionary ---");
         strLoc = "Loc_001oo"; 
         iCountTestcases++;
         sd = new StringDictionary();
         Console.WriteLine("1. Copy empty dictionary into empty array");
         iCountTestcases++;
         destination = Array.CreateInstance(typeof(Object), sd.Count);
         Console.WriteLine("     - CopyTo(arr, -1)");
         try 
         {
             sd.CopyTo(destination, -1);
             iCountErrors++;
             Console.WriteLine("Err_0001a, no exception");
         }
         catch (ArgumentOutOfRangeException ex) 
         {
             Console.WriteLine("  Expected exception: {0}", ex.Message);
         }
         catch (Exception e) 
         {
             iCountErrors++;
             Console.WriteLine("Err_001b, unexpected exception: {0}", e.ToString());
         }
         iCountTestcases++;
         Console.WriteLine("     - CopyTo(arr, 0)");
         try 
         {
             sd.CopyTo(destination, 0);
         }
         catch (Exception e) 
         {
             iCountErrors++;
             Console.WriteLine("Err_001c, unexpected exception: {0}", e.ToString());
         }
         iCountTestcases++;
         Console.WriteLine("     - CopyTo(arr, 1)");
         try 
         {
             sd.CopyTo(destination, 1);
             iCountErrors++;
             Console.WriteLine("Err_0001d, no exception");
         }
         catch (ArgumentException ex) 
         {
             Console.WriteLine("  Expected exception: {0}", ex.Message);
         }
         catch (Exception e) 
         {
             iCountErrors++;
             Console.WriteLine("Err_001e, unexpected exception: {0}", e.ToString());
         }
         Console.WriteLine("2. Copy empty dictionary into non-empty array");
         iCountTestcases++;
         destination = Array.CreateInstance(typeof(Object), values.Length);
         for (int i = 0; i < values.Length; i++) 
         {
             destination.SetValue(values[i], i);
         }
         sd.CopyTo(destination, 0);
         if( destination.Length != values.Length) 
         {
             iCountErrors++;
             Console.WriteLine("Err_0002a, altered array after copying empty collection");
         } 
         if (destination.Length == values.Length) 
         {
             for (int i = 0; i < values.Length; i++) 
             {
                 iCountTestcases++;
                 if (String.Compare(destination.GetValue(i).ToString(), values[i], false) != 0) 
                 {
                     iCountErrors++;
                     Console.WriteLine("Err_0002_{0}b, altered item {0} after copying empty collection", i);
                 }
             } 
         }
         Console.WriteLine("3. add simple strings and CopyTo(Array, 0)");
         strLoc = "Loc_003oo"; 
         iCountTestcases++;
         cnt = sd.Count;
         int len = values.Length;
         for (int i = 0; i < len; i++) 
         {
             sd.Add(keys[i], values[i]);
         }
         if (sd.Count != len) 
         {
             iCountErrors++;
             Console.WriteLine("Err_0003a, count is {0} instead of {1}", sd.Count, values.Length);
         } 
         destination = Array.CreateInstance(typeof(Object), len);
         sd.CopyTo(destination, 0);
         IEnumerator en = sd.GetEnumerator();
         for (int i = 0; i < len; i++) 
         {
             en.MoveNext();
             DictionaryEntry curr = (DictionaryEntry)en.Current;
             iCountTestcases++;
             if ( String.Compare(curr.Value.ToString(), ((DictionaryEntry)destination.GetValue(i)).Value.ToString(), false) != 0 ) 
             {
                 iCountErrors++;
                 Console.WriteLine("Err_0003_{0}b, copied \"{1}\" instead of \"{2}\"", i, ((DictionaryEntry)destination.GetValue(i)).Value, curr.Value);
             }  
             iCountTestcases++;
             if ( String.Compare(curr.Key.ToString(), ((DictionaryEntry)destination.GetValue(i)).Key.ToString(), false) != 0 ) 
             {
                 iCountErrors++;
                 Console.WriteLine("Err_0003_{0}c, copied \"{1}\" instead of \"{2}\"", i, ((DictionaryEntry)destination.GetValue(i)).Key, curr.Key);
             }  
         }
         Console.WriteLine("4. add simple strings and CopyTo(Array, {0})", values.Length);
         sd.Clear();
         strLoc = "Loc_004oo"; 
         iCountTestcases++;
         for (int i = 0; i < len; i++) 
         {
             sd.Add(keys[i], values[i]);
         }
         if (sd.Count != len) 
         {
             iCountErrors++;
             Console.WriteLine("Err_0004a, count is {0} instead of {1}", sd.Count, values.Length);
         } 
         destination = Array.CreateInstance(typeof(Object), len*2);
         sd.CopyTo(destination, len);
         en = sd.GetEnumerator();
         for (int i = 0; i < len; i++) 
         {
             en.MoveNext();
             DictionaryEntry curr = (DictionaryEntry)en.Current;
             iCountTestcases++;
             if ( String.Compare(curr.Value.ToString(), ((DictionaryEntry)destination.GetValue(i+len)).Value.ToString(), false) != 0 ) 
             {
                 iCountErrors++;
                 Console.WriteLine("Err_0003_{0}b, copied \"{1}\" instead of \"{2}\"", i, ((DictionaryEntry)destination.GetValue(i+len)).Value, curr.Value);
             }  
             iCountTestcases++;
             if ( String.Compare(curr.Key.ToString(), ((DictionaryEntry)destination.GetValue(i+len)).Key.ToString(), false) != 0 ) 
             {
                 iCountErrors++;
                 Console.WriteLine("Err_0003_{0}c, copied \"{1}\" instead of \"{2}\"", i, ((DictionaryEntry)destination.GetValue(i+len)).Key, curr.Key);
             }  
         }
         Console.WriteLine("5. add intl strings and CopyTo(Array, 0)");
         strLoc = "Loc_005oo"; 
         iCountTestcases++;
         string [] intlValues = new string [len * 2];
         for (int i = 0; i < len*2; i++) 
         {
             string val = intl.GetString(MAX_LEN, true, true, true);
             while (Array.IndexOf(intlValues, val) != -1 )
                 val = intl.GetString(MAX_LEN, true, true, true);
             intlValues[i] = val;
         } 
         Boolean caseInsensitive = false;
         for (int i = 0; i < len * 2; i++) 
         {
             if(intlValues[i].Length!=0 && intlValues[i].ToLower()==intlValues[i].ToUpper())
                 caseInsensitive = true;
         }            
         iCountTestcases++;
         sd.Clear();
         for (int i = 0; i < len; i++) 
         {
             sd.Add(intlValues[i+len], intlValues[i]);
         } 
         if ( sd.Count != (len) ) 
         {
             iCountErrors++;
             Console.WriteLine("Err_0005a, count is {0} instead of {1}", sd.Count, len);
         } 
         destination = Array.CreateInstance(typeof(Object), len);
         sd.CopyTo(destination, 0);
         en = sd.GetEnumerator();
         for (int i = 0; i < len; i++) 
         {
             en.MoveNext();
             DictionaryEntry curr = (DictionaryEntry)en.Current;
             iCountTestcases++;
             if ( String.Compare(curr.Value.ToString(), ((DictionaryEntry)destination.GetValue(i)).Value.ToString(), false) != 0 ) 
             {
                 iCountErrors++;
                 Console.WriteLine("Err_0003_{0}b, copied \"{1}\" instead of \"{2}\"", i, ((DictionaryEntry)destination.GetValue(i)).Value, curr.Value);
             }  
             iCountTestcases++;
             if ( String.Compare(curr.Key.ToString(), ((DictionaryEntry)destination.GetValue(i)).Key.ToString(), false) != 0 ) 
             {
                 iCountErrors++;
                 Console.WriteLine("Err_0003_{0}c, copied \"{1}\" instead of \"{2}\"", i, ((DictionaryEntry)destination.GetValue(i)).Key, curr.Key);
             }  
         }
         Console.WriteLine("6. add intl strings and CopyTo(Array, {0})", len);
         strLoc = "Loc_006oo"; 
         destination = Array.CreateInstance(typeof(Object), len*2);
         sd.CopyTo(destination, len);
         en = sd.GetEnumerator();
         for (int i = 0; i < len; i++) 
         {
             en.MoveNext();
             DictionaryEntry curr = (DictionaryEntry)en.Current;
             iCountTestcases++;
             if ( String.Compare(curr.Value.ToString(), ((DictionaryEntry)destination.GetValue(i+len)).Value.ToString(), false) != 0 ) 
             {
                 iCountErrors++;
                 Console.WriteLine("Err_0006_{0}a, copied \"{1}\" instead of \"{2}\"", i, ((DictionaryEntry)destination.GetValue(i+len)).Value, curr.Value);
             }  
             iCountTestcases++;
             if ( String.Compare(curr.Key.ToString(), ((DictionaryEntry)destination.GetValue(i+len)).Key.ToString(), false) != 0 ) 
             {
                 iCountErrors++;
                 Console.WriteLine("Err_0006_{0}b, copied \"{1}\" instead of \"{2}\"", i, ((DictionaryEntry)destination.GetValue(i+len)).Key, curr.Key);
             }  
         }
         Console.WriteLine("7. case sensitivity");
         strLoc = "Loc_007oo"; 
         string [] intlValuesLower = new string [len * 2];
         for (int i = 0; i < len * 2; i++) 
         {
             intlValues[i] = intlValues[i].ToUpper();
         }
         for (int i = 0; i < len * 2; i++) 
         {
             intlValuesLower[i] = intlValues[i].ToLower();
         } 
         sd.Clear();
         for (int i = 0; i < len; i++) 
         {
             sd.Add(intlValues[i+len], intlValues[i]);     
         }
         destination = Array.CreateInstance(typeof(Object), len);
         sd.CopyTo(destination, 0);
         en = sd.GetEnumerator();
         for (int i = 0; i < len; i++) 
         {
             en.MoveNext();
             DictionaryEntry curr = (DictionaryEntry)en.Current;
             iCountTestcases++;
             if ( String.Compare(curr.Value.ToString(), ((DictionaryEntry)destination.GetValue(i)).Value.ToString(), false) != 0 ) 
             {
                 iCountErrors++;
                 Console.WriteLine("Err_0006_{0}a, copied \"{1}\" instead of \"{2}\"", i, ((DictionaryEntry)destination.GetValue(i)).Value, curr.Value);
             }
             iCountTestcases++;
             if ( !caseInsensitive && (Array.IndexOf(intlValuesLower, ((DictionaryEntry)destination.GetValue(i)).Value.ToString()) != -1 )) 
             {
                 iCountErrors++;
                 Console.WriteLine("Err_0006_{0}b, copied lowercase string");
             }  
             iCountTestcases++;
             if ( String.Compare(curr.Key.ToString(), ((DictionaryEntry)destination.GetValue(i)).Key.ToString(), false) != 0 ) 
             {
                 iCountErrors++;
                 Console.WriteLine("Err_0006_{0}c, copied \"{1}\" instead of \"{2}\"", i, ((DictionaryEntry)destination.GetValue(i)).Key, curr.Key);
             } 
             iCountTestcases++;
             if ( Array.IndexOf(intlValuesLower, ((DictionaryEntry)destination.GetValue(i)).Key.ToString()) == -1 ) 
             {
                 iCountErrors++;
                 Console.WriteLine("Err_0006_{0}d, copied uppercase key");
             }  
         }
         Console.WriteLine("8. CopyTo(null, int)");
         strLoc = "Loc_008oo"; 
         iCountTestcases++;
         destination = null;
         try 
         {
             sd.CopyTo(destination, 0);
             iCountErrors++;
             Console.WriteLine("Err_0008a: no exception ");
         }
         catch (ArgumentNullException ex) 
         {
             Console.WriteLine("  Expected exception: {0}", ex.Message);
         }
         catch (Exception e) 
         {
             iCountErrors++;
             Console.WriteLine("Err_0008b, unexpected exception: {0}", e.ToString());
         }
         Console.WriteLine("9. CopyTo(Array, -1)");
         strLoc = "Loc_009oo"; 
         iCountTestcases++;
         cnt = sd.Count;
         destination = Array.CreateInstance(typeof(Object), cnt);
         try 
         {
             sd.CopyTo(destination, -1);
             iCountErrors++;
             Console.WriteLine("Err_0009b: no exception ");
         }
         catch (ArgumentOutOfRangeException ex) 
         {
             Console.WriteLine("  Expected exception: {0}", ex.Message);
         }
         catch (Exception e) 
         {
             iCountErrors++;
             Console.WriteLine("Err_0009c, unexpected exception: {0}", e.ToString());
         }
         Console.WriteLine("10. CopyTo(Array, upperBound+1)");
         strLoc = "Loc_0010oo"; 
         iCountTestcases++;
         if (sd.Count < 1) 
         {
             for (int i = 0; i < len; i++) 
             {
                 sd.Add(keys[i], values[i]);
             }
         }
         destination = Array.CreateInstance(typeof(Object), len);
         try 
         {
             sd.CopyTo(destination, len);
             iCountErrors++;
             Console.WriteLine("Err_0010b: no exception ");
         }
         catch (ArgumentException ex) 
         {
             Console.WriteLine("  Expected exception: {0}", ex.Message);
         }
         catch (Exception e) 
         {
             iCountErrors++;
             Console.WriteLine("Err_0010c, unexpected exception: {0}", e.ToString());
         }
         Console.WriteLine("11. CopyTo(Array, upperBound+2)");
         strLoc = "Loc_010oo"; 
         iCountTestcases++;
         try 
         {
             sd.CopyTo(destination, len+1);
             iCountErrors++;
             Console.WriteLine("Err_0011b: no exception ");
         }
         catch (ArgumentException ex) 
         {
             Console.WriteLine("  Expected exception: {0}", ex.Message);
         }
         catch (Exception e) 
         {
             iCountErrors++;
             Console.WriteLine("Err_0011c, unexpected exception: {0}", e.ToString());
         }
         Console.WriteLine("12. CopyTo(Array, not_enough_space)");
         strLoc = "Loc_012oo"; 
         iCountTestcases++;
         try 
         {
             sd.CopyTo(destination, len / 2);
             iCountErrors++;
             Console.WriteLine("Err_0012a: no exception ");
         }
         catch (ArgumentException ex) 
         {
             Console.WriteLine("  Expected exception: {0}", ex.Message);
         }
         catch (Exception e) 
         {
             iCountErrors++;
             Console.WriteLine("Err_0012b, unexpected exception: {0}", e.ToString());
         }
         Console.WriteLine("13. CopyTo(multidim_Array, 0)");
         strLoc = "Loc_013oo"; 
         iCountTestcases++;
         destination = Array.CreateInstance(typeof(Object), len, len);
         try 
         {
             sd.CopyTo(destination, 0);
             iCountErrors++;
             Console.WriteLine("Err_0013a: no exception ");
         }
         catch (ArgumentException ex) 
         {
             Console.WriteLine("  Expected exception: {0}", ex.Message);
         }
         catch (Exception e) 
         {
             iCountErrors++;
             Console.WriteLine("Err_0013b, unexpected exception: {0}", e.ToString());
         }
     } 
     catch (Exception exc_general ) 
     {
         ++iCountErrors;
         Console.WriteLine (s_strTFAbbrev + " : Error Err_general!  strLoc=="+ strLoc +", exc_general==\n"+exc_general.ToString());
     }
     if ( iCountErrors == 0 )
     {
         Console.WriteLine( "Pass.   "+s_strTFPath +" "+s_strTFName+" ,iCountTestcases=="+iCountTestcases);
         return true;
     }
     else
     {
         Console.WriteLine("Fail!   "+s_strTFPath+" "+s_strTFName+" ,iCountErrors=="+iCountErrors+" , BugNums?: "+s_strActiveBugNums );
         return false;
     }
 }