public void MatchRegex_NotSupportedOption(RegexOptions options)
 {
     using (var context = new BloggingContext(ConnectionString))
     {
         Assert.That(() =>
         {
             var results = (from b in context.Blogs
                            where NpgsqlTextFunctions.MatchRegex(b.Name, "Some pattern", options)
                            select b.Name).ToList();
         }, Throws.InnerException.TypeOf <NotSupportedException>());
     }
 }
        public void MatchRegexOptions(RegexOptions options, string pattern, string matchingInput, string mismatchingInput)
        {
            // Arrange
            using (var context = new BloggingContext(ConnectionString))
            {
                context.Database.Log = Console.Out.WriteLine;

                context.Blogs.Add(new Blog()
                {
                    Name = matchingInput
                });
                context.Blogs.Add(new Blog()
                {
                    Name = mismatchingInput
                });
                context.SaveChanges();
            }

            // Act
            // Ensure correctness of a test case
            var netMatchResult    = Regex.IsMatch(matchingInput, pattern, options);
            var netMismatchResult = Regex.IsMatch(mismatchingInput, pattern, options);

            List <string> pgMatchResults;
            List <string> pgMismatchResults;

            using (var context = new BloggingContext(ConnectionString))
            {
                pgMatchResults = (from b in context.Blogs
                                  where NpgsqlTextFunctions.MatchRegex(b.Name, pattern, options)
                                  select b.Name).ToList();

                pgMismatchResults = (from b in context.Blogs
                                     where !NpgsqlTextFunctions.MatchRegex(b.Name, pattern, options)
                                     select b.Name).ToList();
            }

            // Assert
            Assert.That(netMatchResult, Is.True);
            Assert.That(netMismatchResult, Is.False);

            Assert.That(pgMatchResults.Count, Is.EqualTo(1));
            Assert.That(pgMatchResults[0], Is.EqualTo(matchingInput));
            Assert.That(pgMismatchResults.Count, Is.EqualTo(1));
            Assert.That(pgMismatchResults[0], Is.EqualTo(mismatchingInput));
        }