Esempio n. 1
0
        public void SaveTests(string filename, List<List<string>> data /*all the testcases*/, Variable[] variables/*the datatypes from the xml file*/)
        {
            string dirPath = "..\\..\\..\\CSVFiles\\"; // directory path
            string fileFullPath;
            var strTest = new StringBuilder();
            string testVariable = "";
            int numTests = data.Count; // number of tests
            int numVar = variables.Length; // number of variables

            fileFullPath = GetFilePath(filename, dirPath); // full file path

            for (int i = 0; i < numVar; i++) // save names of variables to file
            {
                if (i < (numVar - 1))
                    strTest.Append(variables[i].name + ";");
                else
                    strTest.Append(variables[i].name + Environment.NewLine);
            }

            System.IO.File.AppendAllText(fileFullPath, strTest.ToString());

            for (int i = 0; i < numTests; i++)
            {
                strTest.Clear();
                for (int j = 0; j < numVar; j++)
                {
                    if (j < (numVar - 1))
                        testVariable = string.Format("{0};", data[i][j]);
                    else
                        testVariable = string.Format("{0}{1}", data[i][j], Environment.NewLine);
                    strTest.Append(testVariable);
                }
                System.IO.File.AppendAllText(fileFullPath, strTest.ToString()); // write testcase to file
            }
            System.Windows.Forms.MessageBox.Show("File saved");
        }
Esempio n. 2
0
 private string GetRandom(Variable variable)
 {
     int iIndex = getRandomIntervalIndex(variable.intervals.Length);
     Interval interval = variable.intervals[iIndex];
     switch (variable.datatype)
     {
         case "INT":
         case "BOOL":
             return getRandom_int(interval);
             //return getRandom_bool(interval);
         //case "LREAL":
         //    return getRandom_double(interval);
         case "REAL":
             return getRandom_float(interval);
         default:
             return "-";
     }
 }
Esempio n. 3
0
 public string[,] GetRandomTests(int numTests, Variable[] varList)
 {
     string[,] table = new string[numTests, varList.Length];
     for (int i = 0; i < numTests; i++) // loop for each test
     {
         for (int j = 0; j < varList.Length; j++)
         {
             table[i, j] = GetRandom(varList[j]); // generate a random value for all the inputs in the list
         }
     }
     return table;
 }