Beispiel #1
0
    public void TestMethodReturnPassedResult()
    {
        MethodInfo method = typeof(TestMethodCommandClass).GetMethod("TestMethod");
        TestCommand command = new FactCommand(Reflector.Wrap(method));

        MethodResult result = command.Execute(new TestMethodCommandClass());

        Assert.IsType<PassedResult>(result);
    }
Beispiel #2
0
    public void ExecuteRunsTest()
    {
        MethodInfo method = typeof(TestMethodCommandClass).GetMethod("TestMethod");
        TestCommand command = new FactCommand(Reflector.Wrap(method));
        TestMethodCommandClass.testCounter = 0;

        command.Execute(new TestMethodCommandClass());

        Assert.Equal(1, TestMethodCommandClass.testCounter);
    }
Beispiel #3
0
    public void TurnsParameterCountMismatchExceptionIntoInvalidOperationException()
    {
        Mock<IMethodInfo> method = new Mock<IMethodInfo>();
        method.SetupGet(m => m.Name)
              .Returns("StubbyName");
        method.SetupGet(m => m.TypeName)
              .Returns("StubbyType");
        method.Setup(m => m.Invoke(It.IsAny<object>(), It.IsAny<object[]>()))
              .Throws<ParamterCountMismatchException>();
        TestCommand command = new FactCommand(method.Object);

        Exception ex = Record.Exception(() => command.Execute(new TestMethodCommandClass()));

        Assert.IsType<InvalidOperationException>(ex);
        Assert.Equal("Fact method StubbyType.StubbyName cannot have parameters", ex.Message);
    }