Ejemplo n.º 1
0
 public void CreateServiceContext()
 {
     _services = new ServiceContext();
     _services.Add(new FakeRuntimeService());
     _testAgency = new TestAgency();
     _services.Add(_testAgency);
     _services.ServiceManager.StartServices();
 }
Ejemplo n.º 2
0
        public void TestAgency_RuntimeFrameworkServiceMissing()
        {
            var service = new TestAgency();

            _services.Add(service);
            service.StartService();
            Assert.That(service.Status, Is.EqualTo(ServiceStatus.Error));
        }
Ejemplo n.º 3
0
 public void CreateServiceContext()
 {
     _services = new ServiceContext();
     _services.Add(new FakeRuntimeService());
     // Use a different URI to avoid conflicting with the "real" TestAgency
     _testAgency = new TestAgency("TestAgencyTest", 0);
     _services.Add(_testAgency);
     _services.ServiceManager.StartServices();
 }
Ejemplo n.º 4
0
 public void CreateServiceContext()
 {
     var services = new ServiceContext();
     services.Add(new FakeRuntimeService());
     // Use a different URI to avoid conflicting with the "real" TestAgency
     _testAgency = new TestAgency("TestAgencyTest", 0);
     services.Add(_testAgency);
     services.ServiceManager.StartServices();
 }
Ejemplo n.º 5
0
        public void TestAgency_RuntimeFrameworkServiceError()
        {
            var fake = new FakeRuntimeService();

            fake.FailToStart = true;
            _services.Add(fake);
            var service = new TestAgency();

            _services.Add(service);
            ((IService)fake).StartService();
            service.StartService();
            Assert.That(service.Status, Is.EqualTo(ServiceStatus.Error));
        }
Ejemplo n.º 6
0
        public void CanLocateAgentExecutablePUT2([PexAssumeUnderTest] String path)
        {
            //PexAssume.IsTrue(path.Contains("t"));
            string outputPath = TestAgency.TestAgentExePath1(path);

            //path = path + ".NUnit.exe";
            //PexAssert.AreEqual( System.IO.File.Exists(path), "Cannot find " + path  );
            //Had to change it to run the test case
            //Console.WriteLine(outputPath);
            if (path.Length > 0)
            {
                PexAssert.IsTrue(System.IO.File.Exists(outputPath));
            }
            else
            {
                PexAssert.IsFalse(System.IO.File.Exists(outputPath));
            }
        }
Ejemplo n.º 7
0
 public void CreateAgency()
 {
     agency = new TestAgency("TempTestAgency", 0);
     agency.Start();
 }
Ejemplo n.º 8
0
 public ProcessRunner(IServiceLocator services, TestPackage package) : base(services, package)
 {
     _agency = Services.GetService <TestAgency>();
 }
Ejemplo n.º 9
0
 public void TestAgency_RuntimeFrameworkServiceMissing()
 {
     var service = new TestAgency();
     _services.Add(service);
     service.StartService();
     Assert.That(service.Status, Is.EqualTo(ServiceStatus.Error));
 }
Ejemplo n.º 10
0
 public void TestAgency_RuntimeFrameworkServiceError()
 {
     var fake = new FakeRuntimeService();
     fake.FailToStart = true;
     _services.Add(fake);
     var service = new TestAgency();
     _services.Add(service);
     ((IService)fake).StartService();
     service.StartService();
     Assert.That(service.Status, Is.EqualTo(ServiceStatus.Error));
 }
 public void CreateAgency()
 {
     agency = new TestAgency("TempTestAgency", 0);
     agency.Start();
 }
