Example #1
0
 public void TestMethod_GetMessage_WrongFieldName()
 {
     Assert.Throws <FieldNotFoundException>(
         () =>
         ExpressionTest <Dummy>
         .CreateMethodExpression(nameof(Dummy.GetMessage), typeof(Dummy).GetFieldValue(WrongFieldName))
         .TestAndVerify());
 }
Example #2
0
        public void TestMethod_CharAt1()
        {
            var classInfo = ClassInfo <Dummy> .Create(new Dictionary <string, dynamic>
            {
                { MessageField, "012345789" }
            });

            ExpressionTest <Dummy> .CreateMethodExpression(nameof(Dummy.CharAt1), classInfo, "_message[1] == '1'").TestAndVerify();
        }
Example #3
0
        public void TestMethod_GetMessage()
        {
            // Solution 1
            ExpressionTest <Dummy>
            .CreateMethodExpression(nameof(Dummy.GetMessage), typeof(Dummy).GetFieldValue(MessageField))
            .TestAndVerify();

            // Solution 2
            // Arrange
            var dummy = typeof(Dummy)
                        .CreateInstance() as Dummy;
            // Act
            var message = dummy?.GetMessage();

            // Assert
            message.ShouldBe(dummy.Evaluate <string>(MessageField));
        }
Example #4
0
 public void TestMethod_MethodWithListAsParameter()
 {
     ExpressionTest <Dummy>
     .CreateMethodExpression(nameof(Dummy.MethodWithListAsParameter), "Test Output-0556 Test Output-1556").TestAndVerify();
 }
Example #5
0
 public void ThrowSystemException()
 {
     ExpressionTest <Dummy> .CreateMethodExpression(nameof(Dummy.ThrowSystemException), typeof(System.SystemException).Name).TestAndVerify();
 }
Example #6
0
 public void TestMethod_ReturnMessage_WithWrongExpectedOutput()
 {
     Assert.Throws <NoMatchedException>(
         () => ExpressionTest <Dummy> .CreateMethodExpression(nameof(Dummy.ReturnMessage), "Wrong Expected Output").TestAndVerify());
 }
Example #7
0
 public void TestMethod_WrongMethod()
 {
     Assert.Throws <MethodNotFoundException>(
         () => ExpressionTest <Dummy> .CreateMethodExpression("WrongMethod", null).TestAndVerify());
 }
Example #8
0
        public void TestMethod_GetType()
        {
            ExpressionTest <Dummy> .CreateMethodExpression(nameof(GetType), "expunit.framework.tests.TestClass.Dummy").TestAndVerify();

            ExpressionTest <Dummy> .CreateMethodOutputExpression(nameof(GetType), "_type").TestAndVerify();
        }
Example #9
0
 public void TestMethod_Empty()
 {
     ExpressionTest <Dummy> .CreateMethodExpression(nameof(Dummy.Empty), string.Empty).TestAndVerify();
 }