Пример #1
0
        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;
                }
            }
        }
Пример #2
0
        /// <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);
        }
Пример #3
0
 public void Register()
 {
     CallList.Add(new InvocationInformation()
     {
         InvocationTime   = DateTime.Now,
         StackTrace       = Environment.StackTrace,
         InvocationTarget = "Register"
     });
 }
Пример #4
0
 public void BeforeEach()
 {
     CallList.Add(new InvocationInformation()
     {
         InvocationTime   = DateTime.Now,
         StackTrace       = Environment.StackTrace,
         InvocationTarget = "BeforeEach"
     });
 }
Пример #5
0
 public void ThenMethod(string input)
 {
     CallList.Add(new InvocationInformation()
     {
         InvocationTime   = DateTime.Now,
         StackTrace       = Environment.StackTrace,
         InvocationTarget = "ThenMethod"
     });
 }
Пример #6
0
 public void Inputs(string input1, int input2)
 {
     CallList.Add(new InvocationInformation()
     {
         InvocationTime   = DateTime.Now,
         StackTrace       = Environment.StackTrace,
         InvocationTarget = "Inputs",
         AdditionalData   = $"input1={input1},input2={input2}"
     });
 }
Пример #7
0
 public string ReturnBar()
 {
     CallList.Add(new InvocationInformation()
     {
         InvocationTime   = DateTime.Now,
         StackTrace       = Environment.StackTrace,
         InvocationTarget = "ReturnBar"
     });
     return("ReturnFoo");
 }
Пример #8
0
 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}"
     });
 }
Пример #9
0
        public async Task AsyncWait()
        {
            AsyncTask = Task.Run(() => Thread.Sleep(1500));
            await AsyncTask;

            CallList.Add(new InvocationInformation()
            {
                InvocationTime   = DateTime.Now,
                StackTrace       = Environment.StackTrace,
                InvocationTarget = "AsyncWait"
            });
        }
Пример #10
0
            /// <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();
                }
            }