[InlineData("Run\\ProcedureUnknown", "2")] // Stored Procedure Name not recognized public void SpTestRunner_RunProcNonQueryFail(string testPath, string testCase) { // ARRANGE string basePath = "TestCases\\SpRunner\\RunProcNonQuery\\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 <SpExecInputNonQuery>(File.ReadAllText($"{basePath}\\{testPath}\\input{testCase}.json")); var expected = JsonConvert.DeserializeObject <SpExecResultNonQuery>(File.ReadAllText($"{basePath}\\{testPath}\\expected{testCase}.json")); ////ACT SpExecResultNonQuery actual = SpRunner.RunProcNonQuery(input); // 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_RunProcNonQueryCommit() { bool chkVal; string basePath = "TestCases\\SpRunner\\RunProcNonQuery\\Good\\Commit"; SpExecInputNonQuery input; SpExecResultNonQuery expected; SpExecResultNonQuery actual; //CREATE NEW TABLE // Execute and Commit Create input = JsonConvert.DeserializeObject <SpExecInputNonQuery>(File.ReadAllText($"{basePath}\\spCreate\\input.json")); expected = JsonConvert.DeserializeObject <SpExecResultNonQuery>(File.ReadAllText($"{basePath}\\spCreate\\expected.json")); actual = SpRunner.RunProcNonQuery(input); Assert.True(actual.IsEquivalent(expected)); // INSERT INTO NEW TABLE input = JsonConvert.DeserializeObject <SpExecInputNonQuery>(File.ReadAllText($"{basePath}\\spInsert\\input.json")); expected = JsonConvert.DeserializeObject <SpExecResultNonQuery>(File.ReadAllText($"{basePath}\\spInsert\\expected.json")); actual = SpRunner.RunProcNonQuery(input); Assert.True(actual.IsEquivalent(expected)); // Execute DELETE input = JsonConvert.DeserializeObject <SpExecInputNonQuery>(File.ReadAllText($"{basePath}\\spDelete\\input.json")); expected = JsonConvert.DeserializeObject <SpExecResultNonQuery>(File.ReadAllText($"{basePath}\\spDelete\\expected.json")); actual = SpRunner.RunProcNonQuery(input); Assert.True(actual.IsEquivalent(expected)); // EXECUTE DROP input = JsonConvert.DeserializeObject <SpExecInputNonQuery>(File.ReadAllText($"{basePath}\\spDrop\\input.json")); expected = JsonConvert.DeserializeObject <SpExecResultNonQuery>(File.ReadAllText($"{basePath}\\spDrop\\expected.json")); actual = SpRunner.RunProcNonQuery(input); Assert.True(actual.IsEquivalent(expected)); }
public void SpTestRunner_RunProcNonQueryGood(string testPath, string testCase) { //ARRANGE string basePath = "TestCases\\SpRunner\\RunProcNonQuery\\Good"; // Create the input model var input = JsonConvert.DeserializeObject <SpExecInputNonQuery>(File.ReadAllText($"{basePath}\\{testPath}\\input{testCase}.json")); // Create the expected model var expected = JsonConvert.DeserializeObject <SpExecResultNonQuery>(File.ReadAllText($"{basePath}\\{testPath}\\expected{testCase}.json")); ////ACT SpExecResultNonQuery actual = SpRunner.RunProcNonQuery(input); //TODO Add json trap ////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)); }