private void getCatList(int number,ref StringCollection catList,out CategoryTypeCollection categories)
        {
            bool isSuccess;
            string message;

            catList.Clear();
            //get a leaf category
            isSuccess=CategoryHelper.GetCISSupportLeafCategory(number,out categories,this.apiContext,out message);
            Assert.IsTrue(isSuccess,message);
            for(int i=0;i<number;i++)
            {
                //add to catList
                catList.Add(categories[i].CategoryID);
            }
        }
Beispiel #2
0
 private void GetStringsFromBuffer(Byte[] Buffer, int bufLen, StringCollection Strings)
 {
     Strings.Clear();
     if (bufLen != 0)
     {
         int start = 0;
         for (int i = 0; i < bufLen; i++)
         {
             if ((Buffer[i] == 0) && ((i - start) > 0))
             {
                 String s = Encoding.GetEncoding(0).GetString(Buffer, start, i - start);
                 Strings.Add(s);
                 start = i + 1;
             }
         }
     }
 }
Beispiel #3
0
        /// <PXKeyword name="CONTVARIABLE">
        ///   <rule>
        ///     <description>Hardcoded to ContentsCode</description>
        ///   </rule>
        /// </PXKeyword>
        /// <PXKeyword name="AGGREGALLOWED">
        ///   <rule>
        ///     <description>"No" if any of the selected content has a "no".</description>
        ///     <table modelName ="Contents">
        ///     <column modelName="AggregPossible"/>
        ///     </table>
        ///   </rule>
        /// </PXKeyword>
        internal override void ParseMeta(PCAxis.Paxiom.IPXModelParser.MetaHandler handler, StringCollection LanguageCodes, string preferredLanguage)
        {
            base.ParseMeta(handler, LanguageCodes, preferredLanguage);
            //CONTVARIABLE

            string           language = null;
            string           subkey   = null;
            StringCollection values   = new StringCollection();

            values.Add(this.Name);
            handler(PXKeywords.CONTVARIABLE, language, subkey, values);


            // AggregAllowed
            language = null;
            subkey   = null;
            string tmpAggregPossible = PXConstant.YES;

            foreach (PXSqlContent pxsqlCont in meta.Contents.Values)
            {
                if (!pxsqlCont.AggregPossible)
                {
                    tmpAggregPossible = PXConstant.NO;
                    break;
                }
            }

            values.Clear();
            values.Add(tmpAggregPossible);
            handler(PXKeywords.AGGREGALLOWED, language, subkey, values);

            language = null;
            subkey   = meta.ContensCode;
            values   = new StringCollection();
            values.Clear();
            values.Add(PXConstant.YES);
            handler("CandidateMustSelect", language, subkey, values);

            log.Debug("meta.Contents.Values.Count=" + meta.Contents.Values.Count.ToString());
            // "ContentInfo"
            // og PXKeywords.PRECISION
            foreach (PXSqlContent pxsqlCont in meta.Contents.Values)
            {
                pxsqlCont.ParseMeta(handler, LanguageCodes);
            }
        }
Beispiel #4
0
 private void GetStringsFromBuffer(byte[] Buffer, int bufLen, StringCollection Strings)
 {
     Strings.Clear();
     if (bufLen != 0)
     {
         int index = 0;
         for (int i = 0; i < bufLen; i++)
         {
             if ((Buffer[i] == 0) && ((i - index) > 0))
             {
                 string str = Encoding.GetEncoding(0).GetString(Buffer, index, i - index);
                 Strings.Add(str);
                 index = i + 1;
             }
         }
     }
 }
Beispiel #5
0
    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 string[] GetEntries(string pattern, bool files)
        {
            StringCollection sa = new StringCollection(ResolvePath(pattern, true));

            pattern = "\\" + string.Join("\\", sa.ToArray());
            DirInfo di = null;

            try
            {
                di = FindInfo(pattern.Trim() == "" ? "\\" : pattern);
                if (di == null)
                {
                    throw new Exception();
                }
                if (!(di is FileInfo))
                {
                    pattern = "*";
                }
            }
            catch
            {
                pattern = sa[sa.Count - 1];
                sa.RemoveAt(sa.Count - 1);
            }
            di      = FindInfo('\\' + string.Join("\\", sa.ToArray()));
            pattern = pattern.Replace(".", ":").Replace("?", "\\S?");
            pattern = pattern.Replace("*", "\\S*").Replace(":", "\\.");
            sa.Clear();
            Regex re = new Regex(pattern, RegexOptions.IgnoreCase);

            foreach (DirInfo d1 in entries)
            {
                if (d1.Parent != di.Index || (files && !(d1 is FileInfo)) ||
                    (!files && d1 is FileInfo))
                {
                    continue;
                }
                Match m = re.Match(d1.Name);
                if (re.Replace(d1.Name, "", 1, 0) == "")
                {
                    sa.Add(d1.Name);
                }
            }
            return(sa.ToArray());
        }
Beispiel #7
0
        private bool IsPrimaryKey(String tableName, String columnName)
        {
            IDataReader r = null;

            try
            {
                // Don't do anything if no table or column is given
                if ((tableName == "") || (columnName == ""))
                {
                    return(false);
                }

                if (currTable != tableName)
                {
                    currTable = tableName;
                    pkList.Clear();

                    r = db.ExecuteReader(
                        "select u2.column_name        " +
                        "from user_constraints u1,    " +
                        "     user_cons_columns u2    " +
                        "where u1.table_name = '" + tableName + "'  " +
                        "and constraint_type = 'P'    " +
                        "and u1.owner = u2.owner      " +
                        "and u1.constraint_name = u2.constraint_name " +
                        "and u1.table_name      = u2.table_name      " +
                        "order by position");

                    while (r.Read())
                    {
                        String ss = r.GetString(0);
                        pkList.Add(ss);
                    }
                }
            }
            finally
            {
                if (r != null)
                {
                    r.Close();
                }
            }

            return(pkList.Contains(columnName));
        }
