public void Should_Process_Repetition_Rule_Successfully() { IFiniteAutomataStructure str = new FiniteAutomataStructure(); int statesId = 1; IState initial = new State(statesId++, "1", true); IState state2 = new State(statesId, "2"); Stack <TompsonInitialFinalStatesHelperPair> stack = new Stack <TompsonInitialFinalStatesHelperPair>(); str.States.Add(initial); str.States.Add(state2); initial.Directions.Add(state2, new HashSet <DirectionValue>() { new DirectionValue { Letter = new Letter('a') } }); stack.Push(new TompsonInitialFinalStatesHelperPair() { CurrentFinal = state2, CurrentInitial = initial }); var result = TompsonProcessor.ProcessRule(TompsonRules.REPETITION, stack, str, ref statesId); Assert.IsTrue(initial.Directions.ContainsKey(result.CurrentFinal)); Assert.IsTrue(result.CurrentFinal.Directions.ContainsKey(initial)); Assert.IsTrue(state2.Directions.ContainsKey(result.CurrentFinal)); }
public void Should_Determine_Successfully_Whether_Character_Is_Tompson_Rule(char rule, bool expectedResult) { Assert.AreEqual(TompsonProcessor.IsTompsonRule(rule), expectedResult); }