public void GetNdfaFromRegularExpressionShouldReturnListOfTransitions() { // arrange string formula = "*(|(.(a,b),a))"; IRegularExpressionController regularExpressionController = new RegularExpressionController(); // act RegularExpression regularExpression = regularExpressionController.GetNdfaFromRegularExpression(ref formula); // assert Assert.AreEqual(11, regularExpression.transitions.Count); Assert.IsTrue(regularExpression.final.isFinalState); }
public void GetNdfaFromRegularExpressionShouldUseOrRule() { // arrange string formula = "|(a,b)"; IRegularExpressionController regularExpressionController = new RegularExpressionController(); // act RegularExpression regularExpression = regularExpressionController.GetNdfaFromRegularExpression(ref formula); // assert Assert.IsTrue(regularExpression.transitions.Count == 6); Assert.IsTrue(regularExpression.transitions.Exists(_ => _.connectingLetter.data == 'a')); Assert.IsTrue(regularExpression.transitions.Exists(_ => _.connectingLetter.data == 'b')); Assert.IsTrue(regularExpression.final.isFinalState); }
public void GetNdfaFromRegularExpressionShouldUseStarRule() { // arrange string formula = "*(a)"; IRegularExpressionController regularExpressionController = new RegularExpressionController(); // act RegularExpression regularExpression = regularExpressionController.GetNdfaFromRegularExpression(ref formula); // assert Assert.IsTrue(regularExpression.transitions.Count == 5); Assert.IsTrue(regularExpression.transitions.Exists(_ => _.connectingLetter.data == 'a')); Assert.IsTrue(regularExpression.final.isFinalState); Assert.AreEqual(4, regularExpression.transitions.FindAll(_ => _.connectingLetter.data == '_').Count); }
public void GetNdfaFromRegularExpressionShouldUseLetterRule() { // arrange string formula = "a"; IRegularExpressionController regularExpressionController = new RegularExpressionController(); // act RegularExpression regularExpression = regularExpressionController.GetNdfaFromRegularExpression(ref formula); // assert Assert.AreEqual(1, regularExpression.transitions.Count); Assert.IsTrue(regularExpression.initial.data == "S0"); Assert.IsTrue(regularExpression.final.data == "S1"); Assert.IsTrue(regularExpression.final.isFinalState); }