public void SpTestRunner_RunProcQueryFail(string testPath, string testCase) { // ARRANGE string basePath = "TestCases\\SpRunner\\RunProcQuery\\Fail"; // Save the Connection String and Stored Procedure name in case they are set at the class level string savedConn = SpRunner.ConnectionString; string savedSPName = SpRunner.SpName; // Temporarily clear the connection string and spName from the class property so the input files can simulate missing values SpRunner.ConnectionString = ""; SpRunner.SpName = ""; // Prepare input and expected var input = JsonConvert.DeserializeObject <SpExecInput>(File.ReadAllText($"{basePath}\\{testPath}\\input{testCase}.json")); var expected = JsonConvert.DeserializeObject <SpExecResult>(File.ReadAllText($"{basePath}\\{testPath}\\expected{testCase}.json")); ////ACT SpExecResult actual = SpRunner.RunProcQuery(input); //Capture json output if needed to create test case "expected" records. string jsonString = JsonConvert.SerializeObject(actual, Formatting.Indented); // restore class level settings for subsequent tests in this same run. Do this before Assert in case an error is thrown during Assert. SpRunner.ConnectionString = savedConn; SpRunner.SpName = savedSPName; // ASSERT Assert.True(actual.ResultText == expected.ResultText); }
public void SpTestRunner_RunProcQueryGood(string procedure, string testCase) { //ARRANGE string basePath = "TestCases\\SpRunner\\RunProcQuery\\Good"; // Create the input model var input = JsonConvert.DeserializeObject <SpExecInput>(File.ReadAllText($"{basePath}\\{procedure}\\input{testCase}.json")); // Create the expected model var expected = JsonConvert.DeserializeObject <SpExecResult>(File.ReadAllText($"{basePath}\\{procedure}\\expected{testCase}.json")); ////ACT SpExecResult actual = SpRunner.RunProcQuery(input); ////ASSERT /// SpExecOutput.IsEquivalent method performs deep compare and generates detailed error messages to ResultText property and the Console Log /// NOTE!!! /// Comparison for SpExecResult.Duration passes when expected Duration is greater than 0 and actual.Duration IS LESS THAN OR EQUAL TO expected.Duration /// To disable this check set expected.Duration to 0 /// Assert.True(actual.IsEquivalent(expected)); }