public static void IndexOfTest(StringCollection collection, string[] data) { Assert.All(data, element => Assert.Equal(Array.IndexOf(data, element), collection.IndexOf(element))); Assert.All(data, element => Assert.Equal(Array.IndexOf(data, element), ((IList)collection).IndexOf(element))); Assert.Equal(-1, collection.IndexOf(ElementNotPresent)); Assert.Equal(-1, ((IList)collection).IndexOf(ElementNotPresent)); }
public static int GetImageIndex(string imageName) { int ret = imageTypes.IndexOf(imageName); if (ret < 0) { ret = imageTypes.IndexOf("deprecated_" + imageName); if (ret < 0) { int colonPos = imageName.IndexOf(":"); if (colonPos > 0) { ret = imageTypes.IndexOf(imageName.Substring(colonPos + 1)); } if (ret < 0) { ret = imageTypes.IndexOf("deprecated_" + imageName.Substring(colonPos + 1)); } } if (ret < 0) { ret = GetUnsupportedImageIndex(); } } return(ret); }
public static void Main() { // Creates and initializes a new StringCollection. StringCollection myCol = new StringCollection(); String[] myArr = new String[] { "RED", "orange", "yellow", "RED", "green", "blue", "RED", "indigo", "violet", "RED" }; myCol.AddRange(myArr); Console.WriteLine("Initial contents of the StringCollection:"); PrintValues(myCol); // Removes one element from the StringCollection. myCol.Remove("yellow"); Console.WriteLine("After removing \"yellow\":"); PrintValues(myCol); // Removes all occurrences of a value from the StringCollection. int i = myCol.IndexOf("RED"); while (i > -1) { myCol.RemoveAt(i); i = myCol.IndexOf("RED"); } Console.WriteLine("After removing all occurrences of \"RED\":"); PrintValues(myCol); // Clears the entire collection. myCol.Clear(); Console.WriteLine("After clearing the collection:"); PrintValues(myCol); }
public static void IndexOf_DuplicateTest(StringCollection collection, string[] data) { // Only the index of the first element will be returned. data = data.Distinct().ToArray(); Assert.All(data, element => Assert.Equal(Array.IndexOf(data, element), collection.IndexOf(element))); Assert.All(data, element => Assert.Equal(Array.IndexOf(data, element), ((IList)collection).IndexOf(element))); Assert.Equal(-1, collection.IndexOf(ElementNotPresent)); Assert.Equal(-1, ((IList)collection).IndexOf(ElementNotPresent)); }
public void SetFieldValue(string fieldName, object value) { if (_fields != null) { syncValueArray(); int n = _fields.IndexOf(fieldName); if (n >= 0) { _values[n] = value; } } }
//--------------------------------------------------------------- // Replace all macros in the specified Contents. //--------------------------------------------------------------- void ReplaceLocalMacros(ref string Contents, StringCollection AliasNames, XmlNode[] AliasNodes) { char[] delimiters = { '.' }; int PosStartMacro = Contents.IndexOf('['); while (PosStartMacro != -1) { int PosEndMacro = Contents.IndexOf(']', PosStartMacro); string Macro = Contents.Substring(PosStartMacro + 1, PosEndMacro - PosStartMacro - 1); string[] words = Macro.Split(delimiters, 2); if (words.Length == 2) { int PosAlias = AliasNames.IndexOf(words[0].ToLower()); if (PosAlias != -1) { XmlNode node = AliasNodes[PosAlias]; string Value = GetValueFromNode(node, words[1]); if (Value != null) { Contents = Contents.Remove(PosStartMacro, Macro.Length + 2); Contents = Contents.Insert(PosStartMacro, Value); } } } PosStartMacro = Contents.IndexOf('[', PosStartMacro + 1); } }
/// <summary> /// 检查某个Section下的某个键值是否存在 /// </summary> /// <param name="Section"></param> /// <param name="Ident"></param> /// <returns></returns> public bool CIniFileValueExists(string section, string ident) { StringCollection Idents = new StringCollection(); this.CIniFileReadSection(section, ref Idents); return(Idents.IndexOf(ident) > -1); }
// Calculates List of Property Scopes private StringCollection LoadPropertyScopes(DataTable PropDefs) { StringCollection scopeNames = new StringCollection(); foreach (DataRow row in PropDefs.Rows) { string scopeName = ""; string propertyName = row["name"].ToString(); string[] propertyParts = propertyName.Split(new char[] { '.' }); if (propertyParts.Length == 2) { scopeName = propertyParts[0]; } else if (propertyParts.Length >= 3) { scopeName = string.Format("{0}.{1}", propertyParts[0], propertyParts[1]); } row["scope"] = scopeName; if (scopeNames.IndexOf(scopeName) < 0) { scopeNames.Add(scopeName); } } return(scopeNames); }
//检查某个section下的某个键值是否存在 public bool ValueExists(string section, string key) { StringCollection Idents = new StringCollection(); ReadSection(section, Idents); return(Idents.IndexOf(key) > -1); }
public bool ValueExists(string Section, string Ident) { StringCollection idents = new StringCollection(); this.ReadSection(Section, idents); return(idents.IndexOf(Ident) > -1); }
protected void Page_Load(object sender, EventArgs e) { if (!HttpContext.Current.User.Identity.IsAuthenticated) { Response.Redirect("WinLogin.aspx", true); return; } StringCollection ug = AccountHelper.GetUserGroup(".", this.User.Identity.Name); if (ug.IndexOf("Administrators") == -1) { Response.Write("没有权限!"); Response.End(); } if (!Page.IsPostBack) { InitializeTable(); BindGridView(); BindWinGroups(); ViewState.Add("DS", DataSource); ViewState.Add("groups", groupTab); } else { DataSource = (DataTable)ViewState["DS"]; groupTab = (DataTable)ViewState["groups"]; } }
static void Main(string[] args) { StringCollection str = new StringCollection(); str.Add("Bringal"); str.Add("Bottle_Gaurd"); str.Add("Cauliflower"); str.Add("Cabbage"); str.Add("Okra"); Console.WriteLine("The Elements of the StringCollection is---------"); foreach (var item in str) { Console.WriteLine(item); } Console.WriteLine("Copying the above StringCollection list to string array--------------"); string[] str1 = new string[str.Count]; str.CopyTo(str1, 0); Console.WriteLine("Printing the copied list into the array"); foreach (var i in str) { Console.WriteLine(i); } Console.WriteLine("Checking weather Tomato element is present in the StringCollection:{0}", str.Contains("Tomato")); Console.WriteLine("Checking the index of the element : {0} ", str.IndexOf("Cauliflower")); str.Insert(4, "Tomato"); Console.WriteLine("Printing the list after inserting the new value"); foreach (var item1 in str) { Console.WriteLine(item1); } str.Remove("Bringal"); Console.WriteLine("List of the elements after removing----------"); foreach (var item2 in str) { Console.WriteLine(item2); } Console.WriteLine("Removing element from the index value--------"); str.RemoveAt(3); Console.WriteLine("Elements list after removing values from index 3"); foreach (var item3 in str) { Console.WriteLine(item3); } Console.Read(); }
/// <summary> /// 检查某个Section下的某个键值是否存在 /// </summary> /// <param name="Section"></param> /// <param name="Ident"></param> /// <returns></returns> public bool ValueExists(string Section, string Ident, string FileName) {// StringCollection Idents = new StringCollection(); ReadSection(Section, Idents, FileName); return(Idents.IndexOf(Ident) > -1); }
/// <summary> /// 检查某个Section下的某个键值是否存在 /// </summary> /// <param name="filename"></param> /// <param name="Section"></param> /// <param name="Ident"></param> /// <returns></returns> public static bool ValueExists(string filename, string Section, string Ident) { StringCollection Idents = new StringCollection(); ReadSection(filename, Section, Idents); return(Idents.IndexOf(Ident) > -1); }
//检查某个Section下的某个键值是否存在 public bool existsValue(string Section, string Ident) { StringCollection Idents = new StringCollection(); readSection(Section, Idents); return(Idents.IndexOf(Ident) > -1); }
/// <summary> /// 检查某个Section下的某个键值是否存在 /// </summary> /// <param name="section">section</param> /// <param name="key">key</param> /// <returns>结果</returns> public bool KeyExists(string section, string key) { StringCollection keys = new StringCollection(); GetKeys(section, keys); return(keys.IndexOf(key) > -1); }
}// IntersectCollections static internal StringCollection CondIntersectCollections(ref StringCollection sc1, ref StringCollection sc2, ref StringCollection sc3) { StringCollection scOutput = new StringCollection(); int iLen = sc1.Count; for (int i = 0; i < iLen; i++) { // Clean up our String Collection a little bit if (sc1[i].Equals("")) { sc1.RemoveAt(i); i--; iLen--; } else { int iIndexInSecond = sc2.IndexOf(sc1[i]); if (iIndexInSecond != -1 && !sc3.Contains(sc1[i])) { scOutput.Add(sc1[i]); // Pull this string out of the two string collections sc1.RemoveAt(i); sc2.RemoveAt(iIndexInSecond); // Set the counters so we won't be lost i--; iLen--; } } } return(scOutput); }// IntersectCollections
//检查某个Section下的某个键值是否存在 public bool ValueExists(string section, string ident) { var idents = new StringCollection(); ReadSection(section, idents); return(idents.IndexOf(ident) > -1); }
public string FormatJob(DataRow dr) { string sReport = Fmt.Tm12Hr(DB.DtTm(dr["ReportTime"])); string sReportNote = sReport; string sMeal = Fmt.Tm12Hr(DB.DtTm(dr["MealTime"])); if (sReport.Length == 0) { if (sMeal.Length > 0) { sReport = sMeal + "<sup>*</sup>"; sReportNote = sMeal; fNoReportTime = true; } else { sReport = "N/A"; sReportNote = "N/A"; fNoReportTime = false; } } string Html = WebPage.Tabs(3) + WebPage.Table("width='100%' class='NoBorder'") + WebPage.Tabs(4) + "<tr>\n" + WebPage.Tabs(5) + "<td><span class='CalMainTime'><a href='javascript:ShowJob(" + iJobNum + ");' title='Report Time: " + sReportNote + "\nMeal Time: " + sMeal + "\nClick to see details of this job.'>" + sReport + "</a></span></td>\n" + WebPage.Tabs(5) + "<td> </td>\n" + WebPage.Tabs(5) + "<td align='right'><span class='CalMinorTime'>" + sMeal + "</span></td>\n" + WebPage.Tabs(4) + "</tr>\n" + WebPage.Tabs(3) + WebPage.TableEnd() + WebPage.Tabs(3) + WebPage.Table("class='NoBorder'") + WebPage.Tabs(4) + WebPage.SpaceTr(10, 1) + (fMaster ? WebPage.Tabs(4) + "<tr><td colspan='2'><b>" + DB.Str(dr["CrewMember"]) + "</b></td></tr>\n" : "") + JobField(dr, "Customer") + JobField(dr, "CrewAssignment") + JobField(dr, "Note") + WebPage.Tabs(4) + "<tbody id='tblJob" + iJobNum + "' style='display: none;'>\n" + JobField(dr, "Location") + JobField(dr, "EventType") + JobField(dr, "ServiceType") + WebPage.Tabs(4) + "</tbody>\n" + WebPage.Tabs(3) + WebPage.TableEnd(); iJobNum++; DateTime dtReport = DB.DtTm(dr["ReportTm"]); sReport = new DateTime(dtReport.Year, dtReport.Month, dtReport.Day, 0, 0, 0).ToString("M/d/yyyy"); // if this date hasn't seen yet if (scDays.IndexOf(sReport) < 0) { scDays.Add(sReport); cDays++; } return(Html); }
//检查某个Section下的某个键值是否存在 public bool ValueExists(string Section, string Key) { // StringCollection Keys = new StringCollection(); ReadSection(Section, Keys); return(Keys.IndexOf(Key) > -1); }
//******************************************************************************************************************** //******************************************************************************************************************** //检查Section下的键值是否存在 public bool IniKeyExist(string Section, string Key) { StringCollection KeyList = new StringCollection(); ReadKeyList(Section, KeyList); return(KeyList.IndexOf(Key) > -1); }
static public int GetArea(string strArea) { StringCollection strc = GetAreaNames(); // Corrects for the 1 virtual area we have so far "[LastDiscovery]" return(strc.IndexOf(strArea) - VirtualAreaCount); }
private bool UpdateIds(StringCollection ids, DataTable table, UpdateMode mode) { bool updated = false; if (mode == UpdateMode.New && ids.Count > 0) { ids.Clear(); updated = true; } foreach (DataRow row in table.Rows) { if (!row.IsNull(0)) { string value = row[0].ToString(); if (mode == UpdateMode.Remove) { if (ids.IndexOf(value) >= 0) { ids.Remove(value); updated = true; } } else { if (mode == UpdateMode.Add) { if (ids.IndexOf(value) < 0) { ids.Add(value); updated = true; } } else { ids.Add(value); updated = true; } } } } return(updated); }
private void button1_Click(object sender, System.EventArgs e) { //NAVIGATOR: Microsoft.DirectX.DirectInput.Device md; md = Misc.GetDefaultMouseDevice(this, 0); md.Unacquire(); md.SetCooperativeLevel(this, Microsoft.DirectX.DirectInput.CooperativeLevelFlags.Exclusive | Microsoft.DirectX.DirectInput.CooperativeLevelFlags.Foreground); md.Properties.AxisModeAbsolute = false; md.Acquire(); StringCollection ca = new StringCollection(); AssignementsMap ia = new AssignementsMap(); Controller c; c = FreeSpiritNavigator10.GetDefaultController(); ca = c.ControlActions; ca.Add("EXIT"); ca.Add("FillMode"); ia.KeyboardAssignements.Add(new ButtonInputAssignement(ca.IndexOf("EXIT"), (byte)Microsoft.DirectX.DirectInput.Key.Escape, 0, 0)); ia.KeyboardAssignements.Add(new ButtonInputAssignement(ca.IndexOf("FillMode"), (byte)Microsoft.DirectX.DirectInput.Key.F, 0, 0)); ia.MouseAssignements.Add(new AxisInputAssignement(ca.IndexOf("TurnLeft"), Axis3.X, false)); ia.MouseAssignements.Add(new AxisInputAssignement(ca.IndexOf("TurnRight"), Axis3.X, false)); ia.MouseAssignements.Add(new AxisInputAssignement(ca.IndexOf("TurnDown"), Axis3.Y, false)); ia.MouseAssignements.Add(new AxisInputAssignement(ca.IndexOf("TurnUp"), Axis3.Y, false)); ia.KeyboardAssignements.Add(new ButtonInputAssignement(ca.IndexOf("RollLeft"), (byte)Microsoft.DirectX.DirectInput.Key.Delete, 0, 0)); ia.KeyboardAssignements.Add(new ButtonInputAssignement(ca.IndexOf("RollRight"), (byte)Microsoft.DirectX.DirectInput.Key.PageDown, 0, 0)); ia.KeyboardAssignements.Add(new ButtonInputAssignement(ca.IndexOf("Foreward"), (byte)Microsoft.DirectX.DirectInput.Key.UpArrow, 0, 0)); ia.KeyboardAssignements.Add(new ButtonInputAssignement(ca.IndexOf("Backward"), (byte)Microsoft.DirectX.DirectInput.Key.DownArrow, 0, 0)); this.ic = new InputController(Misc.GetDefaultKeyboardDevice(this, 0), md, ca, ia); this.n = new OnSurfaceNavigator10(this.cam, ic, this.s, this.MyHeight); this.ic.ActionPerformed += new Direct3DAid.Mobility.Controllers.Controller.ActionPerformedHandler(this.OnControllerAction); }
protected void Page_Load(object sender, EventArgs e) { lblUser.Text = this.User.Identity.Name + "(" + User.Identity.AuthenticationType + ")"; StringCollection ug = AccountHelper.GetUserGroup(".", this.User.Identity.Name); if (ug.IndexOf("Administrators") == -1) { hplAccount.Visible = false; } }
//检查某个Section下的某个键值是否存在 public bool ValueExists(string Section, string Ident) { // StringCollection Idents = new StringCollection(); ReadSection(Section, Idents); return Idents.IndexOf(Ident) > -1; }
//--------------------------------------------------------------- // Resolve the specified alias into an XmlNode node. //--------------------------------------------------------------- XmlNode ResolveNode(string Alias, StringCollection AliasNames, XmlNode[] AliasNodes) { int PosAlias = AliasNames.IndexOf(Alias.ToLower()); if (PosAlias == -1) { throw new Exception("Invalid alias specified in foreach macro: " + Alias); } return(AliasNodes[PosAlias]); }
public void AddMember(string MemberName) { if (ChildMemberList.IndexOf(MemberName) >= 0) { return; } else { ChildMemberList.Add(MemberName); } }
public void AddItem(string inputPty) { if (PtyList.IndexOf(inputPty) >= 0) { return; } else { PtyList.Add(inputPty); } }
private void DeleteKeyColumn(StringCollection fieldNames) /* * Method that deletes the key column from fColumns and fieldNames. */ { int keyIndex; keyIndex = fieldNames.IndexOf(fKeyField); fColumns.RemoveAt(keyIndex); fieldNames.RemoveAt(keyIndex); }
//检查某个Section下的某个键值是否存在 public bool valueExists(string Section, string Ident) { // StringCollection Idents = new StringCollection(); readSection(Section, Idents); return Idents.IndexOf(Ident) > -1; }
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"; StringCollection sc; string itm; string [] values = { "", " ", "a", "aa", "text", " spaces", "1", "$%^#", "2222222222222222222222222", System.DateTime.Today.ToString(), Int32.MaxValue.ToString() }; try { intl = new IntlStrings(); Console.WriteLine("--- create collection ---"); strLoc = "Loc_001oo"; iCountTestcases++; sc = new StringCollection(); Console.WriteLine("1. set Item on empty collection"); Console.WriteLine(" (-1)th"); strLoc = "Loc_001oo"; itm = intl.GetString(MAX_LEN, true, true, true); iCountTestcases++; try { sc[-1] = itm; iCountErrors++; Console.WriteLine("Err_0001a, no exception"); } catch (ArgumentOutOfRangeException ex) { Console.WriteLine(" expected exception: " + ex.Message); } catch (Exception e) { iCountErrors++; Console.WriteLine("Err_0001b, unexpected exception: {0}", e.ToString()); } Console.WriteLine(" 0th to string"); iCountTestcases++; try { sc[0] = itm; iCountErrors++; Console.WriteLine("Err_0001c, no exception"); } catch (ArgumentOutOfRangeException ex) { Console.WriteLine(" expected exception: " + ex.Message); } catch (Exception e) { iCountErrors++; Console.WriteLine("Err_0001d, unexpected exception: {0}", e.ToString()); } Console.WriteLine(" 0th to null"); iCountTestcases++; try { sc[0] = null; iCountErrors++; Console.WriteLine("Err_0001e, no exception"); } catch (ArgumentOutOfRangeException ex) { Console.WriteLine(" expected exception: " + ex.Message); } catch (Exception e) { iCountErrors++; Console.WriteLine("Err_0001f, unexpected exception: {0}", e.ToString()); } Console.WriteLine("2. set Item on collection with simple strings"); strLoc = "Loc_002oo"; sc.Clear(); iCountTestcases++; sc.AddRange(values); int cnt = values.Length; if (sc.Count != cnt) { iCountErrors++; Console.WriteLine("Err_0002a, count is {0} instead of {1}", sc.Count, cnt); } for (int i = 0; i < cnt; i++) { iCountTestcases++; sc[i] = values[cnt-i-1]; if (String.Compare(sc[i], values[cnt-i-1], false) != 0) { iCountErrors++; Console.WriteLine("Err_0002_{0}b, value is {1} instead of {2}", i, sc[i], values[cnt-i-1]); } } Console.WriteLine("3. get Item on collection with intl strings"); strLoc = "Loc_003oo"; string [] intlValues = new string [values.Length]; for (int i = 0; i < values.Length; 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; } int len = values.Length; Boolean caseInsensitive = false; for (int i = 0; i < len; i++) { if(intlValues[i].Length!=0 && intlValues[i].ToLower()==intlValues[i].ToUpper()) caseInsensitive = true; } iCountTestcases++; sc.Clear(); cnt = intlValues.Length; sc.AddRange(intlValues); if ( sc.Count != intlValues.Length ) { iCountErrors++; Console.WriteLine("Err_0003a, count is {0} instead of {1}", sc.Count, intlValues.Length); } for (int i = cnt; i < cnt; i++) { iCountTestcases++; sc[i] = intlValues[cnt-i-1]; iCountTestcases++; if (String.Compare(sc[i], intlValues[cnt-i-1], false) != 0) { iCountErrors++; Console.WriteLine("Err_0003_{0}b, actual item is {1} instead of {2}", i, sc[i], intlValues[cnt-i-1]); } } Console.WriteLine("4. case sensitivity"); strLoc = "Loc_004oo"; string intlStrUpper = intlValues[0]; intlStrUpper = intlStrUpper.ToUpper(); string intlStrLower = intlStrUpper.ToLower(); sc.Clear(); sc.AddRange(values); sc.Add(intlStrUpper); iCountTestcases++; if ( sc.Count != values.Length + 1 ) { iCountErrors++; Console.WriteLine("Err_0004a, count is {0} instead of {1}", sc.Count, values.Length + 1); } sc[0] = intlStrLower; iCountTestcases++; if (!caseInsensitive && (String.Compare(sc[0], intlStrUpper, false) == 0)) { iCountErrors++; Console.WriteLine("Err_0004b, set to uppercase when should have to lower"); } iCountTestcases++; if (String.Compare(sc[0], intlStrLower, false) != 0) { iCountErrors++; Console.WriteLine("Err_0004c, disn't set to lower"); } sc[sc.Count - 1] = intlStrLower; iCountTestcases++; if (!caseInsensitive && (String.Compare(sc[sc.Count - 1], intlStrUpper, false) == 0)) { iCountErrors++; Console.WriteLine("Err_0004b, didn't set from uppercase to lowercase "); } iCountTestcases++; if (String.Compare(sc[sc.Count - 1], intlStrLower, false) != 0) { iCountErrors++; Console.WriteLine("Err_0004c, disn't set to lower"); } Console.WriteLine("5. set to null"); strLoc = "Loc_005oo"; if (sc.Count < 1) sc.AddRange(values); int ind = sc.Count / 2; sc[ind] = null; iCountTestcases++; if (sc[ind] != null) { iCountErrors++; Console.WriteLine("Err_0005a, failed to set to null"); } iCountTestcases++; if (!sc.Contains(null)) { iCountErrors++; Console.WriteLine("Err_0005b, Contains() didn't return truw for null"); } iCountTestcases++; if (sc.IndexOf(null) != ind) { iCountErrors++; Console.WriteLine("Err_0005c, IndexOf() returned {0} instead of {1}", sc.IndexOf(null), ind); } Console.WriteLine("6. set [-1] to string"); sc.Clear(); sc.AddRange(intlValues); Console.WriteLine(" collection contains {0} items", sc.Count); strLoc = "Loc_006oo"; iCountTestcases++; try { sc[-1] = intlStrUpper; iCountErrors++; Console.WriteLine("Err_0006a, no exception"); } catch (ArgumentOutOfRangeException ex) { Console.WriteLine(" expected exception: " + ex.Message); } catch (Exception e) { iCountErrors++; Console.WriteLine("Err_0006b, unexpected exception: {0}", e.ToString()); } Console.WriteLine("7. set [Count] to string"); strLoc = "Loc_007oo"; iCountTestcases++; try { sc[sc.Count] = intlStrUpper; iCountErrors++; Console.WriteLine("Err_0007a, no exception"); } catch (ArgumentOutOfRangeException ex) { Console.WriteLine(" expected exception: " + ex.Message); } catch (Exception e) { iCountErrors++; Console.WriteLine("Err_0007b, unexpected exception: {0}", e.ToString()); } Console.WriteLine("8. set (Count + 1) to string"); strLoc = "Loc_008oo"; iCountTestcases++; try { sc[sc.Count + 1] = intlStrUpper; iCountErrors++; Console.WriteLine("Err_0008a, no exception"); } catch (ArgumentOutOfRangeException ex) { Console.WriteLine(" expected exception: " + ex.Message); } catch (Exception e) { iCountErrors++; Console.WriteLine("Err_0008b, unexpected exception: {0}", e.ToString()); } Console.WriteLine("9. set [Count] to null"); strLoc = "Loc_009oo"; iCountTestcases++; try { sc[sc.Count] = null; iCountErrors++; Console.WriteLine("Err_0009a, no exception"); } catch (ArgumentOutOfRangeException ex) { Console.WriteLine(" expected exception: " + ex.Message); } catch (Exception e) { iCountErrors++; Console.WriteLine("Err_0009b, 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; } }
private bool UpdateIds(StringCollection ids, DataTable table, UpdateMode mode) { bool updated = false; if (mode == UpdateMode.New && ids.Count > 0) { ids.Clear(); updated = true; } foreach (DataRow row in table.Rows) { if (!row.IsNull(0)) { string value = row[0].ToString(); if (mode == UpdateMode.Remove) { if (ids.IndexOf(value) >= 0) { ids.Remove(value); updated = true; } } else { if (mode == UpdateMode.Add) { if (ids.IndexOf(value) < 0) { ids.Add(value); updated = true; } } else { ids.Add(value); updated = true; } } } } return updated; }
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"; StringCollection sc; string [] values = { "", " ", "a", "aa", "text", " spaces", "1", "$%^#", "2222222222222222222222222", System.DateTime.Today.ToString(), Int32.MaxValue.ToString() }; int cnt = 0; int ind = 0; try { intl = new IntlStrings(); Console.WriteLine("--- create collection ---"); strLoc = "Loc_001oo"; iCountTestcases++; sc = new StringCollection(); Console.WriteLine("1. add simple strings"); for (int i = 0; i < values.Length; i++) { iCountTestcases++; cnt = sc.Count; sc.Add(values[i]); if (sc.Count != cnt+1) { iCountErrors++; Console.WriteLine("Err_0001_{0}a, count is {1} instead of {2}", i, sc.Count, cnt+1); } iCountTestcases++; if (!sc.Contains(values[i])) { iCountErrors++; Console.WriteLine("Err_0001_{0}b, collection doesn't contain new item", i); } iCountTestcases++; ind = sc.IndexOf(values[i]); if (ind != sc.Count - 1) { iCountErrors++; Console.WriteLine("Err_0001_{0}c, returned index {1} instead of {2}", i, ind, sc.Count - 1); } if (ind != -1) { iCountTestcases++; if (String.Compare(sc[ind], values[i], false) != 0) { iCountErrors++; Console.WriteLine("Err_0001_{0}d, returned item \"{1}\" instead of \"{2}\"", i, sc[ind], values[i]); } } } Console.WriteLine("2. add intl strings"); string [] intlValues = new string [values.Length]; for (int i = 0; i < values.Length; 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; } Console.WriteLine(" initial number of items: " + sc.Count); strLoc = "Loc_002oo"; for (int i = 0; i < intlValues.Length; i++) { iCountTestcases++; cnt = sc.Count; sc.Add(intlValues[i]); if (sc.Count != cnt+1) { iCountErrors++; Console.WriteLine("Err_0002_{0}a, count is {1} instead of {2}", i, sc.Count, cnt+1); } iCountTestcases++; if (!sc.Contains(intlValues[i])) { iCountErrors++; Console.WriteLine("Err_0002_{0}b, collection doesn't contain new item", i); } iCountTestcases++; ind = sc.IndexOf(intlValues[i]); if (ind != sc.Count - 1) { iCountErrors++; Console.WriteLine("Err_0002_{0}c, returned index {1} instead of {2}", i, ind, sc.Count - 1); } if (ind != -1) { iCountTestcases++; if (String.Compare(sc[ind], intlValues[i], false) != 0) { iCountErrors++; Console.WriteLine("Err_0002_{0}d, returned item \"{1}\" instead of \"{2}\"", i, sc[ind], intlValues[i]); } } } Console.WriteLine("3. Add a very long string"); strLoc = "Loc_003oo"; iCountTestcases++; cnt = sc.Count; string intlStr = intlValues[0]; while (intlStr.Length < 10000) intlStr += intlStr; Console.WriteLine(" - add string of Length " + intlStr.Length); sc.Add(intlStr); if (sc.Count != cnt+1) { iCountErrors++; Console.WriteLine("Err_0003a, count is {1} instead of {2}", sc.Count, cnt+1); } iCountTestcases++; if (!sc.Contains(intlStr)) { iCountErrors++; Console.WriteLine("Err_0003b, collection doesn't contain new item"); } iCountTestcases++; ind = sc.IndexOf(intlStr); if (ind != sc.Count - 1) { iCountErrors++; Console.WriteLine("Err_0003c, returned index {1} instead of {2}", ind, sc.Count - 1); } if (ind != -1) { iCountTestcases++; if (String.Compare(sc[ind], intlStr, false) != 0) { iCountErrors++; Console.WriteLine("Err_0003d, returned item \"{1}\" instead of \"{2}\"", sc[ind], intlStr); } } } 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"; StringCollection sc; string [] values = { "", " ", "a", "aa", "text", " spaces", "1", "$%^#", "2222222222222222222222222", System.DateTime.Today.ToString(), Int32.MaxValue.ToString() }; int cnt = 0; try { intl = new IntlStrings(); Console.WriteLine("--- create collection ---"); strLoc = "Loc_001oo"; iCountTestcases++; sc = new StringCollection(); Console.WriteLine("1. Remove() from empty collection"); for (int i = 0; i < values.Length; i++) { iCountTestcases++; sc.Remove(values[i]); if (sc.Count != 0) { iCountErrors++; Console.WriteLine("Err_0001_{0}, Remove changed Count for empty collection", i); } } Console.WriteLine("2. add simple strings and test Remove()"); strLoc = "Loc_002oo"; iCountTestcases++; sc.Clear(); sc.AddRange(values); if (sc.Count != values.Length) { iCountErrors++; Console.WriteLine("Err_0002a, count is {0} instead of {1}", sc.Count, values.Length); } for (int i = 0; i < values.Length; i++) { iCountTestcases++; if (!sc.Contains(values[i])) { iCountErrors++; Console.WriteLine("Err_0002_{0}b, doesn't contain {0} item", i); } cnt = sc.Count; iCountTestcases++; sc.Remove(values[i]); if (sc.Count != cnt - 1) { iCountErrors++; Console.WriteLine("Err_0002_{0}c, didn't remove anything", i); } if (sc.Contains(values[i])) { iCountErrors++; Console.WriteLine("Err_0002_{0}d, removed wrong item", i); } } Console.WriteLine("3. add intl strings and test Remove()"); strLoc = "Loc_003oo"; string [] intlValues = new string [values.Length]; for (int i = 0; i < values.Length; 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; } int len = values.Length; Boolean caseInsensitive = false; for (int i = 0; i < len; i++) { if(intlValues[i].Length!=0 && intlValues[i].ToLower()==intlValues[i].ToUpper()) caseInsensitive = true; } iCountTestcases++; sc.Clear(); sc.AddRange(intlValues); if ( sc.Count != intlValues.Length ) { iCountErrors++; Console.WriteLine("Err_0003a, count is {0} instead of {1}", sc.Count, intlValues.Length); } for (int i = 0; i < intlValues.Length; i++) { iCountTestcases++; if (!sc.Contains(intlValues[i])) { iCountErrors++; Console.WriteLine("Err_0002_{0}b, doesn't contain {0} item", i); } cnt = sc.Count; iCountTestcases++; sc.Remove(intlValues[i]); if (sc.Count != cnt - 1) { iCountErrors++; Console.WriteLine("Err_0002_{0}c, didn't remove anything", i); } if (sc.Contains(intlValues[i])) { iCountErrors++; Console.WriteLine("Err_0002_{0}d, removed wrong item", i); } } Console.WriteLine("4. duplicate strings "); strLoc = "Loc_004oo"; iCountTestcases++; sc.Clear(); string intlStr = intlValues[0]; sc.Add(intlStr); sc.AddRange(values); sc.AddRange(intlValues); cnt = values.Length + 1 + intlValues.Length; if (sc.Count != cnt) { iCountErrors++; Console.WriteLine("Err_0004a, count is {1} instead of {2}", sc.Count, cnt); } iCountTestcases++; if (sc.IndexOf(intlStr) != 0) { iCountErrors++; Console.WriteLine("Err_0004b, IndexOf returned {0} instead of {1}", sc.IndexOf(intlStr), 0); } iCountTestcases++; sc.Remove(intlStr); if (!sc.Contains(intlStr)) { iCountErrors++; Console.WriteLine("Err_0004c, removed both duplicates"); } if (sc.IndexOf(intlStr) != values.Length) { iCountErrors++; Console.WriteLine("Err_0004d, IndexOf returned {0} instead of {1}", sc.IndexOf(intlStr), values.Length); } for (int i = 0; i < values.Length; i++) { if (sc.IndexOf(values[i]) != i) { iCountErrors++; Console.WriteLine("Err_0004e_{0}, IndexOf {0} item returned {1} ", i, sc.IndexOf(values[i])); } if (sc.IndexOf(intlValues[i]) != i+values.Length) { iCountErrors++; Console.WriteLine("Err_0004f_{0}, IndexOf {1} item returned {2} ", i, i+values.Length, sc.IndexOf(intlValues[i])); } } Console.WriteLine("5. Case sensitivity"); strLoc = "Loc_005oo"; iCountTestcases++; sc.Clear(); sc.Add(intlStr.ToUpper()); sc.AddRange(values); sc.Add(intlStr.ToLower()); cnt = values.Length + 2; if (sc.Count != cnt) { iCountErrors++; Console.WriteLine("Err_0005a, count is {1} instead of {2} ", sc.Count, cnt); } intlStr = intlStr.ToLower(); iCountTestcases++; Console.WriteLine(" - remove lowercase" ); cnt = sc.Count; sc.Remove(intlStr); if (sc.Count != cnt-1) { iCountErrors++; Console.WriteLine("Err_0005b, didn't remove anything"); } if (!caseInsensitive && sc.Contains(intlStr)) { iCountErrors++; Console.WriteLine("Err_0005c, didn't remove lowercase "); } if (!sc.Contains(intlValues[0].ToUpper())) { iCountErrors++; Console.WriteLine("Err_0005d, removed uppercase "); } Console.WriteLine("6. Remove() non-existing item"); strLoc = "Loc_006oo"; iCountTestcases++; sc.Clear(); sc.AddRange(values); cnt = values.Length; if (sc.Count != cnt) { iCountErrors++; Console.WriteLine("Err_0006a, count is {1} instead of {2} ", sc.Count, cnt); } intlStr = "Hello"; iCountTestcases++; cnt = sc.Count; sc.Remove(intlStr); if (sc.Count != cnt) { iCountErrors++; Console.WriteLine("Err_0005b, removed something"); } } 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 static void InsertTest(StringCollection collection, string[] data, string element, int location) { collection.Insert(location, element); Assert.Equal(data.Length + 1, collection.Count); if (element == ElementNotPresent) { Assert.Equal(location, collection.IndexOf(ElementNotPresent)); } for (int i = 0; i < data.Length + 1; i++) { if (i < location) { Assert.Equal(data[i], collection[i]); } else if (i == location) { Assert.Equal(element, collection[i]); } else { Assert.Equal(data[i - 1], collection[i]); } } }
public static void IndexOf_DuplicateTest(StringCollection collection, string[] data) { // Only the index of the first element will be returned. data = data.Distinct().ToArray(); Assert.All(data, element => Assert.Equal(Array.IndexOf(data, element), collection.IndexOf(element))); Assert.All(data, element => Assert.Equal(Array.IndexOf(data, element), ((IList)collection).IndexOf(element))); Assert.Equal(-1, collection.IndexOf(ElementNotPresent)); Assert.Equal(-1, ((IList)collection).IndexOf(ElementNotPresent)); }
public static void IndexOfTest(StringCollection collection, string[] data) { Assert.All(data, element => Assert.Equal(Array.IndexOf(data, element), collection.IndexOf(element))); Assert.All(data, element => Assert.Equal(Array.IndexOf(data, element), ((IList)collection).IndexOf(element))); Assert.Equal(-1, collection.IndexOf(ElementNotPresent)); Assert.Equal(-1, ((IList)collection).IndexOf(ElementNotPresent)); }
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"; StringCollection sc; string [] values = { "", " ", "a", "aa", "text", " spaces", "1", "$%^#", "2222222222222222222222222", System.DateTime.Today.ToString(), Int32.MaxValue.ToString() }; try { intl = new IntlStrings(); Console.WriteLine("--- create collection ---"); strLoc = "Loc_001oo"; iCountTestcases++; sc = new StringCollection(); Console.WriteLine("1. RemoveAt() from empty collection"); iCountTestcases++; if (sc.Count > 0) sc.Clear(); try { sc.RemoveAt(0); iCountErrors++; Console.WriteLine("Err_0001_{0}a, no exception"); } catch (ArgumentOutOfRangeException ex) { Console.WriteLine(" expected exception: " + ex.Message); } catch (Exception e) { iCountErrors++; Console.WriteLine("Err_0001_{0}b, unexpected exception: " + e.ToString()); } Console.WriteLine("2. RemoveAt() on filled collection"); strLoc = "Loc_002oo"; Console.WriteLine(" - at the beginning"); iCountTestcases++; sc.Clear(); sc.AddRange(values); if (sc.Count != values.Length) { iCountErrors++; Console.WriteLine("Err_0002a, count is {0} instead of {1}", sc.Count, values.Length); } iCountTestcases++; sc.RemoveAt(0); if (sc.Count != values.Length - 1) { iCountErrors++; Console.WriteLine("Err_0002b, Count returned {0} instead of {1}", sc.Count, values.Length - 1); } iCountTestcases++; if (sc.Contains(values[0])) { iCountErrors++; Console.WriteLine("Err_0002c, removed wrong item"); } for (int i = 0; i < values.Length; i++) { iCountTestcases++; if (sc.IndexOf(values[i]) != i-1) { iCountErrors++; Console.WriteLine("Err_0002_{0}d, IndexOf returned {1} instead of {2}", i, sc.IndexOf(values[i]), i-1); } } Console.WriteLine(" - at the end"); iCountTestcases++; sc.Clear(); sc.AddRange(values); if (sc.Count != values.Length) { iCountErrors++; Console.WriteLine("Err_0002e, count is {0} instead of {1}", sc.Count, values.Length); } iCountTestcases++; sc.RemoveAt(values.Length-1); if (sc.Count != values.Length - 1) { iCountErrors++; Console.WriteLine("Err_0002f, Count returned {0} instead of {1}", sc.Count, values.Length - 1); } iCountTestcases++; if (sc.Contains(values[values.Length - 1])) { iCountErrors++; Console.WriteLine("Err_0002g, removed wrong item"); } for (int i = 0; i < values.Length-1; i++) { iCountTestcases++; if (sc.IndexOf(values[i]) != i) { iCountErrors++; Console.WriteLine("Err_0002_{0}h, IndexOf returned {1} instead of {2}", i, sc.IndexOf(values[i]), i); } } Console.WriteLine(" - at the middle"); iCountTestcases++; sc.Clear(); sc.AddRange(values); if (sc.Count != values.Length) { iCountErrors++; Console.WriteLine("Err_0002i, count is {0} instead of {1}", sc.Count, values.Length); } iCountTestcases++; sc.RemoveAt(values.Length/2); if (sc.Count != values.Length - 1) { iCountErrors++; Console.WriteLine("Err_0002j, Count returned {0} instead of {1}", sc.Count, values.Length - 1); } iCountTestcases++; if (sc.Contains(values[values.Length/2])) { iCountErrors++; Console.WriteLine("Err_0002g, removed wrong item"); } for (int i = 0; i < values.Length; i++) { iCountTestcases++; int expected = i; if (i == values.Length / 2) expected = -1; else if (i > values.Length / 2) expected = i-1; if (sc.IndexOf(values[i]) != expected) { iCountErrors++; Console.WriteLine("Err_0002_{0}k, IndexOf returned {1} instead of {2}", i, sc.IndexOf(values[i]), expected); } } Console.WriteLine("3. RemoveAt() on collection with duplicate strings "); strLoc = "Loc_003oo"; iCountTestcases++; sc.Clear(); string intlStr = intl.GetString(MAX_LEN, true, true, true); sc.Add(intlStr); sc.AddRange(values); sc.Add(intlStr); if (sc.Count != values.Length + 2) { iCountErrors++; Console.WriteLine("Err_0003a, count is {1} instead of {2}", sc.Count, values.Length + 2); } iCountTestcases++; sc.RemoveAt(values.Length + 1); if (!sc.Contains(intlStr)) { iCountErrors++; Console.WriteLine("Err_0003b, removed both duplicates"); } if (sc.IndexOf(intlStr) != 0) { iCountErrors++; Console.WriteLine("Err_0003c, removed 1st instance"); } Console.WriteLine("4. RemoveAt(-1)"); strLoc = "Loc_004oo"; iCountTestcases++; sc.Clear(); sc.AddRange(values); try { sc.RemoveAt(-1); iCountErrors++; Console.WriteLine("Err_0004a, no exception"); } catch (ArgumentOutOfRangeException ex) { Console.WriteLine(" expected exception: " + ex.Message); } catch (Exception e) { iCountErrors++; Console.WriteLine("Err_0004b, unexpected exception: {0}", e.ToString()); } Console.WriteLine("5. RemoveAt(Count)"); strLoc = "Loc_005oo"; iCountTestcases++; sc.Clear(); sc.AddRange(values); try { sc.RemoveAt(sc.Count); iCountErrors++; Console.WriteLine("Err_0005a, no exception"); } catch (ArgumentOutOfRangeException ex) { Console.WriteLine(" expected exception: " + ex.Message); } catch (Exception e) { iCountErrors++; Console.WriteLine("Err_0005b, unexpected exception: {0}", e.ToString()); } Console.WriteLine("6. RemoveAt(Count+1)"); strLoc = "Loc_006oo"; iCountTestcases++; sc.Clear(); sc.AddRange(values); try { sc.RemoveAt(sc.Count+1); iCountErrors++; Console.WriteLine("Err_0006a, no exception"); } catch (ArgumentOutOfRangeException 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; } }
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"; StringCollection sc; string [] values = { "", " ", "a", "aa", "text", " spaces", "1", "$%^#", "2222222222222222222222222", System.DateTime.Today.ToString(), Int32.MaxValue.ToString() }; int cnt = 0; try { intl = new IntlStrings(); Console.WriteLine("--- create collection ---"); strLoc = "Loc_001oo"; iCountTestcases++; sc = new StringCollection(); Console.WriteLine("1. Check for empty collection"); for (int i = 0; i < values.Length; i++) { iCountTestcases++; if (sc.IndexOf(values[i]) != -1) { iCountErrors++; Console.WriteLine("Err_0001_{0}, returned {1} for empty collection", i, sc.IndexOf(values[i])); } } Console.WriteLine("2. add simple strings and verify IndexOf()"); strLoc = "Loc_002oo"; iCountTestcases++; cnt = sc.Count; sc.AddRange(values); if (sc.Count != values.Length) { iCountErrors++; Console.WriteLine("Err_0002a, count is {0} instead of {1}", sc.Count, values.Length); } for (int i = 0; i < values.Length; i++) { iCountTestcases++; if (sc.IndexOf(values[i]) != i) { iCountErrors++; Console.WriteLine("Err_0002_{0}b, IndexOf returned {1} instead of {0}", i, sc.IndexOf(values[i])); } } Console.WriteLine("3. add intl strings and verify IndexOf()"); strLoc = "Loc_003oo"; string [] intlValues = new string [values.Length]; for (int i = 0; i < values.Length; 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; } int len = values.Length; Boolean caseInsensitive = false; for (int i = 0; i < len; i++) { if(intlValues[i].Length!=0 && intlValues[i].ToLower()==intlValues[i].ToUpper()) caseInsensitive = true; } iCountTestcases++; cnt = sc.Count; sc.AddRange(intlValues); if ( sc.Count != (cnt + intlValues.Length) ) { iCountErrors++; Console.WriteLine("Err_0003a, count is {0} instead of {1}", sc.Count, cnt + intlValues.Length); } for (int i = 0; i < intlValues.Length; i++) { iCountTestcases++; if (sc.IndexOf(intlValues[i]) != values.Length + i) { iCountErrors++; Console.WriteLine("Err_0003_{0}b, IndexOf returned {1} instead of {2}", i, sc.IndexOf(intlValues[i]), values.Length + i); } } Console.WriteLine("4. duplicate strings "); strLoc = "Loc_004oo"; iCountTestcases++; sc.Clear(); string intlStr = intlValues[0]; sc.Add(intlStr); sc.AddRange(values); sc.AddRange(intlValues); cnt = values.Length + 1 + intlValues.Length; if (sc.Count != cnt) { iCountErrors++; Console.WriteLine("Err_0004a, count is {1} instead of {2}", sc.Count, cnt); } iCountTestcases++; if (sc.IndexOf(intlStr) != 0) { iCountErrors++; Console.WriteLine("Err_0004b, IndexOf returned {0} instead of {1}", sc.IndexOf(intlStr), 0); } iCountTestcases++; sc.Clear(); sc.AddRange(values); sc.AddRange(intlValues); sc.Add(intlStr); cnt = values.Length + 1 + intlValues.Length; if (sc.Count != cnt) { iCountErrors++; Console.WriteLine("Err_0004c, count is {1} instead of {2}", sc.Count, cnt); } iCountTestcases++; if (sc.IndexOf(intlStr) != values.Length) { iCountErrors++; Console.WriteLine("Err_0004b, IndexOf returned {0} instead of {1}", sc.IndexOf(intlStr), values.Length); } Console.WriteLine("5. Case sensitivity"); strLoc = "Loc_005oo"; iCountTestcases++; sc.Clear(); sc.Add(intlValues[0].ToUpper()); sc.AddRange(values); sc.Add(intlValues[0].ToLower()); cnt = values.Length + 2; if (sc.Count != cnt) { iCountErrors++; Console.WriteLine("Err_0005, count is {1} instead of {2} ", sc.Count, cnt); } intlStr = intlValues[0].ToLower(); iCountTestcases++; Console.WriteLine(" - look for lowercase" ); if (!caseInsensitive && (sc.IndexOf(intlStr) != values.Length + 1)) { iCountErrors++; Console.WriteLine("Err_0005a, IndexOf() returned {0} instead of {1} ", sc.IndexOf(intlStr), values.Length + 1); } } 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; } }