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


C# Host.Initialize方法代码示例

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


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

示例1: BasicHostTest

 public void BasicHostTest()
 {
     using (Host test = new Host())
     {
         PayloadDescription desc = new PayloadDescription();
         desc.AssemblyFullName = typeof(HostTest).Assembly.Location;
         desc.Class = typeof(HostTest).FullName;
         Assert.IsTrue(test.Initialize(desc), "Initialize must succeed");
     }
 }
开发者ID:dupdob,项目名称:SHON,代码行数:10,代码来源:HostTest.cs

示例2: CrashOnRunTest

 public void CrashOnRunTest()
 {
     using (Host test = new Host())
     {
         PayloadDescription desc = new PayloadDescription();
         string assembly = typeof(TestService.TestService).Assembly.CodeBase;
         desc.AssemblyFullName = assembly;
         desc.Class = typeof(TestService.TestService).FullName;
         desc.Parameter = "AsyncRaiseOnRun";
         Assert.IsTrue(test.Initialize(desc), "Initialize must succeed");
         using (TestTracer tracer = TestTracer.FromDomain(test.Domain))
         {
             test.Start();
             Thread.Sleep(500);
             Assert.AreEqual("StartWithParam", tracer.Pop(), "TestMethod.Start should have been called");
             Assert.AreEqual("Default", tracer.Pop(), "Bad test parameter");
             Assert.AreEqual("RaisedException", tracer.Pop(), "Should have raised an exception");
             test.Stop();
             Assert.AreEqual("Stop", tracer.Pop(), "Should have raised an exception");
             Assert.IsTrue(tracer.IsEmpty, "No other events should have occured");
         }
     }
 }
开发者ID:dupdob,项目名称:SHON,代码行数:23,代码来源:HostTest.cs

示例3: AlternateTest

        public void AlternateTest()
        {
            using (Host test = new Host())
            {
                PayloadDescription desc = new PayloadDescription();
                string assembly = typeof(TestService.TestService).Assembly.CodeBase;
                desc.AssemblyFullName = assembly;
                desc.Class = typeof(TestService.TestService).FullName;
                desc.ConfigurationFile = "AltShon.TestService.config";
                Assert.IsTrue(test.Initialize(desc), "Initialize must succeed");
                using (TestTracer tracer = TestTracer.FromDomain(test.Domain))
                {
                    test.Start();

                    Assert.AreEqual("Start", tracer.Pop(), "TestMethod.Start should have been called");

                    Assert.AreEqual("Alt", tracer.Pop(), "Bad test parameter");
                    test.Stop();

                    Assert.AreEqual("Stop", tracer.Pop(), "TestMethod.Stop should have been called");
                    Assert.IsTrue(tracer.IsEmpty, "No other events should have occured");
                }
            }
        }
开发者ID:dupdob,项目名称:SHON,代码行数:24,代码来源:HostTest.cs

示例4: HostMethodChecks

 public void HostMethodChecks()
 {
     using (Host test = new Host())
     {
         Assert.Throws<ArgumentNullException>(() => test.Initialize(null));
     }
 }
开发者ID:dupdob,项目名称:SHON,代码行数:7,代码来源:HostTest.cs

示例5: FinalizerTest

 public void FinalizerTest()
 {
     object synchro = new object();
     bool done = false;
     Host test = new Host();
     PayloadDescription desc = new PayloadDescription();
     desc.AssemblyFullName = typeof(TestService.TestService).Assembly.Location;
     desc.Class = typeof(TestService.TestService).FullName;
     desc.ConfigurationFile = "AltShon.TestService.config";
     Assert.IsTrue(test.Initialize(desc), "Initialize must succeed");
     test = null;
     Thread thread = new Thread (() =>
     {
         GC.Collect();
         GC.WaitForPendingFinalizers();
         lock (synchro)
         {
             done = true;
             Monitor.Pulse(synchro);
         }
     });
     thread.Start();
     lock (synchro)
     {
         if (!done)
         {
             Monitor.Wait(synchro, 1000);
         }
     }
     thread.Interrupt();
 }
开发者ID:dupdob,项目名称:SHON,代码行数:31,代码来源:HostTest.cs


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