public void GetAllCall() { callTable.Clear(); CallList.Clear(); string sql = "select * from CallLogTable where CallType=0 or CallType=2"; callTable = AccessHelper.Adapter(sql, null); for (int i = callTable.Rows.Count - 1; i >= 0; i--) { try { var dm = new DataModel(); dm.SetData(callTable.Rows[i]); if (dm.CallerID == "") { continue; } CallList.Add(dm); } catch (Exception ex) { Log4Helper.Error(this.GetType(), "数据库存在异常数据", ex); continue; } } }
/// <summary> /// Replace call ids /// </summary> /// <param name="newid"></param> /// <param name="oldid"></param> private void OnCallReplaced(int oldid, int newid) { IStateMachine call = CallList[oldid]; _calls.Remove(oldid); call.Session = newid; CallList.Add(newid, call); }
public void Register() { CallList.Add(new InvocationInformation() { InvocationTime = DateTime.Now, StackTrace = Environment.StackTrace, InvocationTarget = "Register" }); }
public void BeforeEach() { CallList.Add(new InvocationInformation() { InvocationTime = DateTime.Now, StackTrace = Environment.StackTrace, InvocationTarget = "BeforeEach" }); }
public void ThenMethod(string input) { CallList.Add(new InvocationInformation() { InvocationTime = DateTime.Now, StackTrace = Environment.StackTrace, InvocationTarget = "ThenMethod" }); }
public void Inputs(string input1, int input2) { CallList.Add(new InvocationInformation() { InvocationTime = DateTime.Now, StackTrace = Environment.StackTrace, InvocationTarget = "Inputs", AdditionalData = $"input1={input1},input2={input2}" }); }
public string ReturnBar() { CallList.Add(new InvocationInformation() { InvocationTime = DateTime.Now, StackTrace = Environment.StackTrace, InvocationTarget = "ReturnBar" }); return("ReturnFoo"); }
public void InputsWithDefault(string input1, int input2, string defaultVal = "default") { CallList.Add(new InvocationInformation() { InvocationTime = DateTime.Now, StackTrace = Environment.StackTrace, InvocationTarget = "InputsWithDefault", AdditionalData = $"input1={input1},input2={input2},input3={defaultVal}" }); }
public async Task AsyncWait() { AsyncTask = Task.Run(() => Thread.Sleep(1500)); await AsyncTask; CallList.Add(new InvocationInformation() { InvocationTime = DateTime.Now, StackTrace = Environment.StackTrace, InvocationTarget = "AsyncWait" }); }
/// <summary> /// Handles the current call based on the configured behavior /// </summary> /// <param name="behavior">method behavior</param> /// <param name="resetEvent">related reset event</param> /// <param name="cancellationToken">cancellation token</param> /// <param name="callerName">caller name</param> private Task HandleBehavior(MockBehavior behavior, ManualResetEvent resetEvent, CancellationToken cancellationToken, string callerName) { // Add this call to the list CallList.Add(callerName); // Trigger event resetEvent.Set(); // Handle the behavior switch (behavior) { case MockBehavior.DoNothing: return(Task.CompletedTask); case MockBehavior.ThrowException: throw new NotSupportedException("based on behavior"); case MockBehavior.WaitForCancel: return(Task.Delay(TimeSpan.FromSeconds(10), cancellationToken)); default: throw new ArgumentOutOfRangeException(); } }