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 39a7bc70e70de403a2ab98282aade488c025c802
Author: Shad Storhaug <[email protected]>
AuthorDate: Tue Apr 20 00:08:26 2021 +0700

    Lucene.Net.TestFramework: Removed RandomizedTest stub class and move the 
methods into LuceneTestCase
---
 .../Support/Randomized/RandomizedTest.cs           | 93 ----------------------
 .../Util/LuceneTestCase.cs                         | 55 +++++++++++--
 2 files changed, 48 insertions(+), 100 deletions(-)

diff --git a/src/Lucene.Net.TestFramework/Support/Randomized/RandomizedTest.cs 
b/src/Lucene.Net.TestFramework/Support/Randomized/RandomizedTest.cs
deleted file mode 100644
index 37a8fc9..0000000
--- a/src/Lucene.Net.TestFramework/Support/Randomized/RandomizedTest.cs
+++ /dev/null
@@ -1,93 +0,0 @@
-using System;
-
-#if TESTFRAMEWORK_MSTEST
-using Microsoft.VisualStudio.TestTools.UnitTesting;
-using AssumptionViolatedException = 
Microsoft.VisualStudio.TestTools.UnitTesting.AssertInconclusiveException;
-#elif TESTFRAMEWORK_NUNIT
-using NUnit.Framework;
-using AssumptionViolatedException = NUnit.Framework.InconclusiveException;
-#elif TESTFRAMEWORK_XUNIT
-using Lucene.Net.TestFramework;
-using AssumptionViolatedException = Lucene.Net.TestFramework.SkipTestException;
-#endif
-
-namespace Lucene.Net.Randomized
-{
-    /*
-     * Licensed to the Apache Software Foundation (ASF) under one or more
-     * contributor license agreements.  See the NOTICE file distributed with
-     * this work for additional information regarding copyright ownership.
-     * The ASF licenses this file to You under the Apache License, Version 2.0
-     * (the "License"); you may not use this file except in compliance with
-     * the License.  You may obtain a copy of the License at
-     *
-     *     http://www.apache.org/licenses/LICENSE-2.0
-     *
-     * Unless required by applicable law or agreed to in writing, software
-     * distributed under the License is distributed on an "AS IS" BASIS,
-     * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-     * See the License for the specific language governing permissions and
-     * limitations under the License.
-     */
-
-    /// <summary>
-    /// Common scaffolding for subclassing randomized tests.
-    /// </summary>
-    public static class RandomizedTest // LUCENENET: Made static because all 
members are static
-    {
-        /// <param name="msg">Message to be included in the exception's 
string.</param>
-        /// <param name="condition">
-        /// If <c>false</c> an <see cref="AssumptionViolatedException"/> is
-        /// thrown by this method and the test case (should be) ignored (or
-        /// rather technically, flagged as a failure not passing a certain
-        /// assumption). Tests that are assumption-failures do not break
-        /// builds (again: typically).
-        /// </param>
-        public static void AssumeTrue(string msg, bool condition)
-        {
-#if TESTFRAMEWORK_MSTEST
-            if (!condition)
-                Assert.Inconclusive(msg);
-#elif TESTFRAMEWORK_NUNIT
-            Assume.That(condition, msg);
-#elif TESTFRAMEWORK_XUNIT
-            if (!condition)
-                throw new SkipTestException(msg);
-#endif
-        }
-
-        /// <param name="msg">Message to be included in the exception's 
string.</param>
-        /// <param name="condition">
-        /// If <c>true</c> an <see cref="AssumptionViolatedException"/> is
-        /// thrown by this method and the test case (should be) ignored (or
-        /// rather technically, flagged as a failure not passing a certain
-        /// assumption). Tests that are assumption-failures do not break
-        /// builds (again: typically).
-        /// </param>
-        public static void AssumeFalse(string msg, bool condition)
-        {
-#if TESTFRAMEWORK_MSTEST
-            if (condition)
-                Assert.Inconclusive(msg);
-#elif TESTFRAMEWORK_NUNIT
-            Assume.That(!condition, msg);
-#elif TESTFRAMEWORK_XUNIT
-            if (condition)
-                throw new SkipTestException(msg);
-#endif
-        }
-
-        /// <summary>
-        /// Assume <paramref name="t"/> is <c>null</c>.
-        /// </summary>
-        public static void AssumeNoException(string msg, Exception t)
-        {
-            if (t != null)
-            {
-                // This does chain the exception as the cause.
-                throw new AssumptionViolatedException(msg, t);
-            }
-        }
-    }
-}
-
diff --git a/src/Lucene.Net.TestFramework/Util/LuceneTestCase.cs 
b/src/Lucene.Net.TestFramework/Util/LuceneTestCase.cs
index 3f08ce5..bd6c9b8 100644
--- a/src/Lucene.Net.TestFramework/Util/LuceneTestCase.cs
+++ b/src/Lucene.Net.TestFramework/Util/LuceneTestCase.cs
@@ -4,7 +4,6 @@ using Lucene.Net.Diagnostics;
 using Lucene.Net.Documents;
 using Lucene.Net.Index;
 using Lucene.Net.Index.Extensions;
