Пример #1
0
        public void ExpressionClonerClonesAdditionWithLeftAdditionChainAndRightMultiplicationWithVariableAtTheEnd()
        {
            var underTest = new Addition
            {
                Left =
                    new Addition
                {
                    Left = new Addition {
                        Left = new Constant {
                            Value = 1
                        }, Right = new Constant {
                            Value = 2
                        }
                    },
                    Right = new Constant {
                        Value = 3
                    }
                },
                Right = new Multiplication {
                    Left = new Constant {
                        Value = 4
                    }, Right = new Variable {
                        Name = "a"
                    }
                }
            };
            var result          = ExpressionCloner.Clone(underTest);
            var equalityChecker = new ExpressionEqualityChecker();

            equalityChecker.IsEqual(result, underTest).Should().BeTrue();
        }
Пример #2
0
        static void Check(string first, string second, bool expected)
        {
            var tokensFirst     = Tokenize(first);
            var inputTreeFirst  = CreateInMemoryModel(tokensFirst);
            var tokensSecond    = Tokenize(second);
            var inputTreeSecond = CreateInMemoryModel(tokensSecond);
            var result          = new ExpressionEqualityChecker();

            result.IsEqual(inputTreeFirst, inputTreeSecond).Should().Be(expected);
        }
Пример #3
0
        public void ExpressionClonerClonesSimpleAddition()
        {
            var underTest = new Addition {
                Left = new Constant {
                    Value = 1
                }, Right = new Constant {
                    Value = 2
                }
            };
            var result          = ExpressionCloner.Clone(underTest);
            var equalityChecker = new ExpressionEqualityChecker();

            equalityChecker.IsEqual(result, underTest).Should().BeTrue();
        }