public void CreateTestAgency()
 {
     _services = new ServiceContext();
     _services.Add(new TestAgency("TestAgencyTest", 0));
     _services.ServiceManager.StartServices();
     _testAgency = _services.GetService <TestAgency>();
     Assert.That(_testAgency.Status, Is.EqualTo(ServiceStatus.Started));
 }
 public void SetUp()
 {
     _agency = Substitute.For <TestAgency>();
     _agency.RemotingUrl.ReturnsForAnyArgs(REMOTING_URL);
     _package = new TestPackage("junk.dll");
     // Only required setting, some tests may change this
     _package.Settings[EnginePackageSettings.TargetRuntimeFramework] = "net-4.5";
 }
示例#3
0
 public void StartServices()
 {
     _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();
 }
示例#4
0
        public AgentProcess(TestAgency agency, TestPackage package, Guid agentId)
        {
            // Get target runtime
            string runtimeSetting = package.GetSetting(EnginePackageSettings.TargetRuntimeFramework, "");

            TargetRuntime = RuntimeFramework.Parse(runtimeSetting);

            // Access other package settings
            bool   runAsX86        = package.GetSetting(EnginePackageSettings.RunAsX86, false);
            bool   debugTests      = package.GetSetting(EnginePackageSettings.DebugTests, false);
            bool   debugAgent      = package.GetSetting(EnginePackageSettings.DebugAgent, false);
            string traceLevel      = package.GetSetting(EnginePackageSettings.InternalTraceLevel, "Off");
            bool   loadUserProfile = package.GetSetting(EnginePackageSettings.LoadUserProfile, false);
            string workDirectory   = package.GetSetting(EnginePackageSettings.WorkDirectory, string.Empty);

            string agencyUrl = TargetRuntime.Runtime == Runtime.NetCore
                ? agency.TcpEndPoint
                : agency.RemotingUrl;

            AgentArgs = new StringBuilder($"{agentId} {agencyUrl} --pid={Process.GetCurrentProcess().Id}");

            // Set options that need to be in effect before the package
            // is loaded by using the command line.
            if (traceLevel != "Off")
            {
                AgentArgs.Append(" --trace=").EscapeProcessArgument(traceLevel);
            }
            if (debugAgent)
            {
                AgentArgs.Append(" --debug-agent");
            }
            if (workDirectory != string.Empty)
            {
                AgentArgs.Append(" --work=").EscapeProcessArgument(workDirectory);
            }

            AgentExePath = GetTestAgentExePath(TargetRuntime, runAsX86);

            log.Debug("Using testcentric-agent at " + AgentExePath);

            StartInfo.UseShellExecute  = false;
            StartInfo.CreateNoWindow   = true;
            StartInfo.WorkingDirectory = Environment.CurrentDirectory;
            EnableRaisingEvents        = true;

            if (TargetRuntime.Runtime == Runtime.Mono)
            {
                StartInfo.FileName = TargetRuntime.MonoExePath;
                string monoOptions = "--runtime=v" + TargetRuntime.ClrVersion.ToString(3);
                if (debugTests || debugAgent)
                {
                    monoOptions += " --debug";
                }
                StartInfo.Arguments = string.Format("{0} \"{1}\" {2}", monoOptions, AgentExePath, AgentArgs);
            }
            else if (TargetRuntime.Runtime == Runtime.Net)
            {
                StartInfo.FileName        = AgentExePath;
                StartInfo.Arguments       = AgentArgs.ToString();
                StartInfo.LoadUserProfile = loadUserProfile;
            }
            else if (TargetRuntime.Runtime == Runtime.NetCore)
            {
                StartInfo.FileName  = "dotnet";
                StartInfo.Arguments = $"\"{AgentExePath}\" {AgentArgs}";
            }
            else
            {
                StartInfo.FileName  = AgentExePath;
                StartInfo.Arguments = AgentArgs.ToString();
            }
        }