Creaturestests.MutatorTests.CommandsEqualityComparer.IsEqual C# (CSharp) Method

IsEqual() public method

public IsEqual ( ICommand first, ICommand second ) : bool
first ICommand
second ICommand
return bool
        public bool IsEqual(ICommand first, ICommand second)
        {
            if (first.GetType() != second.GetType()) return false;
            _second = second;
            Execute(first);
            return _isEqual;
        }

Usage Example

Example #1
0
        public void ReverseParseShouldBeSame()
        {
            var comparer = new CommandsEqualityComparer();
            var somecode =
                new StringBuilder(@"
                    int a
                    int b
                    int c
                    a = 1
                    b = getState 2
                    c = b
                    int d
                    d = random c
                    d = a + c
                    d = b - a
                    if d then
                    if a then
                    stop
                    endif
                    print d
                    endif
                        ");
            var parsedCommands = new Parser().ProcessCommands(somecode.ToString()).ToArray();

            var parsedCommandInString = new CommandToStringParser().ParseCommands(parsedCommands);
            var reverse = new Parser().ProcessCommands(parsedCommandInString).ToArray();

            Assert.AreEqual(reverse.Length, parsedCommands.Length);
            for (int i = 0; i < parsedCommands.Length; i++)
            {
                Assert.IsTrue(comparer.IsEqual(parsedCommands[i], reverse[i]));
            }
        }
All Usage Examples Of Creaturestests.MutatorTests.CommandsEqualityComparer::IsEqual
CommandsEqualityComparer