Matches() 공개 정적인 메소드

Tests that the value of the named element matches a regular expression (see $regex).
public static Matches ( string name, BsonRegularExpression regex ) : QueryComplete
name string The name of the element to test.
regex BsonRegularExpression The regular expression to match against.
리턴 QueryComplete
        public void TestMatches()
        {
            var query    = Query.Matches("a", "/abc/");
            var expected = "{ 'a' : /abc/ }".Replace("'", "\"");

            Assert.AreEqual(expected, query.ToJson());
        }
        public void TestRegex()
        {
            var query    = Query.Matches("name", new BsonRegularExpression("acme.*corp", "i"));
            var expected = "{ \"name\" : /acme.*corp/i }";
            JsonWriterSettings settings = new JsonWriterSettings {
                OutputMode = JsonOutputMode.JavaScript
            };
            var actual = query.ToJson(settings);

            Assert.AreEqual(expected, actual);
        }