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)); }
public void Run_ShouldReturnPassedResultWhenTestPasses() { var runner = new PmlTestRunner(Mock.Of <ObjectProxy>(), Mock.Of <MethodInvoker>()); var result = runner.Run(Test); Assert.IsTrue(result.Passed); }
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)); }
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); }
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)); }
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)); }
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); }
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); }