Ejemplo n.º 1
0
        public async Task <List <TestResultClass> > RunTest() //
        {
            List <TestResultClass> testResult = new List <TestResultClass>();

            for (int i = 0; i < funcNames.Count; i++)
            {
                PrepareDirectoryClass.Prepare(); // Подготавливаем директорию для работы
                CreatePatternFileClass.CreateFile(testfile.PathToFile, funcNames[i]);
                GccRunnetClass GccRunnet = new GccRunnetClass();
                GccRunnet.SendCommand("CD /d " + Directory.GetCurrentDirectory());
                GccRunnet.SendCommand(Directory.GetCurrentDirectory() + "\\mingw\\bin\\gcc.exe" + " testrunner.c");
                GccRunnet.SendCommand("a");
                GccRunnet.SendCommand("Exit");
                testResult.Add(await CheckResultClass.CheckResult(funcNames[i]));
                ClearAssertResultFileClass.Clear(funcNames[i]);
            }
            return(testResult);
        }
Ejemplo n.º 2
0
        public void Test_PrepareDirectory()
        {
            using (FileStream fs = new FileStream(Directory.GetCurrentDirectory() + "\\testrunner.c", FileMode.Create, FileAccess.Write))
            {
                fs.Write(new byte[] { 0, 1, 2 }, 0, 3);
                fs.Close();
            }
            using (FileStream fs = new FileStream(Directory.GetCurrentDirectory() + "\\a.exe", FileMode.Create, FileAccess.Write))
            {
                fs.Write(new byte[] { 0, 1, 2 }, 0, 3);
                fs.Close();
            }
            bool Before_1_File = File.Exists(Directory.GetCurrentDirectory() + "\\testrunner.c");
            bool Before_2_File = File.Exists(Directory.GetCurrentDirectory() + "\\a.exe");

            Assert.True(Before_1_File);
            Assert.True(Before_2_File);
            PrepareDirectoryClass.Prepare();
            bool After_1_File = File.Exists(Directory.GetCurrentDirectory() + "\\testrunner.c");
            bool After_2_File = File.Exists(Directory.GetCurrentDirectory() + "\\a.exe");

            Assert.False(After_1_File);
            Assert.False(After_2_File);
        }