コード例 #1
0
        public void RandomizeListsTest()
        {
            PFList <string> list1 = new PFList <string>();
            PFKeyValueList <int, string>       kvlist2   = new PFKeyValueList <int, string>();
            PFKeyValueListSorted <int, string> sortlist3 = new PFKeyValueListSorted <int, string>();

            try
            {
                _msg.Length = 0;
                _msg.Append("RandomizeListsTest started ...\r\n");
                Program._messageLog.WriteLine(_msg.ToString());

                list1.Add("First");
                list1.Add("Second");
                list1.Add("Third");
                list1.Add("fourth");
                list1.Add("fifth");
                list1.Add("sixth");
                list1.Add("Seventh");
                list1.Add("Eighth");
                list1.Add("Ninth");
                list1.Add("Tenth");

                PFList <string> randomizedList = list1.Randomize();

                _msg.Length = 0;
                _msg.Append("randomizedList: ");
                _msg.Append(Environment.NewLine);
                _msg.Append(randomizedList.ToXmlString());
                Program._messageLog.WriteLine(_msg.ToString());

                kvlist2.Add(new stKeyValuePair <int, string>(1, "First"));
                kvlist2.Add(new stKeyValuePair <int, string>(2, "Second"));
                kvlist2.Add(new stKeyValuePair <int, string>(3, "Third"));
                kvlist2.Add(new stKeyValuePair <int, string>(4, "fourth"));
                kvlist2.Add(new stKeyValuePair <int, string>(5, "fifth"));
                kvlist2.Add(new stKeyValuePair <int, string>(6, "sixth"));
                kvlist2.Add(new stKeyValuePair <int, string>(7, "Seventh"));
                kvlist2.Add(new stKeyValuePair <int, string>(8, "Eighth"));
                kvlist2.Add(new stKeyValuePair <int, string>(9, "Ninth"));
                kvlist2.Add(new stKeyValuePair <int, string>(10, "Tenth"));

                PFKeyValueList <int, string> randomizedKvList = kvlist2.Randomize();

                _msg.Length = 0;
                _msg.Append("randomizedKvList: ");
                _msg.Append(Environment.NewLine);
                _msg.Append(randomizedKvList.ToXmlString());
                Program._messageLog.WriteLine(_msg.ToString());

                sortlist3.Add(1, "First");
                sortlist3.Add(2, "Second");
                sortlist3.Add(3, "Third");
                sortlist3.Add(4, "fourth");
                sortlist3.Add(5, "fifth");
                sortlist3.Add(6, "sixth");
                sortlist3.Add(7, "Seventh");
                sortlist3.Add(8, "Eighth");
                sortlist3.Add(9, "Ninth");
                sortlist3.Add(10, "Tenth");

                PFKeyValueList <int, string> randomizedSortList = sortlist3.Randomize();

                _msg.Length = 0;
                _msg.Append("randomizedSortList: ");
                _msg.Append(Environment.NewLine);
                _msg.Append(randomizedSortList.ToXmlString());
                Program._messageLog.WriteLine(_msg.ToString());
            }
            catch (System.Exception ex)
            {
                _msg.Length = 0;
                _msg.Append(AppGlobals.AppMessages.FormatErrorMessage(ex));
                Program._messageLog.WriteLine(_msg.ToString());
                AppMessages.DisplayErrorMessage(_msg.ToString(), _saveErrorMessagesToAppLog);
            }
            finally
            {
                _msg.Length = 0;
                _msg.Append("\r\n... RandomizeListsTest finished.");
                Program._messageLog.WriteLine(_msg.ToString());
            }
        }