Exemple #1
0
 private static void ReadFromConfigureFile()
 {
     var serializer = new XmlSerializer (typeof (Config));
     using (FileStream fs = new FileStream ("Config.xml", FileMode.Open)) {
         instance = serializer.Deserialize (fs) as Config;
     }
 }
        /**
         * flushBuffer, Add (actionBuffer, expectedResultBuffer) to the _procedures list, then reset actionBuffer and expectedResultBuffer
         *
         * After a call to expectedResult() and before the next call to action(),
         * (after an action/expectedResult pair), we want to append the pair to the
         * _procedures list and possibly take a screenshot.
         */
        private void FlushBuffer()
        {
            Config config = new Config ();

            if (actionBuffer.Length != 0  && expectedResultBuffer.Length != 0) {
                if (Config.Instance.TakeScreenShots) {
                    string filename = string.Format ("screen{0:00}.png", procedures.Count + 1);
                    // take screenshot
                    Utils.TakeScreenshot (Path.Combine (Config.Instance.OutputDir, filename));
                    Console.WriteLine ("Screenshot: " + filename);
                    procedures.Add (new List<string> { actionBuffer.ToString().TrimEnd (), expectedResultBuffer.ToString().TrimEnd (), filename });
                } else {
                    procedures.Add (new List<string> { actionBuffer.ToString().TrimEnd (), expectedResultBuffer.ToString().TrimEnd ()});
                }

                actionBuffer.Remove (0, actionBuffer.Length);
                expectedResultBuffer.Remove (0, expectedResultBuffer.Length);
                Console.WriteLine ();
            }
        }