Beispiel #8
0
        /// <summary>
        /// Start the server instance
        /// </summary>
        /// <param name="statusDisplay">Status display object to use (can be null)</param>
        /// <param name="commandInterface">Command interface to use (can be null)</param>
        /// <param name="cdKeyValidator">CD key validator to use</param>
        /// <param name="connectionLogWriter">LogWriter writer to use</param>
        public static bool Start(IStatusDisplay statusDisplay, ICommandInterface commandInterface)
        {
            if (instance == null)
            {
                IGameStatsLog   gameStats;
                ICDKeyValidator cdKeyValidator;

                if (LoadConfiguredModules(out gameStats, out cdKeyValidator))
                {
                    log.Clear();
                    instance = new MasterServer(statusDisplay, commandInterface, cdKeyValidator, gameStats, logWriter);
                    instance.BeginListening();
                    return(true);
                }
            }

            return(false);
        }
        /// <summary>
        /// Sends the hierachynames to paxiom
        /// </summary>
        internal void ParseHierarchyNames(PCAxis.Paxiom.IPXModelParser.MetaHandler handler, StringCollection LanguageCodes)
        {
            string           subkey = this.Name;
            StringCollection values = new StringCollection();

            //HIERARCYNAMES
            foreach (string langCode in LanguageCodes)
            {
                values.Clear();

                foreach (string hierarchyNames in currentGrouping.HierarchyNames[langCode])
                {
                    values.Add(hierarchyNames);
                }
                handler(PXKeywords.HIERARCHYNAMES, langCode, subkey, values);
            }
            values = null;
        }
Beispiel #10
0
        /// <PXKeyword name="META_ID">
        ///   <rule>
        ///     <description>New in 2.3.</description>
        ///     <table modelName ="ValuePool">
        ///     <column modelName="MetaId"/>
        ///     </table>
        ///   </rule>
        /// </PXKeyword>
        private void ParseMetaId(PCAxis.Paxiom.IPXModelParser.MetaHandler handler)
        {
            if (this.metaids.Count > 0)
            {
                StringCollection values          = new StringCollection();
                string           subkey          = this.Name;
                string           noLanguage      = null;
                string           theStringToSend = String.Join(",", metaids.ToArray());

                log.Debug("Sending METAID string:" + theStringToSend);

                values.Clear();

                values.Add(theStringToSend);

                handler(PXKeywords.META_ID, noLanguage, subkey, values);
            }
        }
Beispiel #11
0
        /// <summary>
        /// Ensures all resources a cleaned up in an orderly fashion.
        /// </summary>

        protected virtual void Dispose(bool disposing)
        {
            if (!isDisposed)
            {
                if (extensions != null)
                {
                    extensions.Clear();
                    extensions = null;
                }

                if (root != null)
                {
                    root = null;
                }

                isDisposed = true;
            }
        }
Beispiel #12
0
        public static void buildFilter(string Filter, bool isReplace)
        {
            string[] FilterList = Filter.Split(',');

            if (isReplace)
            {
                filterList.Clear();
            }

            foreach (string filter in FilterList)
            {
                string tmp = "." + filter;
                if (filter.Length == 3 && !filterList.Contains(tmp))
                {
                    filterList.Add(tmp);
                }
            }
        }
Beispiel #13
0
        private void SplitBufToStrList(Byte[] Buffer, int bufLen, StringCollection StrList)
        {
            StrList.Clear();

            if (bufLen != 0)
            {
                int start = 0;
                for (int i = 0; i < bufLen; i++)
                {
                    if ((Buffer[i] == 0) && ((i - start) > 0))
                    {
                        String TmpStr = Encoding.GetEncoding(0).GetString(Buffer, start, i - start);
                        StrList.Add(TmpStr);
                        start = i + 1;
                    }
                }
            }
        }
        /// <PXKeyword name="VALUESET_ID">
        ///   <rule>
        ///     <description> </description>
        ///     <table modelName ="ValueSet">
        ///     <column modelName="ValueSet"/>
        ///     </table>
        ///   </rule>
        /// </PXKeyword>
        /// <PXKeyword name="VALUESET_NAME">
        ///   <rule>
        ///     <description> </description>
        ///     <table modelName ="ValueSet">
        ///     <column modelName="PresText"/>
        ///     </table>
        ///   </rule>
        /// </PXKeyword>
        private void ParseValueSetKeywords(PCAxis.Paxiom.IPXModelParser.MetaHandler handler, StringCollection LanguageCodes)
        {
            StringCollection values     = new StringCollection();
            string           subkey     = this.Name;
            string           noLanguage = null;
            bool             parseValueSet;

            if (meta.inPresentationModus)
            {
                parseValueSet = true;
            }
            else
            {
                if ((this.ValueSets.Values.Count > 1) || (this.groupingInfos.Infos.Count > 0))
                {
                    parseValueSet = true;
                }
                else
                {
                    parseValueSet = false;
                }
            }


            if (parseValueSet)
            {
                foreach (PXSqlValueSet valueSet in this.ValueSets.Values)
                {
                    values.Add(valueSet.ValueSet);
                }
                handler(PXKeywords.VALUESET_ID, noLanguage, subkey, values);

                foreach (string langCode in LanguageCodes)
                {
                    values.Clear();

                    foreach (PXSqlValueSet valueSet in this.ValueSets.Values)
                    {
                        values.Add(valueSet.PresText[langCode]);
                    }
                    handler(PXKeywords.VALUESET_NAME, langCode, subkey, values);
                }
            }
        }
