Esempio n. 1
0
        /// <summary>
        /// Function of sorting arrays
        /// </summary>
        /// <param name="sender">Button that activated event</param>
        /// <param name="e">Name of operation</param>
        private void SortingArrays(object sender, EventArgs e)
        {
            try
            {
                string[] split = FirstArgument.Text.Split(new Char[] { ' ', ';' });
                double[] array = new double[split.Length];

                for (int i = 0; i < split.Length; i++)
                {
                    array[i] = Validation.StringToDouble(split[i]);
                }

                string   operation         = (((Button)sender).Name);
                var      op                = SortingOfArraysFactory.CreateSorting(operation);
                double[] resultDoubleArray = op.Sort(array);
                string[] resultStringArray = new string[split.Length];

                for (int i = 0; i < array.Length; i++)
                {
                    resultStringArray[i] = Convert.ToString(resultDoubleArray[i]);
                }

                string resultString = "";

                for (int i = 0; i < resultStringArray.Length; i++)
                {
                    resultString += resultStringArray[i] + ';' + ' ';
                }

                Result.Text = resultString;
            }
            catch (Exception exception)
            {
                MessageBox.Show(exception.Message, "Error", MessageBoxButtons.OK);
            }
        }
Esempio n. 2
0
        public void CreateSorting(Type expectedTypeOfOperation, string nameOfOperation)
        {
            Type resultType = SortingOfArraysFactory.CreateSorting(nameOfOperation).GetType();

            Assert.AreEqual(expectedTypeOfOperation, resultType);
        }