public void ValidateParseError() { string path = "agent.product.(1)name[3]\"Safari\""; var matcher = new TestMatcher(new Dictionary <string, IDictionary <string, string> >(), new Dictionary <string, ISet <string> >()); MatcherExtractAction action = new MatcherExtractAction("Dummy", 42, path, matcher); Action a = new Action(() => action.Initialize()); a.Should().Throw <InvalidParserConfigurationException>(); }
/// <summary> /// /// </summary> /// <param name="path"></param> /// <param name="expectedHashEntries"></param> /// <param name="expectedWalkList"></param> private void CheckPath(string path, string[] expectedHashEntries, string[] expectedWalkList) { var lookups = new Dictionary <string, IDictionary <string, string> > { ["TridentVersions"] = new Dictionary <string, string>() }; var matcher = new TestMatcher(lookups, new Dictionary <string, ISet <string> >()); var action = new MatcherExtractAction("Dummy", 42, path, matcher); action.Initialize(); var sb = new StringBuilder("\n---------------------------\nActual list (") .Append(matcher.receivedValues.Count) .Append(" entries):\n"); foreach (var actual in matcher.receivedValues) { sb.Append(actual).Append('\n'); } sb.Append("---------------------------\n"); // Validate the expected hash entries (i.e. the first part of the path) foreach (var expect in expectedHashEntries) { matcher.receivedValues.Contains(expect).Should().BeTrue("\nExpected:\n" + expect + sb.ToString()); } expectedHashEntries.Length.Should().Be(matcher.receivedValues.Count, "Found that number of entries"); // Validate the expected walk list entries (i.e. the dynamic part of the path) var evaluator = action.EvaluatorForUnitTesting; var walkList = evaluator.WalkListForUnitTesting; var step = walkList.FirstStep; foreach (var walkStep in expectedWalkList) { step.Should().NotBeNull("Step: " + walkStep); walkStep.Should().Be(step.ToString(), "step(" + step.ToString() + " should be " + walkStep + ")"); step = step.NextStep; } step.Should().BeNull(); }