Beispiel #15
0
        //========================================================================================
        // Helpers
        //========================================================================================

        /// <summary>
        /// Scan the entire library and extract all unique media file extensions, returning
        /// only extensions mapping to system-registered audio types.
        /// </summary>
        /// <returns>
        /// A collection of file extensions, where each extension is of the form ".xxx"
        /// </returns>

        protected override StringCollection LoadExtensions()
        {
            StringCollection extensions = new StringCollection();

            // dive down to <key>Tracks</key>

            var tracks =
                from node in root
                .Element(ns + "dict")
                .Elements(ns + "key")
                where node.Value == "Tracks"
                select node.NextNode;

            // Tracks/dict is the container for all tracks where each is a key/dict pair
            // Extract all Location extension values into an IEnumerable<string>

            var extlist =
                from node in ((XElement)tracks.Single())
                .Elements(ns + "dict")
                .Elements(ns + "key")
                where node.Value == "Location"
                select Path.GetExtension(((XElement)node.NextNode).Value).ToLower();

            if (extlist != null)
            {
                StringCollection list = FilterMusicalExtensions(extlist.Distinct());
                foreach (string ext in list)
                {
                    extensions.Add(ext);
                }

                list.Clear();
                list = null;
            }

            extlist = null;
            tracks  = null;

            // add some well-known extensions if missing
            base.AddKnownExtensions(extensions);

            return(extensions);
        }
Beispiel #16
0
        public static void FetchRealTimeData(DateTime updateTime)
        {
            StringCollection aFields = new StringCollection();
            int idx = 0;

            while (true)
            {
                aFields.Clear();
                aFields.Add("url" + idx.ToString()); aFields.Add("stockExchange" + idx.ToString());
                if (!GetConfig("UPDATEDATA", "updateSource", aFields))
                {
                    break;
                }
                common.fileFuncs.WriteLog(updateTime.ToString() + " : update data from " + aFields[0] + " " + aFields[1]);
                imports.libs.ImportPricedata_URL(updateTime, aFields[0], aFields[1]);
                idx++;
            }
            return;
        }
Beispiel #17
0
        /// <summary>
        /// Return the next line in the file as a collection of words.
        /// </summary>
        /// <param name="inData">The in.</param>
        /// <param name="words">The words.</param>
        /// <returns></returns>
        /// <exception cref="System.Exception">Invalid number of values on line:  + Line + \r\nin file:  + _FileName</exception>
        private bool GetNextLine(StreamReaderRandomAccess inData, ref StringCollection words)
        {
            if (inData.EndOfStream)
            {
                return(false);
            }

            string Line = inData.ReadLine();

            if (Line == null || Line.Length == 0)
            {
                return(false);
            }

            if (Line.IndexOf("!") > 0) //used to ignore "!" in a row
            {
                Line = Line.Substring(0, Line.IndexOf("!") - 1);
            }

            if (IsCSVFile)
            {
                words.Clear();
                Line = Line.TrimEnd(',');
                words.AddRange(Line.Split(",".ToCharArray()));
            }
            else
            {
                words = StringUtilities.SplitStringHonouringQuotes(Line, " \t");
            }

            if (words.Count != Headings.Count)
            {
                throw new Exception("Invalid number of values on line: " + Line + "\r\nin file: " + _FileName);
            }

            // Remove leading / trailing double quote chars.
            for (int i = 0; i < words.Count; i++)
            {
                words[i] = words[i].Trim("\"".ToCharArray());
            }

            return(true);
        }
Beispiel #18
0
        private void GetStringsFromBuffer(byte[] Buffer, int bufLen, StringCollection Strings)
        {
            Strings.Clear();
            if (bufLen == 0)
            {
                return;
            }
            int num = 0;

            for (int i = 0; i < bufLen; i++)
            {
                if (Buffer[i] == 0 && i - num > 0)
                {
                    string @string = Encoding.GetEncoding(0).GetString(Buffer, num, i - num);
                    Strings.Add(@string);
                    num = i + 1;
                }
            }
        }
Beispiel #19
0
        public static bool SaveLocalConfig(Meta meta)
        {
            StringCollection aFields = new StringCollection();

            aFields.Clear();
            aFields.Add("params");
            aFields.Add("output");
            aFields.Add("drawInNewWindow");
            StringCollection aValues = new StringCollection();

            aValues.Add(common.system.ToString(meta.Parameters));
            aValues.Add(Meta.OutputInfo2Tring(meta.Output));
            aValues.Add(meta.DrawInNewWindow.ToString());
            if (!Configuration.SaveLocalUserConfig(meta.ClassType.FullName, aFields, aValues))
            {
                return(false);
            }
            return(true);
        }
        private void saveToSettings_Click(object sender, EventArgs e)
        {
            //try
            //{
            //    StringCollection mysettings = Properties.Settings.Default.one;
            //    listOfSSIDs.SelectionMode = SelectionMode.One;
            //    int m = 0;
            //    if (mysettings.Count > 0)
            //    {
            //        foreach (string setting in mysettings)

            //        {
            //            string[] _mysetting = setting.Split(",".ToCharArray());

            //            listOfSSIDs.Items.Add(_mysetting[0].Trim());
            //            listOFPasswords.Items.Add(_mysetting[1].Trim());
            //            listOfAuths.Items.Add(_mysetting[2].Trim());
            //            Console.WriteLine(setting);
            //            // to be done later listOfSSIDs.Items.Add(setting);
            //            //mypasswords.Add(setting);
            //        }
            //    }
            //}
            //catch (Exception ex)
            //{
            //    MessageBox.Show("Exception detected whilst reading ssid settings", "Exception text " + ex.Message);
            //}

            StringCollection mysettings = Properties.Settings.Default.one;

            mysettings.Clear();
            //Properties.Settings.Default.Save();

            int m = listOfSSIDs.Items.Count;
            int n = -1;

            foreach (string _ssid in listOfSSIDs.Items)
            {
                n++;
                mysettings.Add(listOfSSIDs.Items[n].ToString() + ',' + listOFPasswords.Items[n].ToString() + ',' + listOfAuths.Items[n].ToString());
            }
            Properties.Settings.Default.Save();
        }
