/// <summary> /// Tries to Parse the <see cref="string"/> obtained by <paramref name="source"/> into /// the <paramref name="parsedGroup"/>. /// </summary> /// <param name="source"></param> /// <param name="parsedGroup"></param> /// <returns></returns> private bool TryVerifyParse(ParseStringCallback source, out GroupDescriptor parsedGroup) { parsedGroup = null; var s = (source() ?? Empty).Trim(); OutputHelper.WriteLine($"Given: {s}"); /* I've taken the time to isolate a more helpful scaffold than the brute force * creation up of assets, but this will work for verification purposes for now... */ using (var reader = new StringReader(s)) { var charStream = new AntlrInputStream(reader); var lexer = new CaseRegressionLexer(charStream); var tokenStream = new CommonTokenStream(lexer); var parser = new CaseRegressionParser(tokenStream); // ReSharper disable once RedundantEmptyObjectOrCollectionInitializer parser.AddErrorListener(new DefaultErrorListener { }); // ReSharper disable once RedundantEmptyObjectOrCollectionInitializer var listener = new CaseRegressionListener { }; new ParseTreeWalker().Walk(listener, parser.start()); parsedGroup = listener.RootDescriptor; } return(parsedGroup != null); }
/// <summary> /// In my production code there is so much more going on, but the rule that has broken /// is the Group Name rule. /// </summary> /// <param name="expectedGroup"></param> /// <param name="actualGroup"></param> protected override void VerifyGroupDescriptor(GroupDescriptor expectedGroup, GroupDescriptor actualGroup) { Assert.NotNull(actualGroup); Assert.NotSame(expectedGroup, actualGroup); Assert.Equal(expectedGroup.Name, actualGroup.Name); }
protected abstract void VerifyGroupDescriptor(GroupDescriptor expectedGroup, GroupDescriptor actualGroup);