private static void CompareCaptures(Match expected, OMatch <char> actual) { var groups = expected.Groups.Cast <Group>().Where(x => x.Success).ToArray(); Assert.AreEqual(groups.Length, actual.Captures.Count); foreach (var group in actual.Captures) { var captured = expected.Groups[group.Key].Captures.Cast <Capture>().ToArray(); foreach (var capt in group.Value) { if (!captured.Any(x => x.Index == capt.Index && x.Length == capt.Length)) { Assert.Fail("Captures not equal." + capt); } } } }
public Person(OMatch<Word> match) { Words = match.Values.ToArray(); Name = match.Captures["name"].First().Values.First().Value; //Now just normalize this name and you are good. }
private static string ActualString(OMatch <char> actual) { return(string.Format("Value: {0},\tindex: {1}, length: {2}", new string(actual.Values.ToArray()), actual.Index, actual.Length)); }
private static void Compare(Match expected, OMatch <char> actual) { Assert.AreEqual(expected.Index, actual.Index); Assert.AreEqual(expected.Length, actual.Length); CompareCaptures(expected, actual); }
private static string ActualString(OMatch<char> actual) { return string.Format("Value: {0},\tindex: {1}, length: {2}", new string(actual.Values.ToArray()), actual.Index, actual.Length); }
private static void CompareCaptures(Match expected, OMatch<char> actual) { var groups = expected.Groups.Cast<Group>().Where(x => x.Success).ToArray(); Assert.AreEqual(groups.Length, actual.Captures.Count); foreach (var group in actual.Captures) { var captured = expected.Groups[group.Key].Captures.Cast<Capture>().ToArray(); foreach (var capt in group.Value) { if (!captured.Any(x => x.Index == capt.Index && x.Length == capt.Length)) { Assert.Fail("Captures not equal." + capt); } } } }
private static void Compare(Match expected, OMatch<char> actual) { Assert.AreEqual(expected.Index, actual.Index); Assert.AreEqual(expected.Length, actual.Length); CompareCaptures(expected, actual); }
public Person(OMatch <Word> match) { Words = match.Values.ToArray(); Name = match.Captures["name"].First().Values.First().Value; //Now just normalize this name and you are good. }