示例#1
0
        public DefaultTestHostManagerTests()
        {
            this.mockProcessHelper = new Mock <IProcessHelper>();
            this.mockProcessHelper.Setup(ph => ph.GetCurrentProcessFileName()).Returns("vstest.console.exe");

            this.testHostManager = new DefaultTestHostManager(Architecture.X64, Framework.DefaultFramework, this.mockProcessHelper.Object, true);
            this.startInfo       = this.testHostManager.GetTestHostProcessStartInfo(Enumerable.Empty <string>(), null, default(TestRunnerConnectionInfo));
        }
示例#2
0
        public void ConstructorShouldSetX86ProcessForX86Architecture()
        {
            this.testHostManager = new DefaultTestHostManager(Architecture.X86, Framework.DefaultFramework, this.mockProcessHelper.Object, true);

            var info = this.testHostManager.GetTestHostProcessStartInfo(Enumerable.Empty <string>(), null, default(TestRunnerConnectionInfo));

            StringAssert.EndsWith(info.FileName, "testhost.x86.exe");
        }
        public void ConstructorShouldSetX86ProcessForX86Architecture()
        {
            this.testHostManager = new DefaultTestHostManager(this.mockProcessHelper.Object);
            this.testHostManager.Initialize(this.mockMessageLogger.Object, $"<?xml version=\"1.0\" encoding=\"utf-8\"?><RunSettings> <RunConfiguration> <TargetPlatform>{Architecture.X86}</TargetPlatform> <TargetFrameworkVersion>{Framework.DefaultFramework}</TargetFrameworkVersion> <DisableAppDomain>{false}</DisableAppDomain> </RunConfiguration> </RunSettings>");

            var info = this.testHostManager.GetTestHostProcessStartInfo(Enumerable.Empty <string>(), null, default(TestRunnerConnectionInfo));

            StringAssert.EndsWith(info.FileName, "testhost.x86.exe");
        }
        public DefaultTestHostManagerTests()
        {
            this.mockProcessHelper = new Mock <IProcessHelper>();
            this.mockProcessHelper.Setup(ph => ph.GetCurrentProcessFileName()).Returns("vstest.console.exe");

            this.mockMessageLogger = new Mock <IMessageLogger>();

            this.testHostManager = new DefaultTestHostManager(this.mockProcessHelper.Object);
            this.testHostManager.Initialize(this.mockMessageLogger.Object, $"<?xml version=\"1.0\" encoding=\"utf-8\"?><RunSettings> <RunConfiguration> <TargetPlatform>{Architecture.X64}</TargetPlatform> <TargetFrameworkVersion>{Framework.DefaultFramework}</TargetFrameworkVersion> <DisableAppDomain>{false}</DisableAppDomain> </RunConfiguration> </RunSettings>");
            this.startInfo = this.testHostManager.GetTestHostProcessStartInfo(Enumerable.Empty <string>(), null, default(TestRunnerConnectionInfo));
        }
示例#5
0
        public void LaunchTestHostShouldReturnTestHostProcessId()
        {
            var mockProcessHelper = new TestableProcessHelper();

            var testHostManager = new DefaultTestHostManager(Architecture.X64, Framework.DefaultFramework, mockProcessHelper, true);
            var startInfo       = testHostManager.GetTestHostProcessStartInfo(Enumerable.Empty <string>(), null, default(TestRunnerConnectionInfo));

            Task <int> processId = testHostManager.LaunchTestHostAsync(startInfo);

            try
            {
                processId.Wait();
            }
            catch (AggregateException) { }

            Assert.AreEqual(Process.GetCurrentProcess().Id, processId.Result);
        }