Beispiel #21
0
 /// <summary>
 ///
 /// </summary>
 /// <param name="language"></param>
 /// <param name="version"></param>
 public static void LoadPhpbbFileList(string language, ModVersion version)
 {
     PhpbbFileList.Clear();
     if (version.Major == 2 && version.Minor == 0)
     {
         PhpbbFileList.AddRange(OpenTextFile(Path.Combine(domain.BaseDirectory, "files.txt")).Replace("\r\n", "\n").Split('\n'));
     }
     else if (version.Major == 3 && version.Minor == 0)
     {
         PhpbbFileList.AddRange(OpenTextFile(Path.Combine(domain.BaseDirectory, "files_3.0.txt")).Replace("\r\n", "\n").Split('\n'));
     }
     if (language != "english")
     {
         for (int i = 0; i < PhpbbFileList.Count; i++)
         {
             PhpbbFileList[i] = PhpbbFileList[i].Replace("english", language);
         }
     }
 }
Beispiel #22
0
        /// <summary>
        /// Bind data for this control.
        /// </summary>
        private void BindData()
        {
            // list roles of this board
            DataTable dt = DB.group_list(PageContext.PageBoardID, null);

            // set repeater datasource
            RoleListYaf.DataSource = dt;

            // clear cached list of roles
            _availableRoles.Clear();

            // get all provider roles
            foreach (string role in Roles.GetAllRoles())
            {
                // make filter string, we want to filer by role name
                string filter = string.Format("Name='{0}'", role.Replace("'", "''"));
                // get given role of YAF
                DataRow[] rows = dt.Select(filter);

                // if this role is not in YAF DB, add it to the list of provider roles for syncing
                if (rows.Length == 0)
                {
                    // doesn't exist in the Yaf Groups
                    _availableRoles.Add(role);
                }
            }

            // check if there are any roles for syncing
            if (_availableRoles.Count > 0)
            {
                //make it datasource
                RoleListNet.DataSource = _availableRoles;
            }
            else
            {
                // no datasource for provider roles
                RoleListNet.DataSource = null;
            }

            // bind data to controls
            DataBind();
        }
Beispiel #23
0
        //===================================================================
        // We __really__ want to avoid using Python objects or APIs when
        // probing for assemblies to load, since our ResolveHandler may be
        // called in contexts where we don't have the Python GIL and can't
        // even safely try to get it without risking a deadlock ;(
        //
        // To work around that, we update a managed copy of sys.path (which
        // is the main thing we care about) when UpdatePath is called. The
        // import hook calls this whenever it knows its about to use the
        // assembly manager, which lets us keep up with changes to sys.path
        // in a relatively lightweight and low-overhead way.
        //===================================================================

        internal static void UpdatePath()
        {
            IntPtr list  = Runtime.PySys_GetObject("path");
            int    count = Runtime.PyList_Size(list);

            if (count != pypath.Count)
            {
                pypath.Clear();
                probed.Clear();
                for (int i = 0; i < count; i++)
                {
                    IntPtr item = Runtime.PyList_GetItem(list, i);
                    string path = Runtime.GetManagedString(item);
                    if (path != null)
                    {
                        pypath.Add(path);
                    }
                }
            }
        }
Beispiel #24
0
 // --------------------------------------------------
 // Return a list of sibling component names and types
 // for the specified data component
 // --------------------------------------------------
 private static void GetSiblingComponents(ApsimFile.Component Paddock, ref StringCollection ComponentNames, ref StringCollection ComponentTypes)
 {
     ComponentNames.Clear();
     ComponentTypes.Clear();
     if (Paddock != null)
     {
         if ((Paddock.Parent != null) && (Paddock.Parent.Parent != null))
         {
             GetSiblingComponents(Paddock.Parent, ref ComponentNames, ref ComponentTypes);
         }
         foreach (ApsimFile.Component Sibling in Paddock.ChildNodes)
         {
             if ((Sibling.Type.ToLower() != "simulation") && (Sibling.Type.ToLower() != "graph"))
             {
                 ComponentNames.Add(Sibling.Name);
                 ComponentTypes.Add(Sibling.Type);
             }
         }
     }
 }
Beispiel #25
0
        public static bool Save_Local_UserSettings_STOCK()
        {
            //Systen tab
            StringCollection aFields = new StringCollection();
            StringCollection aValues = new StringCollection();

            aFields.Clear();
            aFields.Add(common.system.GetName(new { Settings.sysStockMaxBuyQtyPerc }));
            aFields.Add(common.system.GetName(new { Settings.sysStockReduceQtyPerc }));
            aFields.Add(common.system.GetName(new { Settings.sysStockAccumulateQtyPerc }));
            aFields.Add(common.system.GetName(new { Settings.sysStockTotalCapAmt }));
            aFields.Add(common.system.GetName(new { Settings.sysStockMaxBuyAmtPerc }));
            aValues.Clear();
            aValues.Add(common.system.Number2String_Common(Settings.sysStockMaxBuyQtyPerc));
            aValues.Add(common.system.Number2String_Common(Settings.sysStockReduceQtyPerc));
            aValues.Add(common.system.Number2String_Common(Settings.sysStockAccumulateQtyPerc));
            aValues.Add(common.system.Number2String_Common(Settings.sysStockTotalCapAmt));
            aValues.Add(common.system.Number2String_Common(Settings.sysStockMaxBuyAmtPerc));
            return(SaveLocalUserConfig("STOCK", aFields, aValues));
        }
