Пример #1
0
        public void TestMethod_GetException()
        {
            const string outputExpression = "_exception";

            // Solution 1
            ExpressionTest <Dummy> .CreateWithOutputExpression(nameof(Dummy.GetException), outputExpression).TestAndVerify();

            // Solution 2
            // Arrange
            var dummy = new Dummy();

            // Act
            var exception = dummy.GetException();

            // Assert
            exception.ShouldBe(dummy.Evaluate <Exception>(outputExpression));
        }
Пример #2
0
        public void TestMethod_SetMessage()
        {
            var testMessage = "test-message";
            var expression  = MessageField;

            // Solution 1
            ExpressionTest <Dummy> .CreateWithOutputExpression(nameof(Dummy.SetMessage), expression, "@p0 + @p0").TestAndVerify();

            // Solution 2
            // Arrange
            var dummy = new Dummy();

            // Act
            dummy.SetMessage(testMessage);

            // Assert
            dummy.Evaluate <string>(expression)
            .ShouldBe(testMessage + testMessage);
        }
Пример #3
0
 public void TestMethod_ToString()
 {
     ExpressionTest <Dummy> .CreateWithOutputExpression(nameof(Dummy.ToString), "'_message=' + _message + 'message2=' + _message2 + 'number1=' + _number1")
     .TestAndVerify();
 }
Пример #4
0
 public void TestMethod_NotEqual()
 {
     ExpressionTest <Dummy> .CreateWithOutputExpression(nameof(Dummy.NotEqual), "_number1 != _number2").TestAndVerify();
 }
Пример #5
0
 public void TestMethod_NegativeNumber()
 {
     ExpressionTest <Dummy> .CreateWithOutputExpression(nameof(Dummy.NegativeNumber), "_number1 * -1").TestAndVerify();
 }
Пример #6
0
 public void TestMethod_Less()
 {
     ExpressionTest <Dummy> .CreateWithOutputExpression(nameof(Dummy.Less), "_number1 < _number2").TestAndVerify();
 }
Пример #7
0
 public void TestMethod_Odd()
 {
     ExpressionTest <Dummy> .CreateWithOutputExpression(nameof(Dummy.Odd), "Mod % 2 == 1").TestAndVerify();
 }
Пример #8
0
 public void TestMethod_NotEven()
 {
     ExpressionTest <Dummy> .CreateWithOutputExpression(nameof(Dummy.NotEven), "!Even").TestAndVerify();
 }
Пример #9
0
 public void TestMethod_GetMessage_LengthExpression()
 {
     ExpressionTest <Dummy> .CreateWithOutputExpression($"{nameof(Dummy.GetMessage)}.Length", "_message.Length").TestAndVerify();
 }