private void LogicEvaluationFactory(string constant, FilterOperator op, bool expected)
        {
            // Arrange
            var expression = new LogicalExpression(new VariableExpression("OfficeNID"), new ConstantExpression(constant), op);
            // Act
            var evaluation = expression.EvaluateAsync(GetDefaultMessageContext);

            // Assert
            Assert.IsTrue((bool)evaluation.Result == expected);
        }
        public void Test_when_Expression_is_not_set()
        {
            //Arrange
            var expression = new LogicalExpression(null, null, 0);

            // Act
            var evaluation = expression.EvaluateAsync(GetDefaultMessageContext);

            // Assert
            Assert.IsTrue((bool)evaluation.Result);
        }
        public void Test_when_Context_does_not_have_a_key_Is_Not_LessThan_10()
        {
            //Arrange
            var expression = new LogicalExpression(new VariableExpression("OfficeNID"), new ConstantExpression("10"), FilterOperator.LessThan);

            //Act
            var evaluation = expression.EvaluateAsync(new Mock <IReadOnlyDictionary <string, object> >().Object);

            // Assert
            Assert.IsFalse((bool)evaluation.Result);
        }
        public void Test_that_officenid_equals_10_OR_equals_20_false()
        {
            // Arrange
            var left       = new LogicalExpression(new VariableExpression("OfficeNID"), new ConstantExpression("10"), FilterOperator.EqualTo);
            var right      = new LogicalExpression(new VariableExpression("OfficeNID"), new ConstantExpression("20"), FilterOperator.EqualTo);
            var expression = new LogicalExpression(left, right, FilterOperator.Or);

            // Act
            var evaluation = expression.EvaluateAsync(GetDefaultMessageContext);

            // Assert
            Assert.IsFalse((bool)evaluation.Result);
        }
        public void Test_when_Context_is_not_set()
        {
            //Arrange
            var expression = new LogicalExpression(new VariableExpression("OfficeNID"), new ConstantExpression("10"), FilterOperator.EqualTo);

            try
            {
                // Act
                var evaluation = expression.EvaluateAsync(null);
                var result     = evaluation.Result is bool;
            }
            catch (AggregateException ae)
            {
                Assert.IsTrue(ae.Flatten().InnerExceptions.Select(e => e.GetType() == typeof(NullReferenceException)).Any());
                return;
            }
            // Assert
            Assert.Fail("Expected Exception was not thrown");
        }
        public void Test_when_Right_part_of_Expression_is_not_set()
        {
            try
            {
                //Arrange
                var expression = new LogicalExpression(new ConstantExpression("10"), null, FilterOperator.EqualTo);

                // Act
                var evaluation = expression.EvaluateAsync(GetDefaultMessageContext);

                // Assert
                var result = evaluation.Result is bool;
            }
            catch (AggregateException ae)
            {
                Assert.IsTrue(ae.Flatten().InnerExceptions.Select(e => e.GetType() == typeof(NullReferenceException)).Any());
                return;
            }
            Assert.Fail("Expected NullReferenceException did not occur");
        }