Beispiel #26
0
        private void GetStringsFromBuffer(byte[] buffer, int bufLen, StringCollection strings)
        {
            strings.Clear();
            if (bufLen == 0)
            {
                return;
            }

            int start = 0;

            for (int i = 0; i < bufLen; i++)
            {
                if ((buffer[i] == 0) && ((i - start) > 0))
                {
                    string s = IniEncoding.GetString(buffer, start, i - start);
                    strings.Add(s);
                    start = i + 1;
                }
            }
        }
Beispiel #27
0
        private void btnUpdate_Click(object sender, EventArgs e)
        {
            manualDBs.Clear();
            IList list = this.bindingSource1.List;

            for (int i = 0; i < list.Count; i++)
            {
                DatabaseItem item = (DatabaseItem)list[i];
                if (item.DatabaseName != null && item.DatabaseName.Trim().Length > 0)
                {
                    manualDBs.Add(item.DatabaseName);
                }
            }

            SqlSync.DbInformation.Properties.Settings.Default.ManuallyEnteredDatabases = manualDBs;
            SqlSync.DbInformation.Properties.Settings.Default.Save();

            this.DialogResult = DialogResult.OK;
            this.Close();
        }
Beispiel #28
0
        internal void ParseCandidateMustSelect(PCAxis.Paxiom.IPXModelParser.MetaHandler handler, string preferredLanguage)
        {
            string           subkey     = this.Name;
            string           noLanguage = null;
            StringCollection values     = new StringCollection();



            values.Clear();
            if (isCandidateMustSelect())
            {
                values.Add(PXConstant.YES);
            }
            else
            {
                values.Add(PXConstant.NO);
            }

            //handler(PXKeywords.POSSIBLENOTELIM, noLanguage, subkey, values);
            handler("CandidateMustSelect", noLanguage, subkey, values);
        }
Beispiel #29
0
 /// <summary>
 /// Return the next line of data from the file as an array of objects.
 /// </summary>
 /// <returns></returns>
 /// <exception cref="System.Exception">End of file reached while reading file:  + _FileName</exception>
 public object[] GetNextLineOfData()
 {
     Words.Clear();
     if (IsExcelFile)
     {
         object[] values = _excelData.Rows[excelIndex].ItemArray;
         excelIndex++;
         return(values);
     }
     else
     {
         if (GetNextLine(inStreamReader, ref Words))
         {
             return(ConvertWordsToObjects(Words, ColumnTypes));
         }
         else
         {
             throw new Exception("End of file reached while reading file: " + _FileName);
         }
     }
 }
        private void Update()
        {
            var current = this.current as XmlTreeNode;

            if (current != null)
            {
                current.EndPosition = linePositions[reader.LineNumber];
            }
            if (name != null)
            {
                var builder = new StringBuilder();
                for (int i = 0; i < attrNames.Count; i++)
                {
                    builder.Append(" " + attrNames[i] + " = " + attrValues[i]);
                }
                this.current.Text = name + builder;
                attrNames.Clear();
                attrValues.Clear();
                name = null;
            }
        }
        /// <summary>
        /// Current assembly wide search for the type, type will be found even
        /// if this assembly doesn't reference to the assembly where type resides
        /// As long as type is loaded, it will found it no matter what.
        /// </summary>
        /// <param name="aName">
        /// Name if type searched, has to be specified with namespace <see cref="System.String"/>
        /// </param>
        /// <returns>
        /// null if unknown or Type if found <see cref="System.Type"/>
        /// </returns>
        public static System.Type GetTypeInWholeAssembly(string aName)
        {
            // Try to find type localy
            System.Type dtype = Type.GetType(aName, false);              // static method
            if (dtype != null)
            {
                return(dtype);
            }

            // Try to find type in main assembly
            StringCollection cache = new StringCollection();

            // Since basic GetType already searches in mscorlib we can safely put it as already done
            cache.Add("mscorlib");

            dtype = GetTypeInAssembly(Assembly.GetEntryAssembly(), aName, cache);
            cache.Clear();
            cache = null;

            return(dtype);
        }
Beispiel #32
0
 public static void CountTest(StringCollection collection, string[] data)
 {
     Assert.Equal(data.Length, collection.Count);
     collection.Clear();
     Assert.Equal(0, collection.Count);
     collection.Add("one");
     Assert.Equal(1, collection.Count);
     collection.AddRange(data);
     Assert.Equal(1 + data.Length, collection.Count);
 }
Beispiel #33
0
 public static void ClearTest(StringCollection collection, string[] data)
 {
     Assert.Equal(data.Length, collection.Count);
     collection.Clear();
     Assert.Equal(0, collection.Count);
 }
Beispiel #34
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";
     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. Count on empty collection");
         iCountTestcases++;
         if (sc.Count != 0) 
         {
             iCountErrors++;
             Console.WriteLine("Err_0001, returned {0} for empty collection", sc.Count);
         }
         Console.WriteLine("2. add simple strings and verify Count");
         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);
         } 
         iCountTestcases++;
         sc.Clear();
         sc.AddRange(values);
         if (sc.Count != values.Length) 
         {
             iCountErrors++;
             Console.WriteLine("Err_0002b, count is {0} instead of {1}", sc.Count, values.Length);
         } 
         Console.WriteLine("3. add intl strings and verify Count");
         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;
         } 
         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);
         } 
         iCountTestcases++;
         sc.Clear();
         sc.AddRange(intlValues);
         if ( sc.Count != intlValues.Length ) 
         {
             iCountErrors++;
             Console.WriteLine("Err_0003b, count is {0} instead of {1}", sc.Count, intlValues.Length);
         } 
     } 
     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;
     }
 }
