Пример #1
0
 public void TestMethod_GetMessage_WrongFieldName()
 {
     Assert.Throws <FieldNotFoundException>(
         () =>
         ExpressionTest <Dummy>
         .CreateMethodExpression(nameof(Dummy.GetMessage), typeof(Dummy).GetFieldValue(WrongFieldName))
         .TestAndVerify());
 }
Пример #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();
        }
Пример #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));
        }
Пример #4
0
 public void TestMethod_MethodWithListAsParameter()
 {
     ExpressionTest <Dummy>
     .CreateMethodExpression(nameof(Dummy.MethodWithListAsParameter), "Test Output-0556 Test Output-1556").TestAndVerify();
 }
Пример #5
0
 public void ThrowSystemException()
 {
     ExpressionTest <Dummy> .CreateMethodExpression(nameof(Dummy.ThrowSystemException), typeof(System.SystemException).Name).TestAndVerify();
 }
Пример #6
0
 public void TestMethod_ReturnMessage_WithWrongExpectedOutput()
 {
     Assert.Throws <NoMatchedException>(
         () => ExpressionTest <Dummy> .CreateMethodExpression(nameof(Dummy.ReturnMessage), "Wrong Expected Output").TestAndVerify());
 }
Пример #7
0
 public void TestMethod_WrongMethod()
 {
     Assert.Throws <MethodNotFoundException>(
         () => ExpressionTest <Dummy> .CreateMethodExpression("WrongMethod", null).TestAndVerify());
 }
Пример #8
0
        public void TestMethod_GetType()
        {
            ExpressionTest <Dummy> .CreateMethodExpression(nameof(GetType), "expunit.framework.tests.TestClass.Dummy").TestAndVerify();

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