Esempio n. 1
0
        public void OnTestSessionTimeoutShouldGetCalledWhenExecutionCrossedTestSessionTimeout()
        {
            string settingsXml =
                @"<?xml version=""1.0"" encoding=""utf-8""?>
                <RunSettings>
                     <RunConfiguration>
                       <TestSessionTimeout>1000</TestSessionTimeout>
                     </RunConfiguration>
                </RunSettings>";

            var testRunCriteria = new TestRunCriteria(new List <string> {
                "foo"
            }, 1, true, settingsXml);
            var executionManager = new Mock <IProxyExecutionManager>();
            var testRunRequest   = new TestRunRequest(this.mockRequestData.Object, testRunCriteria, executionManager.Object);

            ManualResetEvent onTestSessionTimeoutCalled = new ManualResetEvent(true);

            onTestSessionTimeoutCalled.Reset();
            executionManager.Setup(o => o.Abort()).Callback(() => onTestSessionTimeoutCalled.Set());

            testRunRequest.ExecuteAsync();
            onTestSessionTimeoutCalled.WaitOne(20 * 1000);

            executionManager.Verify(o => o.Abort(), Times.Once);
        }
Esempio n. 2
0
        public void LaunchProcessWithDebuggerAttachedShouldNotCallCustomLauncherIfLauncherIsNotDebug()
        {
            var mockCustomLauncher = new Mock <ITestHostLauncher>();

            testRunCriteria = new TestRunCriteria(new List <string> {
                "foo"
            }, 1, false, null, TimeSpan.Zero, mockCustomLauncher.Object);
            executionManager = new Mock <IProxyExecutionManager>();
            testRunRequest   = new TestRunRequest(testRunCriteria, executionManager.Object);

            testRunRequest.ExecuteAsync();

            var testProcessStartInfo = new TestProcessStartInfo();

            testRunRequest.LaunchProcessWithDebuggerAttached(testProcessStartInfo);

            mockCustomLauncher.Verify(ml => ml.LaunchTestHost(It.IsAny <TestProcessStartInfo>()), Times.Never);
        }
Esempio n. 3
0
        public void LaunchProcessWithDebuggerAttachedShouldCallCustomLauncherIfLauncherIsDebugAndRunInProgress()
        {
            var mockCustomLauncher = new Mock <ITestHostLauncher>();

            testRunCriteria = new TestRunCriteria(new List <string> {
                "foo"
            }, 1, false, null, TimeSpan.Zero, mockCustomLauncher.Object);
            executionManager = new Mock <IProxyExecutionManager>();
            testRunRequest   = new TestRunRequest(testRunCriteria, executionManager.Object);

            testRunRequest.ExecuteAsync();

            var testProcessStartInfo = new TestProcessStartInfo();

            mockCustomLauncher.Setup(ml => ml.IsDebug).Returns(true);
            testRunRequest.LaunchProcessWithDebuggerAttached(testProcessStartInfo);

            mockCustomLauncher.Verify(ml => ml.LaunchTestHost(testProcessStartInfo), Times.Once);
        }
Esempio n. 4
0
        public void OnTestSessionTimeoutShouldNotGetCalledWhenTestSessionTimeoutIsZero()
        {
            string settingsXml =
                @"<?xml version=""1.0"" encoding=""utf-8""?>
                <RunSettings>
                     <RunConfiguration>
                       <TestSessionTimeout>0</TestSessionTimeout>
                     </RunConfiguration>
                </RunSettings>";

            var testRunCriteria = new TestRunCriteria(new List <string> {
                "foo"
            }, 1, true, settingsXml);
            var executionManager = new Mock <IProxyExecutionManager>();
            var testRunRequest   = new TestRunRequest(this.mockRequestData.Object, testRunCriteria, executionManager.Object);

            executionManager.Setup(o => o.StartTestRun(It.IsAny <TestRunCriteria>(), It.IsAny <ITestRunEventsHandler>())).Callback(() => System.Threading.Thread.Sleep(5 * 1000));

            testRunRequest.ExecuteAsync();

            executionManager.Verify(o => o.Abort(), Times.Never);
        }
Esempio n. 5
0
        public void ExecuteAsycIfTestRunRequestIsDisposedThrowsObjectDisposedException()
        {
            testRunRequest.Dispose();

            Assert.ThrowsException <ObjectDisposedException>(() => testRunRequest.ExecuteAsync());
        }