本文整理汇总了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");
}
}
示例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");
}
}
}
示例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");
}
}
}
示例4: HostMethodChecks
public void HostMethodChecks()
{
using (Host test = new Host())
{
Assert.Throws<ArgumentNullException>(() => test.Initialize(null));
}
}
示例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();
}