This is an automated email from the ASF dual-hosted git repository.

nightowl888 pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/lucenenet.git

commit 541c5b5416c32f213f703ed422904c02df29b523
Author: Shad Storhaug <[email protected]>
AuthorDate: Tue Jun 30 10:14:19 2020 +0700

    Lucene.Net.Tests.QueryParser.Classic.TestQueryParser::TestProtectedCtors(): 
Reflection doesn't throw exceptions when it cannot find a constructor in .NET, 
we need to test for null instead. (#301)
---
 .../Classic/TestQueryParser.cs                     | 41 ++++++++++++----------
 1 file changed, 23 insertions(+), 18 deletions(-)

diff --git a/src/Lucene.Net.Tests.QueryParser/Classic/TestQueryParser.cs 
b/src/Lucene.Net.Tests.QueryParser/Classic/TestQueryParser.cs
index 9e21454..60027b9 100644
--- a/src/Lucene.Net.Tests.QueryParser/Classic/TestQueryParser.cs
+++ b/src/Lucene.Net.Tests.QueryParser/Classic/TestQueryParser.cs
@@ -143,24 +143,29 @@ namespace Lucene.Net.QueryParsers.Classic
         [Test]
         public virtual void TestProtectedCtors()
         {
-            try
-            {
-                typeof(QueryParser).GetConstructor(new Type[] { 
typeof(ICharStream) });
-                fail("please switch public QueryParser(CharStream) to be 
protected");
-            }
-            catch (Exception /*nsme*/)
-            {
-                // expected
-            }
-            try
-            {
-                typeof(QueryParser).GetConstructor(new Type[] { 
typeof(QueryParserTokenManager) });
-                fail("please switch public 
QueryParser(QueryParserTokenManager) to be protected");
-            }
-            catch (Exception /*nsme*/)
-            {
-                // expected
-            }
+            // LUCENENET: .NET doesn't throw exceptions when public 
constructors don't exist, it simply returns null.
+
+            assertNull("please switch public QueryParser(ICharStream) to be 
protected", typeof(QueryParser).GetConstructor(new Type[] { typeof(ICharStream) 
}));
+            assertNull("please switch public 
QueryParser(QueryParserTokenManager) to be protected", 
typeof(QueryParser).GetConstructor(new Type[] { typeof(QueryParserTokenManager) 
}));
+
+            //try
+            //{
+            //    typeof(QueryParser).GetConstructor(new Type[] { 
typeof(ICharStream) });
+            //    fail("please switch public QueryParser(CharStream) to be 
protected");
+            //}
+            //catch (Exception /*nsme*/)
+            //{
+            //    // expected
+            //}
+            //try
+            //{
+            //    typeof(QueryParser).GetConstructor(new Type[] { 
typeof(QueryParserTokenManager) });
+            //    fail("please switch public 
QueryParser(QueryParserTokenManager) to be protected");
+            //}
+            //catch (Exception /*nsme*/)
+            //{
+            //    // expected
+            //}
         }
 
         private class TestFuzzySlopeExtendabilityQueryParser : QueryParser

Reply via email to