public void Visiting_ConfigFiles() { string startPath = @"..\..\T02\T02-1\T02-2"; string endPath = @"..\..\T02"; /* read connection all way to the top */ _connection = _reader.GetConnection("NoExist", startPath, endPath); ConstantsPR.AssertConnectionString(null, null, _connection, "Expected equal."); /* read connection from the T02 */ _connection = _reader.GetConnection("cNn1", startPath, endPath); ConstantsPR.AssertConnectionString("System.Data.ProviderName", "Valid Connection String;", _connection, "Expected equal."); /* read connection from the T02-2 */ _connection = _reader.GetConnection("ZzZ", startPath, endPath); ConstantsPR.AssertConnectionString("providerZZ", "cnnZZcnn", _connection, "Expected equal."); }
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."); }
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."); }
public void Parsing_ConfigFile() { string inputFile = @"..\..\T02\App.config"; string inputText = File.ReadAllText(inputFile); /* read valid connection */ _connection = _reader.ExtractConnection("cnn1", inputText); ConstantsPR.AssertConnectionString("System.Data.ProviderName", "Valid Connection String;", _connection, "Expected equal."); /* read valid connection, case invariant */ _connection = _reader.ExtractConnection("cNN1", inputText); ConstantsPR.AssertConnectionString("System.Data.ProviderName", "Valid Connection String;", _connection, "Expected equal."); /* read not valid connection */ _connection = _reader.ExtractConnection("BAD_Cnn1", inputText); ConstantsPR.AssertConnectionString(null, "", _connection, "Expected equal."); //Helpers.ExtractConnectionString(inputFile, "cnn1"); }
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."); }