public void OrInvalidOperators()
 {
     ValueTester.TestBinaryOperation("Or", new[]
     {
         // Integer
         new BinaryOperationTestInput(12345, 12345, null),
         new BinaryOperationTestInput(12345, 12.345m, null),
         new BinaryOperationTestInput(12345, "string", null),
         new BinaryOperationTestInput(12345, true, null),
         // Decimal
         new BinaryOperationTestInput(12.345m, 12345, null),
         new BinaryOperationTestInput(12.345m, 12.345m, null),
         new BinaryOperationTestInput(12.345m, "string", null),
         new BinaryOperationTestInput(12.345m, true, null),
         // String
         new BinaryOperationTestInput("string", 12345, null),
         new BinaryOperationTestInput("string", 12.345m, null),
         new BinaryOperationTestInput("string", "string", null),
         new BinaryOperationTestInput("string", true, null),
         // Bool
         new BinaryOperationTestInput(true, 12345, null),
         new BinaryOperationTestInput(false, 12.345m, null),
         new BinaryOperationTestInput(true, "string", null)
     }
                                     );
 }
 public void EqualityValidOperators()
 {
     ValueTester.TestBinaryOperation("EqualTo", new[]
     {
         // Integers
         new BinaryOperationTestInput(1, 1, true),
         new BinaryOperationTestInput(1, 5, false),
         // Two decimals
         new BinaryOperationTestInput(12.34m, 12.34m, true),
         new BinaryOperationTestInput(12.34m, 12.35m, false),
         // Integer and decimal
         new BinaryOperationTestInput(10, 10.0m, true),
         new BinaryOperationTestInput(10, 20.0m, false),
         // Booleans
         new BinaryOperationTestInput(true, false, false),
         new BinaryOperationTestInput(true, true, true),
         new BinaryOperationTestInput(false, true, false),
         new BinaryOperationTestInput(false, false, true),
         // Strings
         new BinaryOperationTestInput("string", "string", true),
         new BinaryOperationTestInput("string", "String", false),
         new BinaryOperationTestInput("string", " string", false)
     }
                                     );
 }
 public void AndValidOperators()
 {
     ValueTester.TestBinaryOperation("And", new[]
     {
         new BinaryOperationTestInput(false, false, false),
         new BinaryOperationTestInput(false, true, false),
         new BinaryOperationTestInput(true, false, false),
         new BinaryOperationTestInput(true, true, true)
     }
                                     );
 }
Beispiel #4
0
 public void NegativeOperation()
 {
     ValueTester.TestBinaryOperation("Negative", new[]
     {
         // Valid (integers and decimals)
         new OperationTestInput(12345, -12345),
         new OperationTestInput(12.345m, -12.345m),
         // Invalid:
         new OperationTestInput(true, null),
         new OperationTestInput("string", null),
     }
                                     );
 }
 public void AdditionValidOperators()
 {
     ValueTester.TestBinaryOperation("Add", new[]
     {
         // Integers
         new BinaryOperationTestInput(10, 2, 12),
         // Decimals
         new BinaryOperationTestInput(10.5m, 5.0m, 15.5m),
         // Integer and decimal
         new BinaryOperationTestInput(10, 10.0m, 20.0m),
         new BinaryOperationTestInput(10.0m, 20, 30.0m)
     }
                                     );
 }
 public void DivisionValidOperators()
 {
     ValueTester.TestBinaryOperation("Divide", new[]
     {
         // Integers
         new BinaryOperationTestInput(10, 2, 5),
         // Decimals
         new BinaryOperationTestInput(10.5m, 5.0m, 2.1m),
         // Integer and decimal
         new BinaryOperationTestInput(10, 10.0m, 1.0m),
         new BinaryOperationTestInput(10.0m, 20, 0.5m)
     }
                                     );
 }
 public void MultiplicationValidOperators()
 {
     ValueTester.TestBinaryOperation("Multiply", new[]
     {
         // Integers
         new BinaryOperationTestInput(10, 2, 20),
         // Decimals
         new BinaryOperationTestInput(10.5m, 5.0m, 52.5m),
         // Integer and decimal
         new BinaryOperationTestInput(10, 10.0m, 100.0m),
         new BinaryOperationTestInput(10.0m, 20, 200m)
     }
                                     );
 }
 public void SubtractionValidOperators()
 {
     ValueTester.TestBinaryOperation("Subtract", new[]
     {
         // Integers
         new BinaryOperationTestInput(10, 2, 8),
         // Decimals
         new BinaryOperationTestInput(10.5m, 5.0m, 5.5m),
         // Integer and decimal
         new BinaryOperationTestInput(10, 10.0m, 0.0m),
         new BinaryOperationTestInput(10.0m, 20, -10.0m)
     }
                                     );
 }
Beispiel #9
0
 public void BangOperation()
 {
     ValueTester.TestBinaryOperation("Bang", new[]
     {
         // Valid (boolean)
         new OperationTestInput(false, true),
         new OperationTestInput(true, false),
         // Invalid:
         new OperationTestInput(12345, null),
         new OperationTestInput(12.345m, null),
         new OperationTestInput("string", null),
     }
                                     );
 }
