예제 #1
0
        public void NoMultipleFormatting()
        {
            string inputFile  = @"..\..\T30\Input.cs";
            string outputFile = Path.GetTempFileName() + ".txt";

            ComposerFiles composer = new ComposerFiles();

            // do it first time
            composer.Compose(inputFile, outputFile, _dbReader);
            string s1 = File.ReadAllText(outputFile);

            // do it second time
            inputFile  = outputFile;
            outputFile = outputFile + "2.txt";
            composer.Compose(inputFile, outputFile, _dbReader);

            // do it third time
            inputFile  = outputFile;
            outputFile = outputFile + "3.txt";
            composer.Compose(inputFile, outputFile, _dbReader);

            // do it forth time
            inputFile  = outputFile;
            outputFile = outputFile + "4.txt";
            composer.Compose(inputFile, outputFile, _dbReader);

            string s2 = File.ReadAllText(outputFile);

            Assert.AreEqual(s1, s2, "Multiple runs do not cause multiple reformatting.");
        }
예제 #2
0
        public void Formatting2()
        {
            string inputFile    = @"..\..\T30\Input2.cs";
            string expectedFile = @"..\..\T30\Output2.cs";

            ComposerFiles composer = new ComposerFiles();

            string outputFile = Path.GetTempFileName() + ".txt";

            composer.Compose(inputFile, outputFile, _dbReader);

            string output   = File.ReadAllText(outputFile);
            string expected = File.ReadAllText(expectedFile);

            ConstantsPR.AssertSpaceEqual(expected, output, "Output should have expected syntax.");
            ConstantsPR.AssertFormatEqual(expected, output, "Output should have expected format.");
        }
예제 #3
0
        public void Reading_Access_OleDB()
        {
            string inputFile    = @"..\..\T33\Input.cs";
            string expectedFile = @"..\..\T33\Output.cs";

            _dbReader = new DbReader(null, null, null);
            ComposerFiles composer = new ComposerFiles();

            // do it first time
            string outputFile = Path.GetTempFileName() + ".txt";

            composer.Compose(inputFile, outputFile, _dbReader);

            string output   = File.ReadAllText(outputFile);
            string expected = File.ReadAllText(expectedFile);

            ConstantsPR.AssertSpaceEqual(output, expected, "Output should be as expected.");
        }
예제 #4
0
        public void SqlServer_NamePairWrong()
        {
            if (ConstantsPR.HasNoAdventureWorks)
            {
                /* AdventureWorks sample database has to be available. */
                throw new ApplicationException();
            }

            string inputFile = @"..\..\T31\Input2.cs";
            //string expectedFile = @"..\..\Fake31_Dell.txt";

            ComposerFiles composer = new ComposerFiles();

            // do it first time
            string outputFile = Path.GetTempFileName() + ".txt";

            composer.Compose(inputFile, outputFile, _dbReader);
        }
예제 #5
0
        public void SqlServer_ConnectionString()
        {
            if (ConstantsPR.HasNoAdventureWorks)
            {
                /* AdventureWorks sample database has to be available. */
                return;
            }

            string inputFile    = @"..\..\T31\Input3.cs";
            string expectedFile = @"..\..\T31\Output.cs";

            ComposerFiles composer = new ComposerFiles();

            // do it first time
            string outputFile = Path.GetTempFileName() + ".txt";

            composer.Compose(inputFile, outputFile, _dbReader);

            // compare with expected
            string output   = File.ReadAllText(outputFile);
            string expected = File.ReadAllText(expectedFile);

            output   = output.RemoveTextBetween("[EnumSqlCnn(", ")]");
            expected = expected.RemoveTextBetween("[EnumSqlCnn(", ")]");

            ConstantsPR.AssertSpaceEqual(expected, output, "Output file should match expected file.");

            // do it second time
            inputFile  = outputFile;
            outputFile = outputFile + "2.txt";
            composer.Compose(inputFile, outputFile, _dbReader);

            // compare with expected
            string output2 = File.ReadAllText(outputFile);

            output2 = output2.RemoveTextBetween("[EnumSqlCnn(", ")]");
            ConstantsPR.AssertSpaceEqual(expected, output2, "Second run of composer should not change the file.");
        }