Пример #1
0
        public void Run_ShouldReturnPassedResultWhenTestPasses()
        {
            var runner = new PmlTestRunner(Mock.Of <ObjectProxy>(), Mock.Of <MethodInvoker>());
            var result = runner.Run(Test);

            Assert.IsTrue(result.Passed);
        }
Пример #2
0
        public static void TestRunnerControlInstantiation()
        {
            TestRunnerControl control = null;
            AsyncTestRunner   runner  = null;
            ObjectProxy       proxy   = null;

            try
            {
                proxy  = new StubObjectProxy();
                runner = new PmlTestRunner(proxy, new StubMethodInvoker());
                proxy  = null;
                var provider = new FileIndexTestCaseProvider();
                control = new TestRunnerControl(provider, runner, new RegistrySettingsProvider());
                runner  = null;
            }
            finally
            {
                if (proxy != null)
                {
                    proxy.Dispose();
                }
                if (runner != null)
                {
                    runner.Dispose();
                }
                if (control != null)
                {
                    control.Dispose();
                }
            }
        }
Пример #3
0
        public void Dispose_ShouldDisposeTheProxy()
        {
            var proxy  = new Mock <ObjectProxy>();
            var runner = new PmlTestRunner(proxy.Object, Mock.Of <MethodInvoker>());

            runner.Dispose();
            proxy.Verify(p => p.Dispose());
        }
Пример #4
0
        public void Run_ShouldQueryTheClock()
        {
            var clock  = new Mock <Clock>();
            var runner = new PmlTestRunner(Mock.Of <ObjectProxy>(), Mock.Of <MethodInvoker>(), clock.Object);

            runner.Run(Test);
            clock.VerifyGet(mock => mock.CurrentInstant, Times.Exactly(2));
        }
Пример #5
0
        public void Run_ShouldFailAfterBeingDisposed()
        {
            var runner = new PmlTestRunner(Mock.Of <ObjectProxy>(), Mock.Of <MethodInvoker>(), Mock.Of <Clock>());

            runner.Dispose();
            Assert.Throws <ObjectDisposedException>(() => runner.Run(TestCase));
            Assert.Throws <ObjectDisposedException>(() => runner.Run(Test));
        }
Пример #6
0
        public void Run_ShouldAssignTestResultToAllTestsInTheTestCase()
        {
            TestCase.Tests.Add("two");
            TestCase.Tests.Add("three");

            var runner = new PmlTestRunner(Mock.Of <ObjectProxy>(), Mock.Of <MethodInvoker>());

            runner.Run(TestCase);

            Assert.NotNull(TestCase.Tests["one"].Result);
            Assert.NotNull(TestCase.Tests["two"].Result);
            Assert.NotNull(TestCase.Tests["three"].Result);
        }
Пример #7
0
        public void Run_ShouldInvokeTheProxysRunMethod(bool hasSetUp, bool hasTearDown)
        {
            // Arrange
            var proxy  = new Mock <ObjectProxy>();
            var runner = new PmlTestRunner(proxy.Object, Mock.Of <MethodInvoker>());

            TestCase.HasSetUp    = hasSetUp;
            TestCase.HasTearDown = hasTearDown;
            // Act
            runner.Run(Test);
            // Assert
            proxy.Verify(p => p.Invoke("run", "Test", "one", hasSetUp, hasTearDown), Times.Exactly(1));
        }
Пример #8
0
        public void Run_ShouldDisposeTestReturnValue()
        {
            // Arrange
            var result = new Mock <IDisposable>();
            var proxy  = new Mock <ObjectProxy>();

            proxy.Setup(mock => mock.Invoke(It.IsAny <string>(), It.IsAny <object[]>())).Returns(result.Object);
            var runner = new PmlTestRunner(proxy.Object, Mock.Of <MethodInvoker>());

            // Act
            runner.Run(Test);
            // Assert
            result.Verify(mock => mock.Dispose(), Times.Exactly(1));
        }
Пример #9
0
        public void Run_ShouldReturnFailedResultWhenTestReturnsError()
        {
            // Arrange
            var proxy = new Mock <ObjectProxy>();

            proxy.Setup(mock => mock.Invoke(It.IsAny <string>(), It.IsAny <object[]>())).Returns(StackTrace);
            var runner = new PmlTestRunner(proxy.Object, Mock.Of <MethodInvoker>());
            // Act
            var result = runner.Run(Test);

            // Assert
            Assert.IsFalse(result.Passed);
            Assert.NotNull(result.Error);
            Assert.AreEqual(StackTrace[1.0], result.Error.Message);
        }
Пример #10
0
        public void Run_ShouldAssignAndReturnTestResultWithElapsedTime(int duration)
        {
            // Arrange
            int seconds = 0;
            var clock   = new Mock <Clock>();

            clock.SetupGet(mock => mock.CurrentInstant)
            .Returns(() => Instant.FromSeconds(seconds))
            .Callback(() => seconds = duration);
            var runner = new PmlTestRunner(Mock.Of <ObjectProxy>(), Mock.Of <MethodInvoker>(), clock.Object);
            // Act
            var result = runner.Run(Test);

            // Assert
            Assert.AreEqual(TimeSpan.FromSeconds(duration), result.Duration);
            Assert.AreSame(result, Test.Result);
        }
Пример #11
0
        public TestForm()
        {
            ObjectProxy       proxy   = null;
            AsyncTestRunner   runner  = null;
            TestRunnerControl control = null;

            try
            {
                Index         = new MutablePathIndex(Path.GetFullPath("..\\..\\..\\..\\pmllib-tests"));
                proxy         = new StubObjectProxy();
                runner        = new PmlTestRunner(proxy, new ControlMethodInvoker(this), new StubClock(), Index);
                proxy         = null;
                control       = new TestRunnerControl(Index, runner, new RegistrySettingsProvider());
                RunnerControl = control;
                runner        = null;
                control.Dock  = DockStyle.Fill;

                InitializeComponent();

                PathComboBox.Text          = Index.Path;
                FolderBrowser.SelectedPath = Index.Path;

                ControlPanel.Controls.Add(control);

                control = null;
            }
            finally
            {
                if (control != null)
                {
                    control.Dispose();
                }
                if (runner != null)
                {
                    runner.Dispose();
                }
                if (proxy != null)
                {
                    proxy.Dispose();
                }
            }
        }