Exemple #1
0
        private bool Testing(TestEnum testEnum)
        {
            // Variable
            bool result = true;

            stringBuilder.Clear();

            ITestInterface test = testsDictionary[testEnum].Item1;

            stringBuilder = test.Test();

            // :( - Don't know why it is necessary
            if (consolePrint)
            {
                stringBuilder.AppendLine();
            }

            if (consolePrint)
            {
                string template   = testsDictionary[testEnum].Item2;
                string testString = stringBuilder.ToString();

                // Because Windows and Unix
                template   = template.Replace("\r\n", "\n");
                testString = testString.Replace("\r\n", "\n");

                if (template.Equals(testString))
                {
                    Console.WriteLine("OK   " + testEnum.ToString());
                    result = true;
                }
                else
                {
                    Console.WriteLine("NOK  " + testEnum.ToString());
                    result = false;
                }
            }
            else
            {
                Directory.CreateDirectory(Path.GetDirectoryName(test.GetPath()));

                testPath = test.GetPath();
                StreamWriter streamWriter = new StreamWriter(testPath);
                streamWriter.WriteLine(stringBuilder.ToString());
                streamWriter.Flush();
            }

            ReaderWriter.ReaderWriter.DeleteTestFile();

            return(result);
        }