public static void LinqTestCallback(IAsyncResult asyncResult) { PropertyInfo[] props = asyncResult.AsyncState.GetType().GetProperties(); object instance = props[0].GetValue(asyncResult.AsyncState, null); Message response = (Message)props[1].GetValue(asyncResult.AsyncState, null); Type entityType = (Type)props[2].GetValue(asyncResult.AsyncState, null); Message message = (Message)props[3].GetValue(asyncResult.AsyncState, null); string TestName = props[4].GetValue(asyncResult.AsyncState, null).ToString(); string instanceTypeName = instance.GetType().FullName; object results = null; bool exceptionOccured = false; string exceptionMessage = String.Empty; LinqTestExecutor currentTest = runningTests.Where(t => t.TestName == TestName).FirstOrDefault <LinqTestExecutor>(); //If Product Linq Query if (instanceTypeName.Contains("DataServiceQuery")) { if (entityType.Name.Contains("Orders")) { instance = instance as DataServiceQuery <northwindClient.Orders>; try { results = ((DataServiceQuery <northwindClient.Orders>)instance).EndExecute(asyncResult); currentTest.testResults = ((IEnumerable)results).GetEnumerator(); } catch (Exception except) { if (ErrorInExecution != null) { ErrorInExecution(message.Method, message, except); } } } else if (entityType.Name.Contains("Customers")) { instance = instance as DataServiceQuery <northwindClient.Customers>; try { results = ((DataServiceQuery <northwindClient.Customers>)instance).EndExecute(asyncResult); currentTest.testResults = ((IEnumerable)results).GetEnumerator(); } catch (Exception except) { if (ErrorInExecution != null) { ErrorInExecution(message.Method, message, except); } } } else if (entityType.Name.Contains("Order_Details")) { instance = instance as DataServiceQuery <northwindClient.Order_Details>; try { results = ((DataServiceQuery <northwindClient.Order_Details>)instance).EndExecute(asyncResult); currentTest.testResults = ((IEnumerable)results).GetEnumerator(); } catch (Exception except) { if (ErrorInExecution != null) { ErrorInExecution(message.Method, message, except); } } } else if (entityType.Name.Contains("Int32")) { instance = instance as DataServiceQuery <Int32>; try { results = ((DataServiceQuery <Int32>)instance).EndExecute(asyncResult); currentTest.testResults = ((IEnumerable)results).GetEnumerator(); } catch (Exception except) { if (ErrorInExecution != null) { ErrorInExecution(message.Method, message, except); } } } } else //If Baseline Execute call { instance = instance as DataServiceContext; if (entityType.Name.Contains("Orders")) { try { results = ((DataServiceContext)instance).EndExecute <northwindClient.Orders>(asyncResult); currentTest.baseLine = ((IEnumerable)results).GetEnumerator(); } catch (Exception except) { if (ErrorInExecution != null) { ErrorInExecution(message.Method, message, except); } } } else if (entityType.Name.Contains("Order_Details")) { try { results = ((DataServiceContext)instance).EndExecute <northwindClient.Order_Details>(asyncResult); currentTest.baseLine = ((IEnumerable)results).GetEnumerator(); } catch (Exception except) { if (ErrorInExecution != null) { ErrorInExecution(message.Method, message, except); } } } else { try { results = ((DataServiceContext)instance).EndExecute <northwindClient.Customers>(asyncResult); currentTest.baseLine = ((IEnumerable)results).GetEnumerator(); } catch (Exception except) { if (ErrorInExecution != null) { ErrorInExecution(message.Method, message, except); } } } } if (!exceptionOccured) { response.Exception = exceptionMessage; response.ReturnValue = "-1"; } if (currentTest.testResults != null && currentTest.baseLine != null) { if (EndExecution != null) { EndExecution(message.Method, message, response); } } }
public static bool RunTest(LinqTestExecutor linqTestExecutor) { return(RunTest(linqTestExecutor.baseLine, linqTestExecutor.testResults)); }
public static bool RunTest(LinqTestExecutor linqTestExecutor) { return RunTest(linqTestExecutor.baseLine, linqTestExecutor.testResults); }