private void Test()
        {
            var begin              = DateTime.Now;
            var function           = CmbBxFunction.SelectionBoxItem.ToString();
            var IDFunction         = SearchForIDFunctionInDatabaseAddIfNotExist(function);
            int IDTest             = 0;
            var textLength         = 100;
            var text               = new String('A', textLength);
            int IDText             = SearchForIDTextInDatabaseAddIfNotExist(text);
            int numberOfIterations = 100000;

            var listOfTimes = new List <TimeSpan>();

            try
            {
                for (int i = 0; i < 30; i++)
                {
                    TimeSpan CalcTime = new TimeSpan();
                    switch (function)
                    {
                    case "MD5":
                    { GetMd5Hashes(ref text, out CalcTime, numberOfIterations); break; }

                    case "SHA1":
                    { GetSHA1Hashes(ref text, out CalcTime, numberOfIterations); break; }

                    case "SHA256":
                    { GetSHA256Hashes(ref text, out CalcTime, numberOfIterations); break; }

                    default:
                    { MessageBox.Show("Function Error!"); break; }
                    }
                    listOfTimes.Add(CalcTime);
                }
                var bestTime = listOfTimes.Min();
                //Add best result to UI Table/List
                var tableCalcParams = new TableCalcParams(function, textLength, numberOfIterations, bestTime);
                IDTest = SaveTestToDatabase(IDPC, IDFunction, IDText, tableCalcParams);
                var myPoints = CalculatePoints(numberOfIterations, bestTime);
                TxtBlockPoints.Text = myPoints + " pkt";

                var foundObjects = new List <KeyValuePair <double, TableTest> >();
                DownloadAllDBResults(IDFunction, IDText, IDTest, out foundObjects);
                ShowChart(foundObjects, myPoints);
            }
            catch (Exception ex)
            { MessageBox.Show("Error: " + ex.Message); MessageBox.Show(ex.InnerException.Message); }
        }
 private int SaveTestToDatabase(int IDPC, int IDFunction, int IDText, TableCalcParams tableCalcParams)
 {
     try
     {
         var entityTest = new TableTest();
         entityTest.IDPC               = IDPC;
         entityTest.IDFunction         = IDFunction;
         entityTest.IDTest             = entityTest.IDTest;
         entityTest.IDText             = IDText;
         entityTest.NumberOfIterations = tableCalcParams.NumberOfIterations;
         entityTest.FullTime           = tableCalcParams.TestTimeInSeconds;
         entityTest = conn.TableTest.Add(entityTest);
         conn.SaveChanges();
         return(entityTest.IDTest);
     }
     catch (Exception e)
     { MessageBox.Show("Error: " + e.Message); }
     return(-1);
 }