public void WildcardMatcher_IsMatch_Positive() { var tests = new[] { new { p = "*", i = "" }, new { p = "?", i = " " }, new { p = "*", i = "a " }, new { p = "*", i = "ab" }, new { p = "?", i = "a" }, new { p = "*?", i = "abc" }, new { p = "?*", i = "abc" }, new { p = "abc", i = "abc" }, new { p = "abc*", i = "abc" }, new { p = "abc*", i = "abcd" }, new { p = "*abc*", i = "abc" }, new { p = "*a*bc*", i = "abc" }, new { p = "*a*b?", i = "aXXXbc" } }; foreach (var test in tests) { var matcher = new WildcardMatcher(test.p); matcher.IsMatch(test.i).Should().Be(1.0d, $"Pattern '{test.p}' with value '{test.i}' should be 1.0"); } }
public void WildcardMatcher_patterns_positive() { var tests = new[] { new { p = "*", i = "" }, new { p = "?", i = " " }, new { p = "*", i = "a" }, new { p = "*", i = "ab" }, new { p = "?", i = "a" }, new { p = "*?", i = "abc" }, new { p = "?*", i = "abc" }, new { p = "abc", i = "abc" }, new { p = "abc*", i = "abc" }, new { p = "abc*", i = "abcd" }, new { p = "*abc*", i = "abc" }, new { p = "*a*bc*", i = "abc" }, new { p = "*a*b?", i = "aXXXbc" } }; foreach (var test in tests) { var matcher = new WildcardMatcher(test.p); Check.That(matcher.IsMatch(test.i)).Equals(1.0); //Assert.AreEqual(1.0, matcher.IsMatch(test.i), "p = " + test.p + ", i = " + test.i); } }
public void WildcardMatcher_IsMatch_Positive() { var tests = new[] { new { p = "*", i = "" }, new { p = "?", i = " " }, new { p = "*", i = "a" }, new { p = "*", i = "ab" }, new { p = "?", i = "a" }, new { p = "*?", i = "abc" }, new { p = "?*", i = "abc" }, new { p = "abc", i = "abc" }, new { p = "abc*", i = "abc" }, new { p = "abc*", i = "abcd" }, new { p = "*abc*", i = "abc" }, new { p = "*a*bc*", i = "abc" }, new { p = "*a*b?", i = "aXXXbc" } }; foreach (var test in tests) { var matcher = new WildcardMatcher(test.p); Check.That(matcher.IsMatch(test.i)).IsEqualTo(1.0d); } }
public QueryArgumentInfoList Include([NotNull] params string[] includedGraphQLPropertyPaths) { Guard.HasNoNulls(includedGraphQLPropertyPaths, nameof(includedGraphQLPropertyPaths)); var matcher = new WildcardMatcher(MatchBehaviour.AcceptOnMatch, includedGraphQLPropertyPaths); return(new QueryArgumentInfoList(this.Where(q => MatchScores.IsPerfect(matcher.IsMatch(q.GraphQLPath))))); }
public void WildcardMatcher_IsMatch_RejectOnMatch() { // Assign var matcher = new WildcardMatcher(MatchBehaviour.RejectOnMatch, "m"); // Act double result = matcher.IsMatch("m"); Check.That(result).IsEqualTo(0.0); }
public void WildcardMatcher_IsMatch_With_StringMatcher_And_StringPattern() { // Arrange var pattern = new StringPattern { Pattern = "*", PatternAsFile = "pf" }; // Act var matcher = new WildcardMatcher(pattern); // Assert matcher.IsMatch("a").Should().Be(1.0d); }
public void WildcardMatcher_IsMatch_Negative() { var tests = new[] { new { p = "*a", i = "" }, new { p = "a*", i = "" }, new { p = "?", i = "" }, new { p = "*b*", i = "a" }, new { p = "b*a", i = "ab" }, new { p = "??", i = "a" }, new { p = "*?", i = "" }, new { p = "??*", i = "a" }, new { p = "*abc", i = "abX" }, new { p = "*abc*", i = "Xbc" }, new { p = "*a*bc*", i = "ac" } }; foreach (var test in tests) { var matcher = new WildcardMatcher(test.p); Check.That(matcher.IsMatch(test.i)).IsEqualTo(0.0); } }
public void WildcardMatcher_patterns_negative() { var tests = new[] { new { p = "*a", i = "" }, new { p = "a*", i = "" }, new { p = "?", i = "" }, new { p = "*b*", i = "a" }, new { p = "b*a", i = "ab" }, new { p = "??", i = "a" }, new { p = "*?", i = "" }, new { p = "??*", i = "a" }, new { p = "*abc", i = "abX" }, new { p = "*abc*", i = "Xbc" }, new { p = "*a*bc*", i = "ac" } }; foreach (var test in tests) { var matcher = new WildcardMatcher(test.p); Assert.AreEqual(0.0, matcher.IsMatch(test.i), "p = " + test.p + ", i = " + test.i); } }
public async Task <IEnumerable <TagRequest> > QueryTaggedRequestsAsync(int limit, string[] filterTags = null) { var result = await Task.Run(() => { // Get tagged requests collection var taggedRequests = ServerContext.Database.GetCollection <TagRequest>(DatabaseConstants.TaggedRequestDataKey); // Log by descending timestamp return(taggedRequests.Find( Query.And( Query.All(nameof(TagRequest.Timestamp), Query.Descending), Query.Where(nameof(TagRequest.Tag), v => filterTags == null || filterTags.Any(f => WildcardMatcher.IsMatch(v.AsString, f))) ), limit: limit )); }); return(result); }