当前位置: 首页>>代码示例>>C#>>正文


C# TestDelegate.Invoke方法代码示例

本文整理汇总了C#中TestDelegate.Invoke方法的典型用法代码示例。如果您正苦于以下问题:C# TestDelegate.Invoke方法的具体用法?C# TestDelegate.Invoke怎么用?C# TestDelegate.Invoke使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在TestDelegate的用法示例。


在下文中一共展示了TestDelegate.Invoke方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: RunMockedExample

 /// <summary>
 /// Runs a code example in mocked mode.
 /// </summary>
 /// <param name="mockData">The mock data for mocking SOAP request and
 /// responses for API calls.</param>
 /// <param name="exampleDelegate">The delegate that initializes and runs the
 /// code example.</param>
 /// <param name="callback">The callback to be called before mocked responses
 /// are sent. You could use this callback to verify if the request was
 /// serialized correctly.</param>
 /// <remarks>This method is not thread safe, but since NUnit can run tests
 /// only in a single threaded mode, thread safety is not a requirement.
 /// </remarks>
 protected void RunMockedExample(ExamplesMockData mockData, TestDelegate exampleDelegate,
     WebRequestInterceptor.OnBeforeSendResponse callback) {
   TextWriter oldWriter = Console.Out;
   try {
     awapiInterceptor.Intercept = true;
     awapiInterceptor.LoadMessages(mockData.MockMessages,
          delegate(Uri requestUri, WebHeaderCollection headers, String body) {
            VerifyHttpHeaders(headers);
            VerifySoapHeaders(requestUri, body);
            callback(requestUri, headers, body);
          }
      );
     StringWriter newWriter = new StringWriter();
     Console.SetOut(newWriter);
     exampleDelegate.Invoke();
     Assert.AreEqual(newWriter.ToString().Trim(), mockData.ExpectedOutput.Trim());
   } finally {
     Console.SetOut(oldWriter);
     awapiInterceptor.Intercept = false;
   }
 }
开发者ID:psmacchia,项目名称:googleads-dotnet-lib,代码行数:34,代码来源:ExampleTestsBase.cs

示例2: MeasureMethod

        //Delegate method, object[] args=null)
        //duplicates NUnit declaration
        public static long MeasureMethod(TestDelegate method, int times_to_execute=100)
        {
            // Uses the second Core or Processor for the Test:
            Process.GetCurrentProcess().ProcessorAffinity = new IntPtr(2);
            // Prevents "Normal" processes from interrupting Threads:
            Process.GetCurrentProcess().PriorityClass = ProcessPriorityClass.High;
            // Prevents "Normal" Threads from interrupting this thread
            Thread.CurrentThread.Priority = ThreadPriority.Highest;

            Stopwatch stopwatch = new Stopwatch();
            WarmUp(stopwatch);
            stopwatch.Reset();
            stopwatch.Start();
            for (int i = 0; i < times_to_execute; i++)
            {
                method.Invoke();
            }
            stopwatch.Stop();
            long time = stopwatch.ElapsedTicks;
            return time;
        }
开发者ID:TheRusskiy,项目名称:NeuralNetwork,代码行数:23,代码来源:MyAssert.cs

示例3: RunExample

 /// <summary>
 /// Runs a code example.
 /// </summary>
 /// <param name="exampleDelegate">The delegate that initializes and runs the
 /// code example.</param>
 protected void RunExample(TestDelegate exampleDelegate) {
   Thread.Sleep(3000);
   StringWriter writer = new StringWriter();
   Assert.DoesNotThrow(delegate() {
     TextWriter oldWriter = Console.Out;
     Console.SetOut(writer);
     exampleDelegate.Invoke();
     Console.SetOut(oldWriter);
     Console.WriteLine(writer.ToString());
   });
 }
开发者ID:psmacchia,项目名称:googleads-dotnet-lib,代码行数:16,代码来源:ExampleTestsBase.cs

示例4: RunMockedExample

 /// <summary>
 /// Runs a code example in mocked mode.
 /// </summary>
 /// <param name="mockData">The mock data for mocking SOAP request and
 /// responses for API calls.</param>
 /// <param name="exampleDelegate">The delegate that initializes and runs the
 /// code example.</param>
 /// <param name="callback">The callback to be called before mocked responses
 /// are sent. You could use this callback to verify if the request was
 /// serialized correctly.</param>
 /// <remarks>This method is not thread safe, but since NUnit can run tests
 /// only in a single threaded mode, thread safety is not a requirement.
 /// </remarks>
 protected void RunMockedExample(ExamplesMockData mockData, TestDelegate exampleDelegate,
     WebRequestInterceptor.OnBeforeSendResponse callback)
 {
     TextWriter oldWriter = Console.Out;
       try {
     clientLoginInterceptor.Intercept = true;
     clientLoginInterceptor.RaiseException = false;
     awapiInterceptor.Intercept = true;
     AuthToken.Cache.Clear();
     awapiInterceptor.LoadMessages(mockData.MockMessages,
      delegate(Uri requestUri, WebHeaderCollection headers, String body) {
        VerifySoapHeaders(requestUri, body);
        callback(requestUri, headers, body);
      }
      );
     StringWriter newWriter = new StringWriter();
     Console.SetOut(newWriter);
     AdWordsAppConfig config = (user.Config as AdWordsAppConfig);
     exampleDelegate.Invoke();
     Assert.AreEqual(newWriter.ToString().Trim(), mockData.ExpectedOutput.Trim());
       } finally {
     Console.SetOut(oldWriter);
     clientLoginInterceptor.Intercept = false;
     awapiInterceptor.Intercept = false;
       }
 }
开发者ID:Zweitze,项目名称:googleads-adwords-dotnet-lib,代码行数:39,代码来源:ExampleTestsBase.cs

示例5: testDel

 /// <summary>
 /// Used to test implicit conversions from SMFunction to Delegate 
 /// (Usage: testDel(function() { print("this is a test!"); }));
 /// </summary>
 /// <param name="delegate"></param>
 public static void testDel(TestDelegate @delegate)
 {
     @delegate.Invoke();
 }
开发者ID:taliesins,项目名称:spidermonkeydotnet,代码行数:9,代码来源:Program.cs


注:本文中的TestDelegate.Invoke方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。