示例#6
0
        public void GetTestHostProcessStartInfoShouldIncludeTestSourcePathInArgumentsIfNonShared()
        {
            this.testHostManager = new DefaultTestHostManager(Architecture.X64, Framework.DefaultFramework, this.mockProcessHelper.Object, shared: false);
            var connectionInfo = new TestRunnerConnectionInfo {
                Port = 123, RunnerProcessId = 101
            };

            var source = "C:\temp\a.dll";
            var info   = this.testHostManager.GetTestHostProcessStartInfo(
                new List <string>()
            {
                source
            },
                null,
                connectionInfo);

            Assert.AreEqual(" --port 123 --parentprocessid 101 --testsourcepath " + "\"" + source + "\"", info.Arguments);
        }
        public void GetTestHostProcessStartInfoShouldIncludeTestSourcePathInArgumentsIfNonShared()
        {
            this.testHostManager = new DefaultTestHostManager(this.mockProcessHelper.Object);
            this.testHostManager.Initialize(this.mockMessageLogger.Object, $"<?xml version=\"1.0\" encoding=\"utf-8\"?><RunSettings> <RunConfiguration> <TargetPlatform>{Architecture.X86}</TargetPlatform> <TargetFrameworkVersion>{Framework.DefaultFramework}</TargetFrameworkVersion> <DisableAppDomain>{true}</DisableAppDomain> </RunConfiguration> </RunSettings>");
            var connectionInfo = new TestRunnerConnectionInfo {
                Port = 123, RunnerProcessId = 101
            };

            var source = "C:\temp\a.dll";
            var info   = this.testHostManager.GetTestHostProcessStartInfo(
                new List <string>()
            {
                source
            },
                null,
                connectionInfo);

            Assert.AreEqual(" --port 123 --parentprocessid 101 --testsourcepath " + "\"" + source + "\"", info.Arguments);
        }
        public void LaunchTestHostShouldReturnTestHostProcessId()
        {
            this.mockProcessHelper.Setup(
                ph =>
                ph.LaunchProcess(
                    It.IsAny <string>(),
                    It.IsAny <string>(),
                    It.IsAny <string>(),
                    It.IsAny <IDictionary <string, string> >(),
                    It.IsAny <Action <object, string> >(),
                    It.IsAny <Action <object> >())).Returns(Process.GetCurrentProcess());

            var testHostManager = new DefaultTestHostManager(Architecture.X64, Framework.DefaultFramework, this.mockProcessHelper.Object, true);
            var startInfo       = testHostManager.GetTestHostProcessStartInfo(Enumerable.Empty <string>(), null, default(TestRunnerConnectionInfo));

            Task <int> processId = testHostManager.LaunchTestHostAsync(startInfo);

            processId.Wait();

            Assert.AreEqual(Process.GetCurrentProcess().Id, processId.Result);
        }
        public void LaunchTestHostShouldReturnTestHostProcessId()
        {
            this.mockProcessHelper.Setup(
                ph =>
                ph.LaunchProcess(
                    It.IsAny <string>(),
                    It.IsAny <string>(),
                    It.IsAny <string>(),
                    It.IsAny <IDictionary <string, string> >(),
                    It.IsAny <Action <object, string> >(),
                    It.IsAny <Action <object> >())).Returns(Process.GetCurrentProcess());

            this.testHostManager = new DefaultTestHostManager(this.mockProcessHelper.Object);
            this.testHostManager.Initialize(this.mockMessageLogger.Object, $"<?xml version=\"1.0\" encoding=\"utf-8\"?><RunSettings> <RunConfiguration> <TargetPlatform>{Architecture.X64}</TargetPlatform> <TargetFrameworkVersion>{Framework.DefaultFramework}</TargetFrameworkVersion> <DisableAppDomain>{false}</DisableAppDomain> </RunConfiguration> </RunSettings>");
            var startInfo = this.testHostManager.GetTestHostProcessStartInfo(Enumerable.Empty <string>(), null, default(TestRunnerConnectionInfo));

            Task <int> processId = this.testHostManager.LaunchTestHostAsync(startInfo);

            processId.Wait();

            Assert.AreEqual(Process.GetCurrentProcess().Id, processId.Result);
        }