Beispiel #10
0
        public static void TestBinaryOperation(OperationTestInput testInput, string op)
        {
            var lhsValue        = ValueCreator.CreateValue(testInput.LeftHandSideOperand);
            var operationMethod = lhsValue.GetType().GetMethod(op);

            try
            {
                var result = operationMethod.Invoke(lhsValue, new object[] { });
                ValueTester.Test((dynamic)result, testInput.ExpectedResult);
            }
            catch (TargetInvocationException ex)
            {
                throw ex.InnerException;
            }
        }
Beispiel #11
0
 public void GreaterThanValidOperators()
 {
     ValueTester.TestBinaryOperation("GreaterThan", new[]
     {
         // Integers
         new BinaryOperationTestInput(10, 2, true),
         new BinaryOperationTestInput(10, 11, false),
         new BinaryOperationTestInput(10, 10, false),
         // Decimals
         new BinaryOperationTestInput(10.5m, 5.0m, true),
         new BinaryOperationTestInput(12.34m, 23.45m, false),
         new BinaryOperationTestInput(12.34m, 12.34m, false),
         // Integer and decimal
         new BinaryOperationTestInput(10, 10.1m, false),
         new BinaryOperationTestInput(10.1m, 10, true),
         new BinaryOperationTestInput(10.0m, 10, false),
         new BinaryOperationTestInput(10, 10.0m, false)
     }
                                     );
 }
Beispiel #12
0
 public void LessthanOrEqualValidOperators()
 {
     ValueTester.TestBinaryOperation("LessThanOrEqual", new[]
     {
         // Integers
         new BinaryOperationTestInput(10, 2, false),
         new BinaryOperationTestInput(10, 11, true),
         new BinaryOperationTestInput(10, 10, true),
         // Decimals
         new BinaryOperationTestInput(10.5m, 5.0m, false),
         new BinaryOperationTestInput(12.34m, 23.45m, true),
         new BinaryOperationTestInput(12.34m, 12.34m, true),
         // Integer and decimal
         new BinaryOperationTestInput(10, 10.1m, true),
         new BinaryOperationTestInput(10.1m, 10, false),
         new BinaryOperationTestInput(10.0m, 10, true),
         new BinaryOperationTestInput(10, 10.0m, true)
     }
                                     );
 }
        public void InequalityInalidOperators()
        {
            ValueTester.TestBinaryOperation("EqualTo", new[]
            {
                // Integers,
                new BinaryOperationTestInput(1, true, null),
                new BinaryOperationTestInput(1, "string", null),
                // Decimals,
                new BinaryOperationTestInput(12.34m, true, null),
                new BinaryOperationTestInput(12.34m, "string", null),
                // Booleans,
                new BinaryOperationTestInput(true, 1, null),
                new BinaryOperationTestInput(true, 12.34m, null),
                new BinaryOperationTestInput(false, "string", null),
                // And Strings
                new BinaryOperationTestInput("string", 1, null),
                new BinaryOperationTestInput("string", 12.34m, null),
                new BinaryOperationTestInput("string", true, null)
            }

                                            );
        }
 public void MultiplicationInvalidOperators()
 {
     ValueTester.TestBinaryOperation("Multiply", new[]
     {
         // Integers
         new BinaryOperationTestInput(10, true, null),
         new BinaryOperationTestInput(10, "string", null),
         // Decimals
         new BinaryOperationTestInput(12.34m, true, null),
         new BinaryOperationTestInput(12.34m, "string", null),
         // Boolean
         new BinaryOperationTestInput(true, true, null),
         new BinaryOperationTestInput(true, "string", null),
         new BinaryOperationTestInput(true, 12345, null),
         new BinaryOperationTestInput(true, 12.345m, null),
         // String
         new BinaryOperationTestInput("string", true, null),
         new BinaryOperationTestInput("string", "string", null),
         new BinaryOperationTestInput("string", 12345, null),
         new BinaryOperationTestInput("string", 12.345m, null),
     }
                                     );
 }
Beispiel #15
0
 public void GreaterThanOrEqualInValidOperators()
 {
     ValueTester.TestBinaryOperation("GreaterThanOrEqual", new[]
     {
         // Integers
         new BinaryOperationTestInput(10, true, null),
         new BinaryOperationTestInput(10, "string", null),
         // Decimal
         new BinaryOperationTestInput(12.34m, true, null),
         new BinaryOperationTestInput(12.34, "string", null),
         // Boolean
         new BinaryOperationTestInput(true, 12345, null),
         new BinaryOperationTestInput(false, 12.345m, null),
         new BinaryOperationTestInput(true, true, null),
         new BinaryOperationTestInput(false, "string", null),
         // String
         new BinaryOperationTestInput("string", 12345, null),
         new BinaryOperationTestInput("string", 12.345m, null),
         new BinaryOperationTestInput("string", true, null),
         new BinaryOperationTestInput("string", "string", null),
     }
                                     );
 }