Ejemplo n.º 12
0
        public static int Main(string[] args)
        {
            AgentId   = new Guid(args[0]);
            AgencyUrl = args[1];

            InternalTrace.Initialize("nunit-agent_%p.log");
            log.Info("Agent process {0} starting", Process.GetCurrentProcess().Id);
            log.Info("Running under version {0}, {1}",
                     Environment.Version,
                     RuntimeFramework.CurrentFramework.DisplayName);

            // Add Standard Services to ServiceManager
            log.Info("Adding Services");
            ServiceManager.Services.AddService(new SettingsService(false));
            ServiceManager.Services.AddService(new ProjectService());
            ServiceManager.Services.AddService(new DomainManager());
            //ServiceManager.Services.AddService( new RecentFilesService() );
            //ServiceManager.Services.AddService( new TestLoader() );
            ServiceManager.Services.AddService(new AddinRegistry());
            ServiceManager.Services.AddService(new AddinManager());

            // Initialize Services
            log.Info("Initializing Services");
            ServiceManager.Services.InitializeServices();

            Channel = ServerUtilities.GetTcpChannel();

            log.Info("Connecting to TestAgency at {0}", AgencyUrl);
            try
            {
                Agency = Activator.GetObject(typeof(TestAgency), AgencyUrl) as TestAgency;
            }
            catch (Exception ex)
            {
                log.Error("Unable to connect", ex);
            }

            if (Channel != null)
            {
                log.Info("Starting RemoteTestAgent");
                RemoteTestAgent agent = new RemoteTestAgent(AgentId, Agency);

                try
                {
                    if (agent.Start())
                    {
                        log.Debug("Waiting for stopSignal");
                        agent.WaitForStop();
                        log.Debug("Stop signal received");
                    }
                    else
                    {
                        log.Error("Failed to start RemoteTestAgent");
                    }
                }
                catch (Exception ex)
                {
                    log.Error("Exception in RemoteTestAgent", ex);
                }

                log.Info("Unregistering Channel");
                try
                {
                    ChannelServices.UnregisterChannel(Channel);
                }
                catch (Exception ex)
                {
                    log.Error("ChannelServices.UnregisterChannel threw an exception", ex);
                }
            }

            log.Info("Stopping all services");
            ServiceManager.Services.StopAllServices();
            log.Info("Agent process {0} exiting", Process.GetCurrentProcess().Id);
            InternalTrace.Close();

            return(0);
        }
Ejemplo n.º 13
0
        public static int Main(string[] args)
        {
            AgentId   = new Guid(args[0]);
            AgencyUrl = args[1];

#if DEBUG
            if (args.Length > 2 && args[2] == "--pause")
            {
                System.Windows.Forms.MessageBox.Show("Attach debugger if desired, then press OK", "NUnit-Agent");
            }
#endif

            // Create SettingsService early so we know the trace level right at the start
            SettingsService settingsService = new SettingsService(false);
            InternalTrace.Initialize("nunit-agent_%p.log", (InternalTraceLevel)settingsService.GetSetting("Options.InternalTraceLevel", InternalTraceLevel.Default));

            log.Info("Agent process {0} starting", Process.GetCurrentProcess().Id);
            log.Info("Running under version {0}, {1}",
                     Environment.Version,
                     RuntimeFramework.CurrentFramework.DisplayName);

            // Add Standard Services to ServiceManager
            log.Info("Adding Services");
            ServiceManager.Services.AddService(settingsService);
            ServiceManager.Services.AddService(new ProjectService());
            ServiceManager.Services.AddService(new DomainManager());
            //ServiceManager.Services.AddService( new RecentFilesService() );
            //ServiceManager.Services.AddService( new TestLoader() );
            ServiceManager.Services.AddService(new AddinRegistry());
            ServiceManager.Services.AddService(new AddinManager());

            // Initialize Services
            log.Info("Initializing Services");
            ServiceManager.Services.InitializeServices();

            Channel = ServerUtilities.GetTcpChannel();

            log.Info("Connecting to TestAgency at {0}", AgencyUrl);
            try
            {
                Agency = Activator.GetObject(typeof(TestAgency), AgencyUrl) as TestAgency;
            }
            catch (Exception ex)
            {
                log.Error("Unable to connect", ex);
            }

            if (Channel != null)
            {
                log.Info("Starting RemoteTestAgent");
                RemoteTestAgent agent = new RemoteTestAgent(AgentId, Agency);

                try
                {
                    if (agent.Start())
                    {
                        log.Debug("Waiting for stopSignal");
                        agent.WaitForStop();
                        log.Debug("Stop signal received");
                    }
                    else
                    {
                        log.Error("Failed to start RemoteTestAgent");
                    }
                }
                catch (Exception ex)
                {
                    log.Error("Exception in RemoteTestAgent", ex);
                }

                log.Info("Unregistering Channel");
                try
                {
                    ChannelServices.UnregisterChannel(Channel);
                }
                catch (Exception ex)
                {
                    log.Error("ChannelServices.UnregisterChannel threw an exception", ex);
                }
            }

            log.Info("Stopping all services");
            ServiceManager.Services.StopAllServices();
            log.Info("Agent process {0} exiting", Process.GetCurrentProcess().Id);
            InternalTrace.Close();

            return(0);
        }
Ejemplo n.º 14
0
 public ProcessRunner(ServiceContext services, TestPackage package) : base(services, package)
 {
     _agency = Services.GetService <TestAgency>();
 }