/// <summary> /// Creates a new parameter object and add it to the corresponding test case object /// </summary> /// <param name="identifier">The test object identifier to be used for the parameter object</param> /// <param name="test">The test object to assign the new parameter object to</param> private void createParameters(int identifier, SQLTestCase test) { TestCaseParameters newParam = new TestCaseParameters(identifier); loadedParameters.Add(identifier, newParam); test.InternalParam = newParam; Console.WriteLine("InternalParameterHandler: Created new parameter with id: " + identifier); }
/// <summary> /// Evaluate results by comparing expected values to execution results stored in the object /// </summary> /// <returns>A TestResult value indicating the outcome of the test case run</returns> public override TestResult EvaluateResults() { if (ExpectedResults == null && ExpectedExecutionPlan == null && ExpectedException == null) { InternalParam = new TestCaseParameters(Identifier); if (ActuallyUsesBisonParser.Count > 0) { InternalParam.UsesBisonParser = ActuallyUsesBisonParser[0]; } // Else, the test result is an exception, and bison parser will not be used Result = TestResult.Generated; return(Result); } if (ExpectedException == null) { ExpectedException = ""; } if (ExpectedExecutionPlan == null) { ExpectedExecutionPlan = ""; } if (ExpectedResults == null) { ExpectedResults = ""; } if (!InternalParam.UsesBisonParser.HasValue && ActuallyUsesBisonParser.Count > 0) { InternalParam.UsesBisonParser = ActuallyUsesBisonParser[0]; } String expectedResultsNoWhitespace = Regex.Replace(ExpectedResults, "\\s", ""); String expectedExecutionPlanNoWhitespace = Regex.Replace(ExpectedExecutionPlan, "\\s", ""); String expectedExceptionNoWhitespace = Regex.Replace(ExpectedException, "\\s", ""); Boolean usesBisonParser = UsesBisonParser.HasValue && UsesBisonParser.Value || InternalParam.UsesBisonParser.HasValue && InternalParam.UsesBisonParser.Value && !UsesBisonParser.HasValue; if (ActualResults.Count == 0 && ActualException.Count == 0) { throw new ArgumentException("No results or exceptions from statement execution exists"); } for (int i = 0; i < ActualResults.Count; i++) { if (expectedResultsNoWhitespace != Regex.Replace(ActualResults[i], "\\s", "") || expectedExecutionPlanNoWhitespace != Regex.Replace(ActualExecutionPlan[i], "\\s", "") || (usesBisonParser != ActuallyUsesBisonParser[i])) { Result = TestResult.Failed; return(Result); } } for (int i = 0; i < ActualException.Count; i++) { if (expectedExceptionNoWhitespace != Regex.Replace(ActualException[i], "\\s", "")) { Result = TestResult.Failed; return(Result); } } Result = TestResult.Passed; return(Result); }