예제 #1
0
파일: HostTest.cs 프로젝트: dupdob/SHON
 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
0
        public void ConfLoad()
        {
            string filename = "testfile.xml";
            PayloadDescription desc = new PayloadDescription();
            string assembly = Assembly.GetExecutingAssembly().Location;
            desc.AssemblyFullName = assembly;
            desc.Class = typeof(HostTest).FullName;
            desc=PayloadDescription.Load(filename);

            Assert.IsNotNull(desc, "Failed to deserialize config");
        }
예제 #3
0
 public void AutoConf()
 {
     PayloadDescription desc = new PayloadDescription();
     string assembly=Assembly.GetExecutingAssembly().CodeBase;
     if (Uri.IsWellFormedUriString(assembly,UriKind.Absolute))
     {
         assembly = new Uri(assembly).AbsolutePath;
         assembly = assembly.Replace(Path.AltDirectorySeparatorChar, Path.DirectorySeparatorChar);
     }
     desc.AssemblyFullName = Path.GetFileName(assembly);
     desc.Class = typeof(HostTest).FullName;
     Assert.AreEqual(assembly+".config", desc.ConfigurationFile, "Config file should match default name");
     Assert.AreEqual(Path.GetDirectoryName(assembly), desc.BinaryFolder, "binary folder should be assembly folder");
 }
예제 #4
0
        public void ConfSerialization()
        {
            string filename = "testconfig.xml";
            try
            {
                PayloadDescription desc = new PayloadDescription();
                string assembly = Assembly.GetExecutingAssembly().Location;
                desc.AssemblyFullName = assembly;
                desc.Class = typeof(HostTest).FullName;
                File.Delete(filename);
                PayloadDescription.Save(desc, filename);

                Assert.IsTrue(File.Exists(filename));
            }
            finally
            {
                File.Delete(filename);
            }
        }
예제 #5
0
파일: HostTest.cs 프로젝트: dupdob/SHON
 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");
         }
     }
 }
예제 #6
0
파일: HostTest.cs 프로젝트: dupdob/SHON
        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");
                }
            }
        }
예제 #7
0
파일: HostTest.cs 프로젝트: dupdob/SHON
 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();
 }