public void CustomComparators() { Module A = new Module('A'); DerivedModule B9 = new DerivedModule('B', 9); DerivedModule B10 = new DerivedModule('B', 10); DerivedModule B11 = new DerivedModule('B', 11); Module C = new Module('C'); Production P = new Production(A, B10, C); P.matchCompare = GreaterThan; Assert.IsFalse(P.isMatch(A, B9, C)); Assert.IsTrue(P.isMatch(A, B11, C)); P = new Production(B10, A, C); P.leftCompare = GreaterThan; Assert.IsFalse(P.isMatch(B9, A, C)); Assert.IsTrue(P.isMatch(B11, A, C)); P = new Production(A, C, B10); P.rightCompare = GreaterThan; Assert.IsFalse(P.isMatch(A, C, B9)); Assert.IsTrue(P.isMatch(A, C, B11)); }
public void ModuleMutability() { DerivedModule A10 = new DerivedModule('A', 10); Module B = new Module('B'); // Rule 1: B -> A(10) Production P = new Production(B); P.successor.Add(A10); LSystem LS = new LSystem(); LS.addProduction(P); List<Module> axiom = new List<Module>() { B, B, B }; LS.setAxiom(axiom); // // Step one: A(10)A(10)A(10) LS.step(); List<Module> expected = new List<Module>() { new DerivedModule('A', 10), new DerivedModule('A', 10), new DerivedModule('A', 10) }; Assert.IsTrue(Utility.compareStates(expected, LS.getState())); // Change the original A10 to see if it affects the state A10.param = 15; Assert.IsTrue(Utility.compareStates(expected, LS.getState())); }