Beispiel #36
0
	private void getStringsFromBuffer(Byte[] Buffer, int bufLen, StringCollection Strings)
	{
		Strings.Clear();
		if (bufLen != 0)
		{
			int start = 0;
			for (int i = 0; i < bufLen; i++)
			{
				if ((Buffer[i] == 0) && ((i - start) > 0))
				{
					String s = Encoding.GetEncoding(0).GetString(Buffer, start, i - start);
					Strings.Add(s);
					start = i + 1;
				}
			}
		}
	}
Beispiel #37
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";
     StringCollection sc; 
     string [] values = 
     {
         "",
         " ",
         "a",
         "aa",
         "text",
         "     spaces",
         "1",
         "$%^#",
         "2222222222222222222222222",
         System.DateTime.Today.ToString(),
         Int32.MaxValue.ToString()
     };
     string[] destination;
     int cnt = 0;            
     try
     {
         intl = new IntlStrings(); 
         Console.WriteLine("--- create collection ---");
         strLoc = "Loc_001oo"; 
         iCountTestcases++;
         sc = new StringCollection();
         Console.WriteLine("1. Copy empty collection into empty array");
         iCountTestcases++;
         destination = new string[values.Length];
         for (int i = 0; i < values.Length; i++) 
         {
             destination[i] = "";
         }
         sc.CopyTo(destination, 0);
         if( destination.Length != values.Length) 
         {
             iCountErrors++;
             Console.WriteLine("Err_0001a, altered array after copying empty collection");
         } 
         if (destination.Length == values.Length) 
         {
             for (int i = 0; i < values.Length; i++) 
             {
                 iCountTestcases++;
                 if (String.Compare(destination[i], "", false) != 0) 
                 {
                     iCountErrors++;
                     Console.WriteLine("Err_0001_{0}b, item = \"{1}\" insteead of \"{2}\" after copying empty collection", i, destination[i], "");
                 }
             } 
         }
         Console.WriteLine("2. Copy empty collection into non-empty array");
         iCountTestcases++;
         destination = values;
         sc.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[i], 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([], 0)");
         strLoc = "Loc_003oo"; 
         iCountTestcases++;
         cnt = sc.Count;
         sc.AddRange(values);
         if (sc.Count != values.Length) 
         {
             iCountErrors++;
             Console.WriteLine("Err_0003a, count is {0} instead of {1}", sc.Count, values.Length);
         } 
         destination = new string[values.Length];
         sc.CopyTo(destination, 0);
         for (int i = 0; i < values.Length; i++) 
         {
             iCountTestcases++;
             if ( String.Compare(sc[i], destination[i], false) != 0 ) 
             {
                 iCountErrors++;
                 Console.WriteLine("Err_0003_{0}b, copied \"{1}\" instead of \"{2}\"", i, destination[i], sc[i]);
             } 
         }
         Console.WriteLine("4. add simple strings and CopyTo([], {0})", values.Length);
         sc.Clear();
         strLoc = "Loc_004oo"; 
         iCountTestcases++;
         cnt = sc.Count;
         sc.AddRange(values);
         if (sc.Count != values.Length) 
         {
             iCountErrors++;
             Console.WriteLine("Err_0003a, count is {0} instead of {1}", sc.Count, values.Length);
         } 
         destination = new string[values.Length * 2];
         sc.CopyTo(destination, values.Length);
         for (int i = 0; i < values.Length; i++) 
         {
             iCountTestcases++;
             if ( String.Compare(sc[i], destination[i+values.Length], false) != 0 ) 
             {
                 iCountErrors++;
                 Console.WriteLine("Err_0003_{0}b, copied \"{1}\" instead of \"{2}\"", i, destination[i+values.Length], sc[i]);
             } 
         }
         Console.WriteLine("5. add intl strings and CopyTo([], 0)");
         strLoc = "Loc_005oo"; 
         iCountTestcases++;
         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;
         } 
         iCountTestcases++;
         sc.Clear();
         sc.AddRange(intlValues);
         if ( sc.Count != (intlValues.Length) ) 
         {
             iCountErrors++;
             Console.WriteLine("Err_0005a, count is {0} instead of {1}", sc.Count, intlValues.Length);
         } 
         destination = new string[intlValues.Length];
         sc.CopyTo(destination, 0);
         for (int i = 0; i < intlValues.Length; i++) 
         {
             iCountTestcases++;
             if ( String.Compare(sc[i], destination[i], false) != 0 ) 
             {
                 iCountErrors++;
                 Console.WriteLine("Err_0005_{0}b, copied \"{1}\" instead of \"{2}\"", i, destination[i], sc[i]);
             } 
         }
         Console.WriteLine("6. add intl strings and CopyTo([], {0})", intlValues.Length);
         strLoc = "Loc_006oo"; 
         iCountTestcases++;
         sc.Clear();
         sc.AddRange(intlValues);
         if ( sc.Count != (intlValues.Length) ) 
         {
             iCountErrors++;
             Console.WriteLine("Err_0006a, count is {0} instead of {1}", sc.Count, intlValues.Length);
         } 
         destination = new string[intlValues.Length*2];
         sc.CopyTo(destination, intlValues.Length);
         for (int i = 0; i < intlValues.Length; i++) 
         {
             iCountTestcases++;
             if ( String.Compare(sc[i], destination[i+intlValues.Length], false) != 0 ) 
             {
                 iCountErrors++;
                 Console.WriteLine("Err_0006_{0}b, copied \"{1}\" instead of \"{2}\"", i, destination[i+intlValues.Length], sc[i]);
             } 
         }
         Console.WriteLine("7. CopyTo(null, int)");
         strLoc = "Loc_007oo"; 
         iCountTestcases++;
         sc.Clear();
         sc.AddRange(values);
         if ( sc.Count != (intlValues.Length) ) 
         {
             iCountErrors++;
             Console.WriteLine("Err_0007a, count is {0} instead of {1}", sc.Count, intlValues.Length);
         } 
         destination = null;
         try 
         {
             sc.CopyTo(destination, 0);
             iCountErrors++;
             Console.WriteLine("Err_0007b: no exception ");
         }
         catch (ArgumentNullException ex) 
         {
             Console.WriteLine("  Expected exception: {0}", ex.Message);
         }
         catch (Exception e) 
         {
             iCountErrors++;
             Console.WriteLine("Err_0007c, unexpected exception: {0}", e.ToString());
         }
         Console.WriteLine("8. CopyTo(string[], -1)");
         strLoc = "Loc_008oo"; 
         iCountTestcases++;
         if (sc.Count != values.Length ) 
         {
             sc.Clear();
             sc.AddRange(values);
             if ( sc.Count != (intlValues.Length) ) 
             {
                 iCountErrors++;
                 Console.WriteLine("Err_0008a, count is {0} instead of {1}", sc.Count, intlValues.Length);
             } 
         }
         destination = new string[values.Length];
         try 
         {
             sc.CopyTo(destination, -1);
             iCountErrors++;
             Console.WriteLine("Err_0008b: no exception ");
         }
         catch (ArgumentOutOfRangeException ex) 
         {
             Console.WriteLine("  Expected exception: {0}", ex.Message);
         }
         catch (Exception e) 
         {
             iCountErrors++;
             Console.WriteLine("Err_0008c, unexpected exception: {0}", e.ToString());
         }
         Console.WriteLine("9. CopyTo(string[], upperBound+1)");
         strLoc = "Loc_009oo"; 
         iCountTestcases++;
         if (sc.Count != values.Length ) 
         {
             sc.Clear();
             sc.AddRange(values);
             if ( sc.Count != (intlValues.Length) ) 
             {
                 iCountErrors++;
                 Console.WriteLine("Err_0009a, count is {0} instead of {1}", sc.Count, intlValues.Length);
             } 
         }
         destination = new string[values.Length];
         try 
         {
             sc.CopyTo(destination, values.Length);
             iCountErrors++;
             Console.WriteLine("Err_0009b: no exception ");
         }
         catch (ArgumentException 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(string[], upperBound+2)");
         strLoc = "Loc_010oo"; 
         iCountTestcases++;
         if (sc.Count != values.Length ) 
         {
             sc.Clear();
             sc.AddRange(values);
             if ( sc.Count != (intlValues.Length+1) ) 
             {
                 iCountErrors++;
                 Console.WriteLine("Err_0010a, count is {0} instead of {1}", sc.Count, intlValues.Length);
             } 
         }
         destination = new string[values.Length];
         try 
         {
             sc.CopyTo(destination, values.Length);
             iCountErrors++;
             Console.WriteLine("Err_0010b: no exception ");
         }
         catch (ArgumentException ex) 
         {
             Console.WriteLine("  Expected exception: {0}", ex.Message);
         }
         catch (Exception e) 
         {
             iCountErrors++;
             Console.WriteLine("Err_0009c, unexpected exception: {0}", e.ToString());
         }
         Console.WriteLine("11. CopyTo(string[], not_enough_space)");
         strLoc = "Loc_011oo"; 
         iCountTestcases++;
         if (sc.Count != values.Length ) 
         {
             sc.Clear();
             sc.AddRange(values);
             if ( sc.Count != (intlValues.Length) ) 
             {
                 iCountErrors++;
                 Console.WriteLine("Err_0011a, count is {0} instead of {1}", sc.Count, intlValues.Length);
             } 
         }
         destination = new string[values.Length];
         try 
         {
             sc.CopyTo(destination, values.Length / 2);
             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());
         }
     } 
     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;
     }
 }
