Example #1
0
        public void RemoveReferenceTypeNullChecks_IfTrueValueIsNOTConstantOfNull_ShouldReturnOriginalExpression()
        {
            var t = new OuterType
            {
                InnerType = new InnerType
                {
                    Value = 123
                }
            };

            Expression <Func <bool> > initialExpression = () => (t.InnerType == null ? 999 : t.InnerType.Value) == (int?)123;

            Expression actualExpression = ConditionalNullRemoverVisitor.RemoveReferenceTypeNullChecks(initialExpression);

            Assert.AreEqual(initialExpression.ToString(), actualExpression.ToString());
        }
Example #2
0
        public void RemoveReferenceTypeNullChecks_WhenConditionalExpTestIsANotEqualityCheck_And_RightChildOfTestExpIsConstantExpOfNull_And_IfFalseValueIsConstantOfNull_ShouldReturnIfFalseExpression()
        {
            var t = new OuterType
            {
                InnerType = new InnerType
                {
                    Value = 123
                }
            };

            Expression <Func <bool> > initialExpression  = () => (t.InnerType != null ? t.InnerType.Value: null) == (int?)123;
            Expression <Func <bool> > expectedExpression = () => t.InnerType.Value == (int?)123;

            Expression actualExpression = ConditionalNullRemoverVisitor.RemoveReferenceTypeNullChecks(initialExpression);

            Assert.AreEqual(expectedExpression.ToString(), actualExpression.ToString());
        }