-using Lucene.Net.Randomized;
 using Lucene.Net.Search;
 using Lucene.Net.Store;
 using Lucene.Net.Support;
@@ -42,6 +41,7 @@ using OneTimeSetUp = 
Microsoft.VisualStudio.TestTools.UnitTesting.ClassInitializ
 using OneTimeTearDown = 
Microsoft.VisualStudio.TestTools.UnitTesting.ClassCleanupAttribute;
 using Test = Microsoft.VisualStudio.TestTools.UnitTesting.TestMethodAttribute;
 using TestFixture = 
Microsoft.VisualStudio.TestTools.UnitTesting.TestClassAttribute;
+using AssumptionViolatedException = 
Microsoft.VisualStudio.TestTools.UnitTesting.AssertInconclusiveException;
 #elif TESTFRAMEWORK_NUNIT
 using Before = NUnit.Framework.SetUpAttribute;
 using After = NUnit.Framework.TearDownAttribute;
@@ -49,6 +49,7 @@ using OneTimeSetUp = NUnit.Framework.OneTimeSetUpAttribute;
 using OneTimeTearDown = NUnit.Framework.OneTimeTearDownAttribute;
 using Test = NUnit.Framework.TestAttribute;
 using TestFixture = NUnit.Framework.TestFixtureAttribute;
+using AssumptionViolatedException = NUnit.Framework.InconclusiveException;
 using NUnit.Framework.Interfaces;
 using NUnit.Framework.Internal;
 using NUnit.Framework.Internal.Commands;
@@ -59,6 +60,7 @@ using OneTimeSetUp = Lucene.Net.Attributes.NoOpAttribute;
 using OneTimeTearDown = Lucene.Net.Attributes.NoOpAttribute;
 using Test = Lucene.Net.TestFramework.SkippableFactAttribute;
 using TestFixture = Lucene.Net.Attributes.NoOpAttribute;
+using AssumptionViolatedException = Lucene.Net.TestFramework.SkipTestException;
 #endif
 
 namespace Lucene.Net.Util
@@ -1422,19 +1424,58 @@ namespace Lucene.Net.Util
             return Usually(Random);
         }
 
-        public static void AssumeTrue(string msg, bool condition)
+        /// <param name="msg">Message to be included in the exception's 
string.</param>
+        /// <param name="condition">
+        /// If <c>false</c> an <see cref="AssumptionViolatedException"/> is
+        /// thrown by this method and the test case (should be) ignored (or
+        /// rather technically, flagged as a failure not passing a certain
+        /// assumption). Tests that are assumption-failures do not break
+        /// builds (again: typically).
+        /// </param>
+        public static void AssumeTrue(string msg, bool condition) // 
LUCENENET: From RandomizedTest
         {
-            RandomizedTest.AssumeTrue(msg, condition);
+#if TESTFRAMEWORK_MSTEST
+            if (!condition)
+                Assert.Inconclusive(msg);
+#elif TESTFRAMEWORK_NUNIT
+            NUnit.Framework.Assume.That(condition, msg);
+#elif TESTFRAMEWORK_XUNIT
+            if (!condition)
+                throw new SkipTestException(msg);
+#endif
         }
 
-        public static void AssumeFalse(string msg, bool condition)
+        /// <param name="msg">Message to be included in the exception's 
string.</param>
+        /// <param name="condition">
+        /// If <c>true</c> an <see cref="AssumptionViolatedException"/> is
+        /// thrown by this method and the test case (should be) ignored (or
+        /// rather technically, flagged as a failure not passing a certain
+        /// assumption). Tests that are assumption-failures do not break
+        /// builds (again: typically).
+        /// </param>
+        public static void AssumeFalse(string msg, bool condition) // 
LUCENENET: From RandomizedTest
         {
-            RandomizedTest.AssumeFalse(msg, condition);
+#if TESTFRAMEWORK_MSTEST
+            if (condition)
+                Assert.Inconclusive(msg);
+#elif TESTFRAMEWORK_NUNIT
+            NUnit.Framework.Assume.That(!condition, msg);
+#elif TESTFRAMEWORK_XUNIT
+            if (condition)
+                throw new SkipTestException(msg);
+#endif
         }
 
-        public static void AssumeNoException(string msg, Exception e)
+        /// <summary>
+        /// Assume <paramref name="e"/> is <c>null</c>.
+        /// </summary>
+        public static void AssumeNoException(string msg, Exception e) // 
LUCENENET: From RandomizedTest
         {
-            RandomizedTest.AssumeNoException(msg, e);
+            if (e != null)
+            {
+                // This does chain the exception as the cause.
+                throw new AssumptionViolatedException(msg, e);
+            }
         }
 
         /// <summary>

Reply via email to