Beispiel #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";
     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;
     }
 }
Beispiel #39
0
        /// <summary>
        /// Specify custom item specify
        /// </summary>
        /// <returns></returns>
        private NameValueListTypeCollection getCIS()
        {
            NameValueListTypeCollection list = new NameValueListTypeCollection();
            StringCollection tmp=new StringCollection();

            NameValueListType nameValue1=new NameValueListType();
            nameValue1.Name="test specifics(add name1)";
            tmp.Add("test specifics(add value1)");
            nameValue1.Value=tmp;

            NameValueListType nameValue2=new NameValueListType();
            nameValue2.Name="test specifics(add name2)";
            tmp.Clear();
            tmp.Add("test specifics(add value2)");
            nameValue2.Value=tmp;

            list.Add(nameValue1);
            list.Add(nameValue2);

            return list;
        }
    // input Entry protection/validation data
    private void initData()
    {
      // Forces validation.
      GridWeb1.ForceValidation = true;

      string path = Server.MapPath("~");
      path = path.Substring(0, path.LastIndexOf("\\"));
      string fileName = path + "\\File\\Input.xls";

      // Imports from a excel file.
      GridWeb1.ImportExcelFile(fileName);

      GridWorksheetCollection sheets = GridWeb1.WorkSheets;

      // Sets cell validation.
      GridValidationCollection gridValidationCollection = sheets[0].Validations;

      // Regular expression.
      GridValidation C5 = gridValidationCollection.Add();
      C5.AddACell("C5");
      //C5.Operator = OperatorType.BETWEEN;
      C5.ValidationType = GridValidationType.CustomExpression;
      C5.RegEx = @"\d{6}";

      // Number.
      GridValidation C6 = gridValidationCollection.Add();
      C6.AddACell("C6");
      C6.ValidationType = GridValidationType.Decimal;

      // Integer.
      GridValidation C7 = gridValidationCollection.Add();
      C7.AddACell("C7");
      C7.ValidationType = GridValidationType.WholeNumber;

      // Date.
      GridValidation C8 = gridValidationCollection.Add();
      C8.AddACell("C8");
      C8.ValidationType = GridValidationType.Date;

      // DateTime
      GridValidation C9 = gridValidationCollection.Add();
      C9.AddACell("C9");
      C9.ValidationType = GridValidationType.DateTime;

      // List.
      GridValidation C10 = gridValidationCollection.Add();
      C10.AddACell("C10");
      C10.ValidationType = GridValidationType.List;
      StringCollection value = new StringCollection();
      value.Add("Fortran");
      value.Add("Pascal");
      value.Add("C++");
      value.Add("Visual Basic");
      value.Add("Java");
      value.Add("C#");
      C10.ValueList = value;
      value.Clear();

      // DropDownList.
      GridValidation C11 = gridValidationCollection.Add();
      C11.AddACell("C11");
      C11.ValidationType = GridValidationType.DropDownList;
      value.Add("Bachelor");
      value.Add("Master");
      value.Add("Doctor");
      C11.ValueList = value;

      // FreeList
      GridValidation C12 = gridValidationCollection.Add();
      C12.AddACell("C12");
      C12.ValidationType = GridValidationType.FreeList;
      value.Add("US");
      value.Add("Britain");
      value.Add("France");
      C12.ValueList = value;

      // Custom function
      GridValidation C13 = gridValidationCollection.Add();
      C13.AddACell("C13");
      C13.ValidationType = GridValidationType.CustomFunction;
      C13.ClientValidationFunction = "myvalidation1";

      // CheckBox
      GridValidation C14 = gridValidationCollection.Add();
      C14.AddACell("C14");
      C14.ValidationType = GridValidationType.CheckBox;
    }
