WriteToFile() public method

public WriteToFile ( string fileName ) : void
fileName string
return void
Esempio n. 1
0
        static void DoSimpleSingleFileTest(
            string testName,
            string fileNamePrefix,
            string fileNameSuffix
            )
        {
            string       fileName = @"..\..\Input\" + fileNamePrefix + fileNameSuffix;
            ParameterSet pset     = new ParameterSet();

            pset.mUseTabsToIndent = true;

            TestFileWrapper regressionFile = new TestFileWrapper(fileName);

            EnvDTE.EditPoint tp1 = regressionFile.CreateEditPoint(null);
            tp1.StartOfDocument();
            EnvDTE.EditPoint tp2 = regressionFile.CreateEditPoint(null);
            tp2.EndOfDocument();
            CommentReflowerObj.WrapAllBlocksInSelection(pset, fileName, tp1, tp2);
            regressionFile.WriteToFile(@"..\..\Output\" + fileNamePrefix + ".out" + fileNameSuffix);
            int lineNum = fileCompare(@"..\..\Output\" + fileNamePrefix + ".out" + fileNameSuffix,
                                      @"..\..\Compare\" + fileNamePrefix + ".compare" + fileNameSuffix);

            if (lineNum != -1)
            {
                throw new System.ApplicationException(
                          testName + " regression file does not match compare at line " + lineNum);
            }

            //now apply again and ensure consitancy
            tp1.StartOfDocument();
            tp2.EndOfDocument();
            CommentReflowerObj.WrapAllBlocksInSelection(pset, fileName, tp1, tp2);
            regressionFile.WriteToFile(@"..\..\Output\" + fileNamePrefix + ".out2" + fileNameSuffix);
            lineNum = fileCompare(@"..\..\Output\" + fileNamePrefix + ".out2" + fileNameSuffix,
                                  @"..\..\Compare\" + fileNamePrefix + ".compare" + fileNameSuffix);
            if (lineNum != -1)
            {
                throw new System.ApplicationException(
                          testName + " 2nd run regression file does not match compare at line " + lineNum);
            }
            Console.WriteLine(testName + " tests PASSED.");
        }
Esempio n. 2
0
        static void DoBlockTests()
        {
            string fileName = @"..\..\Input\Regression.cpp";
            TestFileWrapper regressionFile = new TestFileWrapper(fileName);

            /////////////////////////////////////////
            // first detection tests
            /////////////////////////////////////////
            foreach (GetBlockFromPointRegression val in mBlockPointValues)
            {
                val.doTest(regressionFile, fileName);
            }

            //////////////////////////////////////////
            // now formatting tests one by one
            //////////////////////////////////////////
            ParameterSet pset = new ParameterSet();
            pset.mUseTabsToIndent = true;
            EnvDTE.EditPoint[] tp = new EnvDTE.EditPoint[mBlockPointValues.Length];
            for (int i=0; i < mBlockPointValues.Length; i++)
            {
                tp[i] = regressionFile.CreateEditPoint(null);
                tp[i].MoveToLineAndOffset(mBlockPointValues[i].retStartLine,1);
            }
            for (int i=0; i < tp.Length; i++)
            {
                try
                {
                    CommentReflowerObj.WrapBlockContainingPoint(pset,fileName,tp[i]);
                }
                catch (Exception)
                {
                    if (mBlockPointValues[i].retSuccess == true)
                    {
                        throw;
                    }
                }
            }
            regressionFile.WriteToFile(@"..\..\Output\Regression.out.cpp");
            int lineNum = fileCompare(@"..\..\Output\Regression.out.cpp", @"..\..\Compare\Regression.compare.cpp");
            if (lineNum != -1)
            {
                throw new System.ApplicationException(
                    "One by One Block regression file does not match compare at line " + lineNum);
            }

            ////////////////////////////////////////
            // now formatting tests all at once
            ////////////////////////////////////////
            TestFileWrapper regressionFile2 = new TestFileWrapper(fileName);
            EnvDTE.EditPoint tp1 = regressionFile2.CreateEditPoint(null);
            tp1.StartOfDocument();
            EnvDTE.EditPoint tp2 = regressionFile2.CreateEditPoint(null);
            tp2.EndOfDocument();
            CommentReflowerObj.WrapAllBlocksInSelection(pset,fileName,tp1,tp2);
            regressionFile2.WriteToFile(@"..\..\Output\Regression.out2.cpp");
            lineNum = fileCompare(@"..\..\Output\Regression.out2.cpp", @"..\..\Compare\Regression.compare.cpp");
            if (lineNum != -1)
            {
                throw new System.ApplicationException(
                    "Whole block regression file does not match compare at line " + lineNum);
            }

            //now apply again and ensure consitancy
            tp1.StartOfDocument();
            tp2.EndOfDocument();
            CommentReflowerObj.WrapAllBlocksInSelection(pset,fileName,tp1,tp2);
            regressionFile2.WriteToFile(@"..\..\Output\Regression.out3.cpp");
            lineNum = fileCompare(@"..\..\Output\Regression.out3.cpp", @"..\..\Compare\Regression.compare.cpp");
            if (lineNum != -1)
            {
                throw new System.ApplicationException(
                    "Whole block second run regression file does not match compare at line " + lineNum);
            }

            Console.WriteLine("Block detection and formatting tests PASSED.");
        }
Esempio n. 3
0
        static void DoBlockTests()
        {
            string          fileName       = @"..\..\Input\Regression.cpp";
            TestFileWrapper regressionFile = new TestFileWrapper(fileName);

            /////////////////////////////////////////
            // first detection tests
            /////////////////////////////////////////
            foreach (GetBlockFromPointRegression val in mBlockPointValues)
            {
                val.doTest(regressionFile, fileName);
            }

            //////////////////////////////////////////
            // now formatting tests one by one
            //////////////////////////////////////////
            ParameterSet pset = new ParameterSet();

            pset.mUseTabsToIndent = true;
            EnvDTE.EditPoint[] tp = new EnvDTE.EditPoint[mBlockPointValues.Length];
            for (int i = 0; i < mBlockPointValues.Length; i++)
            {
                tp[i] = regressionFile.CreateEditPoint(null);
                tp[i].MoveToLineAndOffset(mBlockPointValues[i].retStartLine, 1);
            }
            for (int i = 0; i < tp.Length; i++)
            {
                try
                {
                    CommentReflowerObj.WrapBlockContainingPoint(pset, fileName, tp[i]);
                }
                catch (Exception)
                {
                    if (mBlockPointValues[i].retSuccess == true)
                    {
                        throw;
                    }
                }
            }
            regressionFile.WriteToFile(@"..\..\Output\Regression.out.cpp");
            int lineNum = fileCompare(@"..\..\Output\Regression.out.cpp", @"..\..\Compare\Regression.compare.cpp");

            if (lineNum != -1)
            {
                throw new System.ApplicationException(
                          "One by One Block regression file does not match compare at line " + lineNum);
            }

            ////////////////////////////////////////
            // now formatting tests all at once
            ////////////////////////////////////////
            TestFileWrapper regressionFile2 = new TestFileWrapper(fileName);

            EnvDTE.EditPoint tp1 = regressionFile2.CreateEditPoint(null);
            tp1.StartOfDocument();
            EnvDTE.EditPoint tp2 = regressionFile2.CreateEditPoint(null);
            tp2.EndOfDocument();
            CommentReflowerObj.WrapAllBlocksInSelection(pset, fileName, tp1, tp2);
            regressionFile2.WriteToFile(@"..\..\Output\Regression.out2.cpp");
            lineNum = fileCompare(@"..\..\Output\Regression.out2.cpp", @"..\..\Compare\Regression.compare.cpp");
            if (lineNum != -1)
            {
                throw new System.ApplicationException(
                          "Whole block regression file does not match compare at line " + lineNum);
            }

            //now apply again and ensure consitancy
            tp1.StartOfDocument();
            tp2.EndOfDocument();
            CommentReflowerObj.WrapAllBlocksInSelection(pset, fileName, tp1, tp2);
            regressionFile2.WriteToFile(@"..\..\Output\Regression.out3.cpp");
            lineNum = fileCompare(@"..\..\Output\Regression.out3.cpp", @"..\..\Compare\Regression.compare.cpp");
            if (lineNum != -1)
            {
                throw new System.ApplicationException(
                          "Whole block second run regression file does not match compare at line " + lineNum);
            }


            Console.WriteLine("Block detection and formatting tests PASSED.");
        }
Esempio n. 4
0
        static void DoSimpleSingleFileTest(
            string testName,
            string fileNamePrefix,
            string fileNameSuffix
            )
        {
            string fileName = @"..\..\Input\"+fileNamePrefix+fileNameSuffix;
            ParameterSet pset = new ParameterSet();
            pset.mUseTabsToIndent = true;

            TestFileWrapper regressionFile = new TestFileWrapper(fileName);
            EnvDTE.EditPoint tp1 = regressionFile.CreateEditPoint(null);
            tp1.StartOfDocument();
            EnvDTE.EditPoint tp2 = regressionFile.CreateEditPoint(null);
            tp2.EndOfDocument();
            CommentReflowerObj.WrapAllBlocksInSelection(pset,fileName,tp1,tp2);
            regressionFile.WriteToFile(@"..\..\Output\"+fileNamePrefix+".out"+fileNameSuffix);
            int lineNum = fileCompare(@"..\..\Output\"+fileNamePrefix+".out"+fileNameSuffix,
                                      @"..\..\Compare\"+fileNamePrefix+".compare"+fileNameSuffix);
            if (lineNum != -1)
            {
                throw new System.ApplicationException(
                    testName + " regression file does not match compare at line " + lineNum);
            }

            //now apply again and ensure consitancy
            tp1.StartOfDocument();
            tp2.EndOfDocument();
            CommentReflowerObj.WrapAllBlocksInSelection(pset,fileName,tp1,tp2);
            regressionFile.WriteToFile(@"..\..\Output\"+fileNamePrefix+".out2"+fileNameSuffix);
            lineNum = fileCompare(@"..\..\Output\"+fileNamePrefix+".out2"+fileNameSuffix,
                                  @"..\..\Compare\"+fileNamePrefix+".compare"+fileNameSuffix);
            if (lineNum != -1)
            {
                throw new System.ApplicationException(
                    testName + " 2nd run regression file does not match compare at line " + lineNum);
            }
            Console.WriteLine(testName + " tests PASSED.");
        }