Beispiel #41
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";
     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;
     String strLoc = "Loc_000oo";
     StringCollection sc; 
     string [] values = 
     {
         "",
         " ",
         "a",
         "aa",
         "text",
         "     spaces",
         "1",
         "$%^#",
         "2222222222222222222222222",
         System.DateTime.Today.ToString(),
         Int32.MaxValue.ToString()
     };
     try
     {
         Console.WriteLine("--- create collection ---");
         strLoc = "Loc_001oo"; 
         iCountTestcases++;
         sc = new StringCollection();
         Console.WriteLine("1. IsSynchronized on empty collection");
         iCountTestcases++;
         if (sc.IsSynchronized) 
         {
             iCountErrors++;
             Console.WriteLine("Err_0001, returned true for empty collection");
         }
         Console.WriteLine("2. IsSynchronized for filled collection");
         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);
         } 
         iCountTestcases++;
         if (sc.IsSynchronized) 
         {
             iCountErrors++;
             Console.WriteLine("Err_0002b, returned true for filled collection");
         } 
     } 
     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;
     }
 }
Beispiel #43
0
  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 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;
     }
 }
Beispiel #45
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";
     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. get Item from empty collection");
         Console.WriteLine(" (-1)th");
         strLoc = "Loc_001oo"; 
         iCountTestcases++;
         try 
         {
             itm = sc[-1];
             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");
         iCountTestcases++;
         try 
         {
             itm = sc[0];
             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("2. Get Item on collection with simple strings");
         strLoc = "Loc_002oo";
         sc.Clear(); 
         iCountTestcases++;
         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 (String.Compare(sc[i], values[i], false) != 0) 
             {
                 iCountErrors++;
                 Console.WriteLine("Err_0002_{0}b, returned {1} instead of {2}", i, sc[i], values[i]);
             } 
         }
         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++;
         int 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);
         } 
         cnt = values.Length;
         for (int i = cnt; i < cnt + intlValues.Length; i++) 
         {
             iCountTestcases++;
             if (String.Compare(sc[i], intlValues[i-cnt], false) != 0) 
             {
                 iCountErrors++;
                 Console.WriteLine("Err_0003_{0}b, returned {1} instead of {2}", i, sc[i], intlValues[i-cnt]);
             } 
         }
         Console.WriteLine("4. case sensitivity");
         strLoc = "Loc_004oo"; 
         string intlStr = intlValues[0];
         intlStr = intlStr.ToUpper();
         sc.Clear();
         sc.Add(intlStr);            
         iCountTestcases++;
         if ( sc.Count != 1 ) 
         {
             iCountErrors++;
             Console.WriteLine("Err_0004a, count is {0} instead of 1", sc.Count);
         } 
         iCountTestcases++;
         if (!caseInsensitive && (String.Compare(sc[0], intlValues[0].ToLower(), false) == 0)) 
         {
             iCountErrors++;
             Console.WriteLine("Err_0004b, returned unexpected result: {0} when should have return all upper", sc[0]);
         } 
         iCountTestcases++;
         if (String.Compare(sc[0], intlStr, false) != 0) 
         {
             iCountErrors++;
             Console.WriteLine("Err_0004c, returned {0} instead of {1}", sc[0], intlStr);
         } 
         Console.WriteLine("4. get [-1]");
         sc.Clear();
         sc.AddRange(intlValues);
         Console.WriteLine(" collection contains {0} items", sc.Count);
         strLoc = "Loc_004oo"; 
         iCountTestcases++;
         try 
         {
             itm = sc[-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. get [Count]");
         strLoc = "Loc_005oo"; 
         iCountTestcases++;
         try 
         {
             itm = sc[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. get [Count + 1]");
         strLoc = "Loc_006oo"; 
         iCountTestcases++;
         try 
         {
             itm = sc[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;
     }
 }