lucenenet-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From mhern...@apache.org
Subject [4/7] lucenenet git commit: creating new projects in order to separate out logic create to suppliment .NET with JAVA standard library functionality.
Date Sun, 09 Nov 2014 22:07:48 GMT
http://git-wip-us.apache.org/repos/asf/lucenenet/blob/4b4d4d93/test/Lucene.Net.Core.Tests/Lucene.Net.Core.Tests.csproj
----------------------------------------------------------------------
diff --git a/test/Lucene.Net.Core.Tests/Lucene.Net.Core.Tests.csproj b/test/Lucene.Net.Core.Tests/Lucene.Net.Core.Tests.csproj
index 54711db..7a3150c 100644
--- a/test/Lucene.Net.Core.Tests/Lucene.Net.Core.Tests.csproj
+++ b/test/Lucene.Net.Core.Tests/Lucene.Net.Core.Tests.csproj
@@ -23,7 +23,7 @@
   <Import Project="..\..\packages\xunit.core.2.0.0-beta-build2700\build\portable-net45+win+wpa81+wp80\xunit.core.props" Condition="Exists('..\..\packages\xunit.core.2.0.0-beta-build2700\build\portable-net45+win+wpa81+wp80\xunit.core.props')" />
   <Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')" />
   <PropertyGroup>
-    <MinimumVisualStudioVersion>12.0</MinimumVisualStudioVersion>
+    <MinimumVisualStudioVersion>10.0</MinimumVisualStudioVersion>
     <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
     <Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
     <ProjectGuid>{C879C7A6-FBE5-4F22-B363-A4356C7B8E76}</ProjectGuid>
@@ -34,8 +34,8 @@
     <DefaultLanguage>en-US</DefaultLanguage>
     <FileAlignment>512</FileAlignment>
     <ProjectTypeGuids>{786C830F-07A1-408B-BD7F-6EE04809D6DB};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</ProjectTypeGuids>
-    <TargetFrameworkProfile>Profile151</TargetFrameworkProfile>
-    <TargetFrameworkVersion>v4.6</TargetFrameworkVersion>
+    <TargetFrameworkProfile>Profile111</TargetFrameworkProfile>
+    <TargetFrameworkVersion>v4.5</TargetFrameworkVersion>
     <SolutionDir Condition="$(SolutionDir) == '' Or $(SolutionDir) == '*Undefined*'">..\..\</SolutionDir>
     <RestorePackages>true</RestorePackages>
   </PropertyGroup>
@@ -70,6 +70,7 @@
     <Compile Include="Util\TestCharsRef.cs" />
     <Compile Include="Util\TestConstants.cs" />
     <Compile Include="Util\TestInPlaceMergeSorter.cs" />
+    <Compile Include="Util\TestOpenBitSet.cs" />
     <Compile Include="Util\TestPurgableThreadLocal.cs" />
     <Compile Include="Util\TestRamEstimatorUsage.cs" />
     <Compile Include="Util\TestSetOnce.cs" />
@@ -95,6 +96,10 @@
       <Project>{ad8901c0-209d-4132-80aa-257dbaceecb4}</Project>
       <Name>Lucene.Net.Core</Name>
     </ProjectReference>
+    <ProjectReference Include="..\Lucene.Net.TestFramework.Core\Lucene.Net.TestFramework.Core.csproj">
+      <Project>{438b8450-e93a-425f-9a9b-11d02e8896d5}</Project>
+      <Name>Lucene.Net.TestFramework.Core</Name>
+    </ProjectReference>
     <ProjectReference Include="..\Lucene.Net.TestFramework\Lucene.Net.TestFramework.csproj">
       <Project>{f0d68fea-b118-43b6-b760-3fb75cde766d}</Project>
       <Name>Lucene.Net.TestFramework</Name>

http://git-wip-us.apache.org/repos/asf/lucenenet/blob/4b4d4d93/test/Lucene.Net.Core.Tests/Util/BaseSorterTestCase.cs
----------------------------------------------------------------------
diff --git a/test/Lucene.Net.Core.Tests/Util/BaseSorterTestCase.cs b/test/Lucene.Net.Core.Tests/Util/BaseSorterTestCase.cs
index 0318665..3d8931c 100644
--- a/test/Lucene.Net.Core.Tests/Util/BaseSorterTestCase.cs
+++ b/test/Lucene.Net.Core.Tests/Util/BaseSorterTestCase.cs
@@ -98,7 +98,7 @@ namespace Lucene.Net.Util
             var entries = new Entry[length];
             for (var i = 0; i < entries.Length; ++i)
             {
-                strategy.SetValue(this.Random, entries, i);
+                strategy.SetValue(Random, entries, i);
             }
 
             return entries;
@@ -107,8 +107,8 @@ namespace Lucene.Net.Util
         // test(Entry[] array)
         protected Entry[] CopyAndSort(Entry[] entries)
         {
-            int start = this.Random.Next(1000);
-            var toSort = new Entry[start + entries.Length + this.Random.Next(3)];
+            int start = Random.Next(1000);
+            var toSort = new Entry[start + entries.Length + Random.Next(3)];
             Array.Copy(entries, 0, toSort, start, entries.Length);
 
             var sorter = this.CreateSorter(toSort);

http://git-wip-us.apache.org/repos/asf/lucenenet/blob/4b4d4d93/test/Lucene.Net.Core.Tests/Util/TestBroadWord.cs
----------------------------------------------------------------------
diff --git a/test/Lucene.Net.Core.Tests/Util/TestBroadWord.cs b/test/Lucene.Net.Core.Tests/Util/TestBroadWord.cs
index db6bbe3..e91d419 100644
--- a/test/Lucene.Net.Core.Tests/Util/TestBroadWord.cs
+++ b/test/Lucene.Net.Core.Tests/Util/TestBroadWord.cs
@@ -98,10 +98,11 @@ namespace Lucene.Net.Util
         }
 
         [Test]
-        [Perf] // TODO: implement a real performance test.
+        [Performance] // TODO: implement a real performance test.
         public void TestPerfSelectAllBitsBroad()
         {
-            for (int j = 0; j < 100000; j++)
+            var length = AtLeast(5000);
+            for (int j = 0; j < length; j++)
             { // 1000000 for real perf test
                 for (int i = 0; i < 64; i++)
                 {
@@ -111,10 +112,12 @@ namespace Lucene.Net.Util
             }
         }
 
-        [Test][Perf]
+        [Test]
+        [Performance]
         public void TestPerfSelectAllBitsNaive()
         {
-            for (int j = 0; j < 10000; j++)
+            var length = AtLeast(5000);
+            for (int j = 0; j < length; j++)
             { // real perftest: 1000000
                 for (int i = 0; i < 64; i++)
                 {

http://git-wip-us.apache.org/repos/asf/lucenenet/blob/4b4d4d93/test/Lucene.Net.Core.Tests/Util/TestByteArrayRef.cs
----------------------------------------------------------------------
diff --git a/test/Lucene.Net.Core.Tests/Util/TestByteArrayRef.cs b/test/Lucene.Net.Core.Tests/Util/TestByteArrayRef.cs
index f7b6897..bb6de32 100644
--- a/test/Lucene.Net.Core.Tests/Util/TestByteArrayRef.cs
+++ b/test/Lucene.Net.Core.Tests/Util/TestByteArrayRef.cs
@@ -28,7 +28,7 @@ namespace Lucene.Net.Util
         [Test]
         public virtual void TestAppend()
         {
-            var random = this.Random;
+            var random = Random;
             var  list = new BytesRefArray(Counter.NewCounter());
             IList<string> stringList = new List<string>();
             for (int j = 0; j < 2; j++)
@@ -38,7 +38,7 @@ namespace Lucene.Net.Util
                     list.Clear();
                     stringList.Clear();
                 }
-                int entries = this.AtLeast(500);
+                int entries = Random.AtLeast(500);
                 var spare = new BytesRefBuilder();
                 int initSize = list.Length;
                 for (int i = 0; i < entries; i++)
@@ -78,7 +78,7 @@ namespace Lucene.Net.Util
         [Test]
         public virtual void TestSort()
         {
-            var random = this.Random;
+            var random = Random;
             var list = new BytesRefArray(Util.Counter.NewCounter());
             var stringList = new List<string>();
 
@@ -89,7 +89,7 @@ namespace Lucene.Net.Util
                     list.Clear();
                     stringList.Clear();
                 }
-                int entries = this.AtLeast(500);
+                int entries = Random.AtLeast(500);
                 var spare = new BytesRef();
                 int initSize = list.Length;
                 for (int i = 0; i < entries; i++)

http://git-wip-us.apache.org/repos/asf/lucenenet/blob/4b4d4d93/test/Lucene.Net.Core.Tests/Util/TestByteBlockPool.cs
----------------------------------------------------------------------
diff --git a/test/Lucene.Net.Core.Tests/Util/TestByteBlockPool.cs b/test/Lucene.Net.Core.Tests/Util/TestByteBlockPool.cs
index 0bfff1b..95321cc 100644
--- a/test/Lucene.Net.Core.Tests/Util/TestByteBlockPool.cs
+++ b/test/Lucene.Net.Core.Tests/Util/TestByteBlockPool.cs
@@ -52,17 +52,17 @@ namespace Lucene.Net.Util
             var bytesUsed = Counter.NewCounter();
             var  pool = new ByteBlockPool(new ByteBlockPool.DirectTrackingAllocator(bytesUsed));
             
-            var reuseFirst = this.Random.NextBoolean();
+            var reuseFirst = Random.NextBoolean();
             for (var j = 0; j < 2; j++)
             {
                 IList<BytesRefProxy> list = new List<BytesRefProxy>();
-                int maxLength = this.AtLeast(500),
-                    numValues = this.AtLeast(100);
+                int maxLength = Random.AtLeast(500),
+                    numValues = Random.AtLeast(100);
                 
                
                 numValues.Times(i =>
                 {
-                    string value = this.Random.RandomRealisticUnicodeString(maxLength: maxLength);
+                    string value = Random.RandomRealisticUnicodeString(maxLength: maxLength);
                     list.Add(new BytesRefProxy(value));
                     var @ref = new BytesRefProxy();
                     @ref.CopyChars(value);
@@ -80,7 +80,7 @@ namespace Lucene.Net.Util
                     Equal(expected, @ref);
                     position += @ref.Length;
                 }
-                pool.Reset(this.Random.NextBoolean(), reuseFirst);
+                pool.Reset(Random.NextBoolean(), reuseFirst);
                 if (reuseFirst)
                 {
                     Equal(ByteBlockPool.BYTE_BLOCK_SIZE, bytesUsed.Count);

http://git-wip-us.apache.org/repos/asf/lucenenet/blob/4b4d4d93/test/Lucene.Net.Core.Tests/Util/TestBytesRef.cs
----------------------------------------------------------------------
diff --git a/test/Lucene.Net.Core.Tests/Util/TestBytesRef.cs b/test/Lucene.Net.Core.Tests/Util/TestBytesRef.cs
index 034d89f..7a19bf7 100644
--- a/test/Lucene.Net.Core.Tests/Util/TestBytesRef.cs
+++ b/test/Lucene.Net.Core.Tests/Util/TestBytesRef.cs
@@ -50,7 +50,7 @@ namespace Lucene.Net.Util
         {
             100.Times((i) =>
             {
-                var utf8Str1 = this.Random.ToUnicodeString();
+                var utf8Str1 = Random.ToUnicodeString();
                 var utf8Str2 = new BytesRef(utf8Str1).Utf8ToString();
                 Equal(utf8Str1, utf8Str2);
             });

http://git-wip-us.apache.org/repos/asf/lucenenet/blob/4b4d4d93/test/Lucene.Net.Core.Tests/Util/TestCharsRef.cs
----------------------------------------------------------------------
diff --git a/test/Lucene.Net.Core.Tests/Util/TestCharsRef.cs b/test/Lucene.Net.Core.Tests/Util/TestCharsRef.cs
index 35b789c..02ab41b 100644
--- a/test/Lucene.Net.Core.Tests/Util/TestCharsRef.cs
+++ b/test/Lucene.Net.Core.Tests/Util/TestCharsRef.cs
@@ -31,13 +31,13 @@ namespace Lucene.Net.Util
         [Test]
         public void TestUtf16InUtf8Order()
         {
-            var iterations = this.AtLeast(1000);
+            var iterations = AtLeast(1000);
             var utf8 = new BytesRef[iterations];
             var utf16 = new CharsRef[iterations];
 
             iterations.Times((i) =>
             {
-                var s = this.Random.RandomUnicodeString();
+                var s = Random.RandomUnicodeString();
                 utf8[i] = new BytesRef(s);
                 utf16[i] = new CharsRef(s);
             });
@@ -55,11 +55,11 @@ namespace Lucene.Net.Util
         public void TestAppend() {
             var builder = new CharsRefBuilder();
             var sb = new StringBuilder();
-            int iterations = this.AtLeast(10);
+            int iterations = Random.AtLeast(10);
 
             iterations.Times((i) => {
-                var charArray = this.Random.RandomRealisticUnicodeString(1, 100).ToCharArray();
-                int offset = this.Random.Next(charArray.Length);
+                var charArray = Random.RandomRealisticUnicodeString(1, 100).ToCharArray();
+                int offset = Random.Next(charArray.Length);
                 int length = charArray.Length - offset;
                 sb.Append(charArray, offset, length);
                 builder.Append(charArray, offset, length);  
@@ -72,11 +72,11 @@ namespace Lucene.Net.Util
         [Test]
         public void TestCopy()
         {
-            var iterations = this.AtLeast(10);
+            var iterations = Random.AtLeast(10);
             iterations.Times((i) => {
                 var builder = new CharsRefBuilder();
-                var charArray = this.Random.RandomRealisticUnicodeString(1, 100).ToCharArray();
-                int offset = this.Random.Next(charArray.Length),
+                var charArray = Random.RandomRealisticUnicodeString(1, 100).ToCharArray();
+                int offset = Random.Next(charArray.Length),
                     length = charArray.Length - offset;
 
                String str = new String(charArray, offset, length);

http://git-wip-us.apache.org/repos/asf/lucenenet/blob/4b4d4d93/test/Lucene.Net.Core.Tests/Util/TestOpenBitSet.cs
----------------------------------------------------------------------
diff --git a/test/Lucene.Net.Core.Tests/Util/TestOpenBitSet.cs b/test/Lucene.Net.Core.Tests/Util/TestOpenBitSet.cs
new file mode 100644
index 0000000..13a09dc
--- /dev/null
+++ b/test/Lucene.Net.Core.Tests/Util/TestOpenBitSet.cs
@@ -0,0 +1,439 @@
+/*
+ * 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.
+ */
+
+
+
+namespace Lucene.Net.Util
+{
+    using Lucene.Net.Random;
+    using Lucene.Net.Support;
+    using System.Collections;
+
+    using DocIdSetIterator = Lucene.Net.Search.DocIdSetIterator;
+
+    /*
+    public class TestOpenBitSet : BaseDocIdSetTestCase<OpenBitSet>
+    {
+        public override OpenBitSet CopyOf(BitArray bs, int length)
+        {
+            OpenBitSet set = new OpenBitSet(length);
+            for (int doc = bs.NextSetBit(0); doc != -1; doc = bs.NextSetBit(doc + 1))
+            {
+                set.Set(doc);
+            }
+            return set;
+        }
+
+        internal virtual void DoGet(BitArray a, OpenBitSet b)
+        {
+            int max = a.Count;
+            for (int i = 0; i < max; i++)
+            {
+                if (a.Get(i) != b.Get(i))
+                {
+                    Assert.Fail("mismatch: BitSet=[" + i + "]=" + a.Get(i));
+                }
+                if (a.Get(i) != b.Get((long)i))
+                {
+                    Assert.Fail("mismatch: BitSet=[" + i + "]=" + a.Get(i));
+                }
+            }
+        }
+
+        internal virtual void DoGetFast(BitArray a, OpenBitSet b, int max)
+        {
+            for (int i = 0; i < max; i++)
+            {
+                if (a.Get(i) != b.FastGet(i))
+                {
+                    Assert.Fail("mismatch: BitSet=[" + i + "]=" + a.Get(i));
+                }
+                if (a.Get(i) != b.FastGet((long)i))
+                {
+                    Assert.Fail("mismatch: BitSet=[" + i + "]=" + a.Get(i));
+                }
+            }
+        }
+
+        internal virtual void DoNextSetBit(BitArray a, OpenBitSet b)
+        {
+            int aa = -1, bb = -1;
+            do
+            {
+                aa = a.NextSetBit(aa + 1);
+                bb = b.NextSetBit(bb + 1);
+                Assert.AreEqual(aa, bb);
+            } while (aa >= 0);
+        }
+
+        internal virtual void DoNextSetBitLong(BitArray a, OpenBitSet b)
+        {
+            int aa = -1, bb = -1;
+            do
+            {
+                aa = a.NextSetBit(aa + 1);
+                bb = (int)b.NextSetBit((long)(bb + 1));
+                Assert.AreEqual(aa, bb);
+            } while (aa >= 0);
+        }
+
+        internal virtual void DoPrevSetBit(BitArray a, OpenBitSet b)
+        {
+            int aa = a.Count + Random().Next(100);
+            int bb = aa;
+            do
+            {
+                // aa = a.PrevSetBit(aa-1);
+                aa--;
+                while ((aa >= 0) && (!a.Get(aa)))
+                {
+                    aa--;
+                }
+                bb = b.PrevSetBit(bb - 1);
+                Assert.AreEqual(aa, bb);
+            } while (aa >= 0);
+        }
+
+        internal virtual void DoPrevSetBitLong(BitArray a, OpenBitSet b)
+        {
+            int aa = a.Count + Random().Next(100);
+            int bb = aa;
+            do
+            {
+                // aa = a.PrevSetBit(aa-1);
+                aa--;
+                while ((aa >= 0) && (!a.Get(aa)))
+                {
+                    aa--;
+                }
+                bb = (int)b.PrevSetBit((long)(bb - 1));
+                Assert.AreEqual(aa, bb);
+            } while (aa >= 0);
+        }
+
+        // test interleaving different OpenBitSetIterator.Next()/skipTo()
+        internal virtual void DoIterate(BitArray a, OpenBitSet b, int mode)
+        {
+            if (mode == 1)
+            {
+                DoIterate1(a, b);
+            }
+            if (mode == 2)
+            {
+                DoIterate2(a, b);
+            }
+        }
+
+        internal virtual void DoIterate1(BitArray a, OpenBitSet b)
+        {
+            int aa = -1, bb = -1;
+            OpenBitSetIterator iterator = new OpenBitSetIterator(b);
+            do
+            {
+                aa = a.NextSetBit(aa + 1);
+                bb = Random().NextBoolean() ? iterator.NextDoc() : iterator.Advance(bb + 1);
+                Assert.AreEqual(aa == -1 ? DocIdSetIterator.NO_MORE_DOCS : aa, bb);
+            } while (aa >= 0);
+        }
+
+        internal virtual void DoIterate2(BitArray a, OpenBitSet b)
+        {
+            int aa = -1, bb = -1;
+            OpenBitSetIterator iterator = new OpenBitSetIterator(b);
+            do
+            {
+                aa = a.NextSetBit(aa + 1);
+                bb = Random().NextBoolean() ? iterator.NextDoc() : iterator.Advance(bb + 1);
+                Assert.AreEqual(aa == -1 ? DocIdSetIterator.NO_MORE_DOCS : aa, bb);
+            } while (aa >= 0);
+        }
+
+        internal virtual void DoRandomSets(int maxSize, int iter, int mode)
+        {
+            BitArray a0 = null;
+            OpenBitSet b0 = null;
+
+            for (int i = 0; i < iter; i++)
+            {
+                int sz = Random().Next(maxSize);
+                BitArray a = new BitArray(sz);
+                OpenBitSet b = new OpenBitSet(sz);
+
+                // test the various ways of setting bits
+                if (sz > 0)
+                {
+                    int nOper = Random().Next(sz);
+                    for (int j = 0; j < nOper; j++)
+                    {
+                        int idx;
+
+                        idx = Random().Next(sz);
+                        a.Set(idx, true);
+                        b.FastSet(idx);
+
+                        idx = Random().Next(sz);
+                        a.Set(idx, true);
+                        b.FastSet((long)idx);
+
+                        idx = Random().Next(sz);
+                        a.Set(idx, false);
+                        b.FastClear(idx);
+
+                        idx = Random().Next(sz);
+                        a.Set(idx, false);
+                        b.FastClear((long)idx);
+
+                        idx = Random().Next(sz);
+                        a.Set(idx, !a.Get(idx));
+                        b.FastFlip(idx);
+
+                        bool val = b.FlipAndGet(idx);
+                        bool val2 = b.FlipAndGet(idx);
+                        Assert.IsTrue(val != val2);
+
+                        idx = Random().Next(sz);
+                        a.Set(idx, !a.Get(idx));
+                        b.FastFlip((long)idx);
+
+                        val = b.FlipAndGet((long)idx);
+                        val2 = b.FlipAndGet((long)idx);
+                        Assert.IsTrue(val != val2);
+
+                        val = b.GetAndSet(idx);
+                        Assert.IsTrue(val2 == val);
+                        Assert.IsTrue(b.Get(idx));
+
+                        if (!val)
+                        {
+                            b.FastClear(idx);
+                        }
+                        Assert.IsTrue(b.Get(idx) == val);
+                    }
+                }
+
+                // test that the various ways of accessing the bits are equivalent
+                DoGet(a, b);
+                DoGetFast(a, b, sz);
+
+                // test ranges, including possible extension
+                int fromIndex, toIndex;
+                fromIndex = Random().Next(sz + 80);
+                toIndex = fromIndex + Random().Next((sz >> 1) + 1);
+                BitArray aa = (BitArray)a.Clone();
+                aa.Flip(fromIndex, toIndex);
+                OpenBitSet bb = (OpenBitSet)b.Clone();
+                bb.Flip(fromIndex, toIndex);
+
+                DoIterate(aa, bb, mode); // a problem here is from flip or doIterate
+
+                fromIndex = Random().Next(sz + 80);
+                toIndex = fromIndex + Random().Next((sz >> 1) + 1);
+                aa = (BitArray)a.Clone();
+                aa.Clear(fromIndex, toIndex);
+                bb = (OpenBitSet)b.Clone();
+                bb.Clear(fromIndex, toIndex);
+
+                DoNextSetBit(aa, bb); // a problem here is from clear() or nextSetBit
+                DoNextSetBitLong(aa, bb);
+
+                DoPrevSetBit(aa, bb);
+                DoPrevSetBitLong(aa, bb);
+
+                fromIndex = Random().Next(sz + 80);
+                toIndex = fromIndex + Random().Next((sz >> 1) + 1);
+                aa = (BitArray)a.Clone();
+                aa.Set(fromIndex, toIndex);
+                bb = (OpenBitSet)b.Clone();
+                bb.Set(fromIndex, toIndex);
+
+                DoNextSetBit(aa, bb); // a problem here is from set() or nextSetBit
+                DoNextSetBitLong(aa, bb);
+
+                DoPrevSetBit(aa, bb);
+                DoPrevSetBitLong(aa, bb);
+
+                if (a0 != null)
+                {
+                    Assert.AreEqual(a.Equals(a0), b.Equals(b0));
+
+                    Assert.AreEqual(a.Cardinality(), b.Cardinality());
+
+                    BitArray a_and = (BitArray)a.Clone();
+                    a_and = a_and.And(a0);
+                    BitArray a_or = (BitArray)a.Clone();
+                    a_or = a_or.Or(a0);
+                    BitArray a_xor = (BitArray)a.Clone();
+                    a_xor = a_xor.Xor(a0);
+                    BitArray a_andn = (BitArray)a.Clone();
+                    a_andn.AndNot(a0);
+
+                    OpenBitSet b_and = (OpenBitSet)b.Clone();
+                    Assert.AreEqual(b, b_and);
+                    b_and.And(b0);
+                    OpenBitSet b_or = (OpenBitSet)b.Clone();
+                    b_or.Or(b0);
+                    OpenBitSet b_xor = (OpenBitSet)b.Clone();
+                    b_xor.Xor(b0);
+                    OpenBitSet b_andn = (OpenBitSet)b.Clone();
+                    b_andn.AndNot(b0);
+
+                    DoIterate(a_and, b_and, mode);
+                    DoIterate(a_or, b_or, mode);
+                    DoIterate(a_xor, b_xor, mode);
+                    DoIterate(a_andn, b_andn, mode);
+
+                    Assert.AreEqual(a_and.Cardinality(), b_and.Cardinality());
+                    Assert.AreEqual(a_or.Cardinality(), b_or.Cardinality());
+                    Assert.AreEqual(a_xor.Cardinality(), b_xor.Cardinality());
+                    Assert.AreEqual(a_andn.Cardinality(), b_andn.Cardinality());
+
+                    // test non-mutating popcounts
+                    Assert.AreEqual(b_and.Cardinality(), OpenBitSet.IntersectionCount(b, b0));
+                    Assert.AreEqual(b_or.Cardinality(), OpenBitSet.UnionCount(b, b0));
+                    Assert.AreEqual(b_xor.Cardinality(), OpenBitSet.XorCount(b, b0));
+                    Assert.AreEqual(b_andn.Cardinality(), OpenBitSet.AndNotCount(b, b0));
+                }
+
+                a0 = a;
+                b0 = b;
+            }
+        }
+
+        // large enough to flush obvious bugs, small enough to run in <.5 sec as part of a
+        // larger testsuite.
+        [Test]
+        public virtual void TestSmall()
+        {
+            DoRandomSets(AtLeast(1200), AtLeast(1000), 1);
+            DoRandomSets(AtLeast(1200), AtLeast(1000), 2);
+        }
+
+        // uncomment to run a bigger test (~2 minutes).
+        /*
+        public void TestBig() {
+          doRandomSets(2000,200000, 1);
+          doRandomSets(2000,200000, 2);
+        }
+        */
+
+        /*
+
+        [Test]
+        public virtual void TestEquals()
+        {
+            OpenBitSet b1 = new OpenBitSet(1111);
+            OpenBitSet b2 = new OpenBitSet(2222);
+            Assert.IsTrue(b1.Equals(b2));
+            Assert.IsTrue(b2.Equals(b1));
+            b1.Set(10);
+            Assert.IsFalse(b1.Equals(b2));
+            Assert.IsFalse(b2.Equals(b1));
+            b2.Set(10);
+            Assert.IsTrue(b1.Equals(b2));
+            Assert.IsTrue(b2.Equals(b1));
+            b2.Set(2221);
+            Assert.IsFalse(b1.Equals(b2));
+            Assert.IsFalse(b2.Equals(b1));
+            b1.Set(2221);
+            Assert.IsTrue(b1.Equals(b2));
+            Assert.IsTrue(b2.Equals(b1));
+
+            // try different type of object
+            Assert.IsFalse(b1.Equals(new object()));
+        }
+
+        [Test]
+        public virtual void TestHashCodeEquals()
+        {
+            OpenBitSet bs1 = new OpenBitSet(200);
+            OpenBitSet bs2 = new OpenBitSet(64);
+            bs1.Set(3);
+            bs2.Set(3);
+            Assert.AreEqual(bs1, bs2);
+            Assert.AreEqual(bs1.GetHashCode(), bs2.GetHashCode());
+        }
+
+        private OpenBitSet MakeOpenBitSet(int[] a)
+        {
+            OpenBitSet bs = new OpenBitSet();
+            foreach (int e in a)
+            {
+                bs.Set(e);
+            }
+            return bs;
+        }
+
+        private BitArray MakeBitSet(int[] a)
+        {
+            BitArray bs = new BitArray(a.Length);
+            foreach (int e in a)
+            {
+                bs.Set(e, true);
+            }
+            return bs;
+        }
+
+        private void CheckPrevSetBitArray(int[] a)
+        {
+            OpenBitSet obs = MakeOpenBitSet(a);
+            BitArray bs = MakeBitSet(a);
+            DoPrevSetBit(bs, obs);
+        }
+
+        [Test]
+        public virtual void TestPrevSetBit()
+        {
+            CheckPrevSetBitArray(new int[] { });
+            CheckPrevSetBitArray(new int[] { 0 });
+            CheckPrevSetBitArray(new int[] { 0, 2 });
+        }
+
+        [Test]
+        public virtual void TestEnsureCapacity()
+        {
+            OpenBitSet bits = new OpenBitSet(1);
+            int bit = Random().Next(100) + 10;
+            bits.EnsureCapacity(bit); // make room for more bits
+            bits.FastSet(bit - 1);
+            Assert.IsTrue(bits.FastGet(bit - 1));
+            bits.EnsureCapacity(bit + 1);
+            bits.FastSet(bit);
+            Assert.IsTrue(bits.FastGet(bit));
+            bits.EnsureCapacity(3); // should not change numBits nor grow the array
+            bits.FastSet(3);
+            Assert.IsTrue(bits.FastGet(3));
+            bits.FastSet(bit - 1);
+            Assert.IsTrue(bits.FastGet(bit - 1));
+
+            // test ensureCapacityWords
+            int numWords = Random().Next(10) + 2; // make sure we grow the array (at least 128 bits)
+            bits.EnsureCapacityWords(numWords);
+            bit = TestUtil.NextInt(Random(), 127, (numWords << 6) - 1); // pick a bit >= to 128, but still within range
+            bits.FastSet(bit);
+            Assert.IsTrue(bits.FastGet(bit));
+            bits.FastClear(bit);
+            Assert.IsFalse(bits.FastGet(bit));
+            bits.FastFlip(bit);
+            Assert.IsTrue(bits.FastGet(bit));
+            bits.EnsureCapacityWords(2); // should not change numBits nor grow the array
+            bits.FastSet(3);
+            Assert.IsTrue(bits.FastGet(3));
+            bits.FastSet(bit - 1);
+            Assert.IsTrue(bits.FastGet(bit - 1));
+        }
+    }*/
+}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/lucenenet/blob/4b4d4d93/test/Lucene.Net.Core.Tests/Util/TestWeakIdentityMap.cs
----------------------------------------------------------------------
diff --git a/test/Lucene.Net.Core.Tests/Util/TestWeakIdentityMap.cs b/test/Lucene.Net.Core.Tests/Util/TestWeakIdentityMap.cs
index ee18cac..e6bf2f0 100644
--- a/test/Lucene.Net.Core.Tests/Util/TestWeakIdentityMap.cs
+++ b/test/Lucene.Net.Core.Tests/Util/TestWeakIdentityMap.cs
@@ -31,7 +31,7 @@ namespace Lucene.Net.Util
         [Test]
         public async virtual void TestSimpleHashMap()
         {
-            var map = WeakIdentityMap<string, string>.NewHashMap(this.Random.NextBoolean());
+            var map = WeakIdentityMap<string, string>.NewHashMap(Random.NextBoolean());
             // we keep strong references to the keys,
             // so WeakIdentityMap will not forget about them:
             string key1 = "foo",
@@ -190,7 +190,7 @@ namespace Lucene.Net.Util
             // don't make threadCount and keyCount random, otherwise easily OOMs or fails otherwise:
             const int threadCount = 8, keyCount = 1024;
             var tasks = new List<Task>();
-            var map = WeakIdentityMap<object, int?>.NewConcurrentHashMap(this.Random.NextBoolean());
+            var map = WeakIdentityMap<object, int?>.NewConcurrentHashMap(Random.NextBoolean());
             // we keep strong references to the keys,
             // so WeakIdentityMap will not forget about them:
             var keys = new AtomicReferenceArray<object>(keyCount);
@@ -201,7 +201,7 @@ namespace Lucene.Net.Util
 
             for (var t = 0; t < threadCount; t++)
             {
-                var rnd = new Random(this.Random.Next());
+                var rnd = new Random(Random.Next());
                 tasks.Add(Task.Run(() =>
                 {
                        
@@ -272,7 +272,7 @@ namespace Lucene.Net.Util
             public void Run()
             {
 // ReSharper disable once InvokeAsExtensionMethod
-                var count =  this.outerInstance.AtLeast(10000);
+                var count =  AtLeast(10000);
                 for (var i = 0; i < count; i++)
                 {
                     var j = rnd.Next(keyCount);

http://git-wip-us.apache.org/repos/asf/lucenenet/blob/4b4d4d93/test/Lucene.Net.Java.Tests/Lucene.Net.Java.Tests.csproj
----------------------------------------------------------------------
diff --git a/test/Lucene.Net.Java.Tests/Lucene.Net.Java.Tests.csproj b/test/Lucene.Net.Java.Tests/Lucene.Net.Java.Tests.csproj
new file mode 100644
index 0000000..f1114ce
--- /dev/null
+++ b/test/Lucene.Net.Java.Tests/Lucene.Net.Java.Tests.csproj
@@ -0,0 +1,83 @@
+<?xml version="1.0" encoding="utf-8"?>
+<Project ToolsVersion="12.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
+  <Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')" />
+  <PropertyGroup>
+    <MinimumVisualStudioVersion>10.0</MinimumVisualStudioVersion>
+    <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
+    <Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
+    <ProjectGuid>{06FE85CA-11BA-4E69-81B4-1FA6E031E0B7}</ProjectGuid>
+    <OutputType>Library</OutputType>
+    <AppDesignerFolder>Properties</AppDesignerFolder>
+    <RootNamespace>Lucene.Net.Java</RootNamespace>
+    <AssemblyName>Lucene.Net.Java.Tests</AssemblyName>
+    <DefaultLanguage>en-US</DefaultLanguage>
+    <FileAlignment>512</FileAlignment>
+    <ProjectTypeGuids>{786C830F-07A1-408B-BD7F-6EE04809D6DB};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</ProjectTypeGuids>
+    <TargetFrameworkProfile>Profile111</TargetFrameworkProfile>
+    <TargetFrameworkVersion>v4.5</TargetFrameworkVersion>
+    <SolutionDir Condition="$(SolutionDir) == '' Or $(SolutionDir) == '*Undefined*'">..\..\</SolutionDir>
+    <RestorePackages>true</RestorePackages>
+  </PropertyGroup>
+  <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
+    <DebugSymbols>true</DebugSymbols>
+    <DebugType>full</DebugType>
+    <Optimize>false</Optimize>
+    <OutputPath>bin\Debug\</OutputPath>
+    <DefineConstants>DEBUG;TRACE</DefineConstants>
+    <ErrorReport>prompt</ErrorReport>
+    <WarningLevel>4</WarningLevel>
+  </PropertyGroup>
+  <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
+    <DebugType>pdbonly</DebugType>
+    <Optimize>true</Optimize>
+    <OutputPath>bin\Release\</OutputPath>
+    <DefineConstants>TRACE</DefineConstants>
+    <ErrorReport>prompt</ErrorReport>
+    <WarningLevel>4</WarningLevel>
+  </PropertyGroup>
+  <ItemGroup>
+    <!-- A reference to the entire .NET Framework is automatically included -->
+    <None Include="packages.config" />
+  </ItemGroup>
+  <ItemGroup>
+    <Compile Include="Properties\AssemblyInfo.cs" />
+    <Compile Include="Util\InsertionSortTests.cs" />
+    <Compile Include="Util\SortTestClass.cs" />
+  </ItemGroup>
+  <ItemGroup>
+    <Reference Include="xunit.abstractions">
+      <HintPath>..\..\packages\xunit.abstractions.2.0.0-beta-build2700\lib\portable-net45+win+wpa81+wp80+monotouch+monoandroid\xunit.abstractions.dll</HintPath>
+    </Reference>
+    <Reference Include="xunit.assert">
+      <HintPath>..\..\packages\xunit.assert.2.0.0-beta-build2700\lib\portable-net45+win+wpa81+wp80+monoandroid+monotouch10\xunit.assert.dll</HintPath>
+    </Reference>
+    <Reference Include="xunit.core">
+      <HintPath>..\..\packages\xunit.core.2.0.0-beta-build2700\lib\portable-net45+win+wpa81+wp80+monotouch+monoandroid\xunit.core.dll</HintPath>
+    </Reference>
+  </ItemGroup>
+  <ItemGroup>
+    <ProjectReference Include="..\..\src\Lucene.Net.Java\Lucene.Net.Java.csproj">
+      <Project>{4ad3fe35-aa0a-4c3c-a043-12711625df74}</Project>
+      <Name>Lucene.Net.Java</Name>
+    </ProjectReference>
+    <ProjectReference Include="..\Lucene.Net.TestFramework.Core\Lucene.Net.TestFramework.Core.csproj">
+      <Project>{438b8450-e93a-425f-9a9b-11d02e8896d5}</Project>
+      <Name>Lucene.Net.TestFramework.Core</Name>
+    </ProjectReference>
+  </ItemGroup>
+  <Import Project="$(MSBuildExtensionsPath32)\Microsoft\Portable\$(TargetFrameworkVersion)\Microsoft.Portable.CSharp.targets" />
+  <Import Project="$(SolutionDir)\.nuget\NuGet.targets" Condition="Exists('$(SolutionDir)\.nuget\NuGet.targets')" />
+  <Target Name="EnsureNuGetPackageBuildImports" BeforeTargets="PrepareForBuild">
+    <PropertyGroup>
+      <ErrorText>This project references NuGet package(s) that are missing on this computer. Enable NuGet Package Restore to download them.  For more information, see http://go.microsoft.com/fwlink/?LinkID=322105. The missing file is {0}.</ErrorText>
+    </PropertyGroup>
+    <Error Condition="!Exists('$(SolutionDir)\.nuget\NuGet.targets')" Text="$([System.String]::Format('$(ErrorText)', '$(SolutionDir)\.nuget\NuGet.targets'))" />
+  </Target>
+  <!-- To modify your build process, add your task inside one of the targets below and uncomment it. 
+       Other similar extension points exist, see Microsoft.Common.targets.
+  <Target Name="BeforeBuild">
+  </Target>
+  <Target Name="AfterBuild">
+  </Target>
+  -->
+</Project>
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/lucenenet/blob/4b4d4d93/test/Lucene.Net.Java.Tests/Properties/AssemblyInfo.cs
----------------------------------------------------------------------
diff --git a/test/Lucene.Net.Java.Tests/Properties/AssemblyInfo.cs b/test/Lucene.Net.Java.Tests/Properties/AssemblyInfo.cs
new file mode 100644
index 0000000..879cf92
--- /dev/null
+++ b/test/Lucene.Net.Java.Tests/Properties/AssemblyInfo.cs
@@ -0,0 +1,30 @@
+using System.Resources;
+using System.Reflection;
+using System.Runtime.CompilerServices;
+using System.Runtime.InteropServices;
+
+// General Information about an assembly is controlled through the following 
+// set of attributes. Change these attribute values to modify the information
+// associated with an assembly.
+[assembly: AssemblyTitle("Lucene.Net.Java.Tests")]
+[assembly: AssemblyDescription("")]
+[assembly: AssemblyConfiguration("")]
+[assembly: AssemblyCompany("")]
+[assembly: AssemblyProduct("Lucene.Net.Java.Tests")]
+[assembly: AssemblyCopyright("Copyright ©  2014")]
+[assembly: AssemblyTrademark("")]
+[assembly: AssemblyCulture("")]
+[assembly: NeutralResourcesLanguage("en")]
+
+// Version information for an assembly consists of the following four values:
+//
+//      Major Version
+//      Minor Version 
+//      Build Number
+//      Revision
+//
+// You can specify all the values or you can default the Build and Revision Numbers 
+// by using the '*' as shown below:
+// [assembly: AssemblyVersion("1.0.*")]
+[assembly: AssemblyVersion("1.0.0.0")]
+[assembly: AssemblyFileVersion("1.0.0.0")]

http://git-wip-us.apache.org/repos/asf/lucenenet/blob/4b4d4d93/test/Lucene.Net.Java.Tests/Util/InsertionSortTests.cs
----------------------------------------------------------------------
diff --git a/test/Lucene.Net.Java.Tests/Util/InsertionSortTests.cs b/test/Lucene.Net.Java.Tests/Util/InsertionSortTests.cs
new file mode 100644
index 0000000..e2e798d
--- /dev/null
+++ b/test/Lucene.Net.Java.Tests/Util/InsertionSortTests.cs
@@ -0,0 +1,71 @@
+
+namespace Lucene.Net.Java.Util
+{
+    using System;
+    using System.Collections.Generic;
+    using System.Linq;
+    using global::Java.Util;
+
+    public class InsertionSortTests : SortTestClass
+    {
+
+        [Test]
+        public void TestSort()
+        {
+            var length = Random.Next(20);
+            var array = new int[length];
+            Arrays.Fill(array, () => Random.Next());
+
+            InsertionSort.Sort(array);
+            
+            this.AssertSort(array);
+
+            Throws<ArgumentNullException>(() =>
+            {
+                int[] test = null;
+                
+                // ReSharper disable ExpressionIsAlwaysNull
+                InsertionSort.Sort(test);
+            });
+        }
+
+        [Test]
+        public void TestSortWithSlice()
+        {
+            var offset = Random.Next(5, 10);
+            var length = Random.Next(30, 35);
+            var list = new char[length];
+
+            Ok(list.Length > offset);
+            Arrays.Fill(list, () => (char) Random.Next(97, 122));
+           
+            var copy = list.ToList();
+
+            InsertionSort.Sort(list, offset, length - offset - 5);
+ 
+            this.AssertSort(list, offset, length - offset - 5);
+            
+            // ensure what was outside of the slice was not sorted
+            for (var i = 0; i < offset; i++)
+            {
+                Equal(list[i], copy[i]);
+            }
+
+            for (var i = length - 5; i < length; i++)
+            {
+                Equal(list[i], copy[i]);
+            }
+
+            var listB = new char[10];
+
+            // verify exceptions
+            Throws<ArgumentNullException>(() => InsertionSort.Sort((IList<int>)null, -1, 10));
+            Throws<ArgumentOutOfRangeException>(() => InsertionSort.Sort(listB, -1, 10));
+            Throws<ArgumentOutOfRangeException>(() => InsertionSort.Sort(listB, 0, -10));
+            Throws<ArgumentOutOfRangeException>(() => InsertionSort.Sort(listB, 10, 10));
+            Throws<ArgumentOutOfRangeException>(() => InsertionSort.Sort(listB, 0, 11));
+            Throws<ArgumentOutOfRangeException>(() => InsertionSort.Sort(listB, -9, 5));
+
+        }
+    }
+}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/lucenenet/blob/4b4d4d93/test/Lucene.Net.Java.Tests/Util/SortTestClass.cs
----------------------------------------------------------------------
diff --git a/test/Lucene.Net.Java.Tests/Util/SortTestClass.cs b/test/Lucene.Net.Java.Tests/Util/SortTestClass.cs
new file mode 100644
index 0000000..6078100
--- /dev/null
+++ b/test/Lucene.Net.Java.Tests/Util/SortTestClass.cs
@@ -0,0 +1,39 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace Lucene.Net.Java.Util
+{
+    public class SortTestClass : TestClass
+    {
+
+        protected void AssertSort<T>(IList<T> list, int start = 0, int count = -1) where T : IComparable<T>
+        {
+            if(count == -1)
+                count = list.Count;
+
+            count.Times(i =>
+            {
+                if (i < start)
+                   return;
+                
+
+                var current = list[i];
+
+                if (i > start)
+                {
+                    var previous = list[i - 1];
+                    Ok(previous.CompareTo(current) <= 0, "previous value, {0}, should be less than or equal to {1} at index {2}", previous, current, i);
+                }
+
+                if (i < (count - 2))
+                {
+                    var next = list[i + 1];
+                    Ok(next.CompareTo(current) >= 0, "next value, {0}, should be greater than or equal to {1} at index {2}", next, current, i);
+                }
+            });
+        }
+    }
+}

http://git-wip-us.apache.org/repos/asf/lucenenet/blob/4b4d4d93/test/Lucene.Net.Java.Tests/packages.config
----------------------------------------------------------------------
diff --git a/test/Lucene.Net.Java.Tests/packages.config b/test/Lucene.Net.Java.Tests/packages.config
new file mode 100644
index 0000000..b71d5c9
--- /dev/null
+++ b/test/Lucene.Net.Java.Tests/packages.config
@@ -0,0 +1,27 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!--
+
+ 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.
+
+-->
+<packages>
+  <package id="xunit" version="2.0.0-beta-build2700" targetFramework="portable-net45+win+wpa81+wp80" />
+  <package id="xunit.abstractions" version="2.0.0-beta-build2700" targetFramework="portable-net45+win+wpa81+wp80" />
+  <package id="xunit.assert" version="2.0.0-beta-build2700" targetFramework="portable-net45+win+wpa81+wp80" />
+  <package id="xunit.core" version="2.0.0-beta-build2700" targetFramework="portable-net45+win+wpa81+wp80" />
+</packages>
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/lucenenet/blob/4b4d4d93/test/Lucene.Net.Java.Tests/project.json
----------------------------------------------------------------------
diff --git a/test/Lucene.Net.Java.Tests/project.json b/test/Lucene.Net.Java.Tests/project.json
new file mode 100644
index 0000000..27f9bf3
--- /dev/null
+++ b/test/Lucene.Net.Java.Tests/project.json
@@ -0,0 +1,37 @@
+{
+    "licenses": ["apache 2.0"],
+    "version": "5.0.0.0",
+    "compilationOptions": {
+        "warningsAsErrors": false,
+        "define": ["XUNIT"]
+    },
+    "sources": ["../src"],
+    "code": "**/*.cs",
+    "commands": {
+        "test": "Xunit.KRunner"
+    },
+    
+    
+    "dependencies": {
+        "Lucene.Net.Java":  "",
+        "Lucene.Net.TestFramework.Core": "",
+        "Xunit.KRunner": "1.0.0-*",
+        "System.Console": "4.0.0.0"
+    },
+
+    "configurations" : {
+        "net451": {},
+        "net45" : { 
+            "dependencies": {
+            }
+        },
+        "k10" : { 
+            "dependencies": {
+                "System.Runtime": "4.0.20.0",
+                "System.Diagnostics.Debug": "4.0.10.0"
+              
+            }
+            
+        }
+    }
+}

http://git-wip-us.apache.org/repos/asf/lucenenet/blob/4b4d4d93/test/Lucene.Net.TestFramework.Core/CategoryAttribute.cs
----------------------------------------------------------------------
diff --git a/test/Lucene.Net.TestFramework.Core/CategoryAttribute.cs b/test/Lucene.Net.TestFramework.Core/CategoryAttribute.cs
new file mode 100644
index 0000000..ce21ef4
--- /dev/null
+++ b/test/Lucene.Net.TestFramework.Core/CategoryAttribute.cs
@@ -0,0 +1,44 @@
+
+
+
+namespace Lucene.Net
+{
+    using System;
+    using System.Collections.Generic;
+    using System.Linq;
+    using Xunit.Abstractions;
+    using Xunit.Sdk;
+
+    [TraitDiscoverer("CategoryDiscoverer", "TraitExtensibility")]
+    [AttributeUsage(AttributeTargets.Method, AllowMultiple = true)]
+    public class CategoryAttribute : System.Attribute, Xunit.Sdk.ITraitAttribute
+    {
+        public string Name { get; private set; }
+
+        public CategoryAttribute(string category)
+        {
+            this.Name = category;
+        }
+    }
+
+    /// <summary>
+    /// This class discovers all of the tests and test classes that have
+    /// applied the Category attribute
+    /// </summary>
+    public class CategoryDiscoverer : ITraitDiscoverer
+    {
+        /// <summary>
+        /// Gets the trait values from the Category attribute.
+        /// </summary>
+        /// <param name="traitAttribute">The trait attribute containing the trait values.</param>
+        /// <returns>The trait values.</returns>
+        public IEnumerable<KeyValuePair<string, string>> GetTraits(IAttributeInfo traitAttribute)
+        {
+            var ctorArgs = traitAttribute.GetConstructorArguments().ToList();
+
+            yield return new KeyValuePair<string, string>("Category", ctorArgs[0].ToString());
+           
+        }
+    }
+
+}

http://git-wip-us.apache.org/repos/asf/lucenenet/blob/4b4d4d93/test/Lucene.Net.TestFramework.Core/ExtensionMethods.cs
----------------------------------------------------------------------
diff --git a/test/Lucene.Net.TestFramework.Core/ExtensionMethods.cs b/test/Lucene.Net.TestFramework.Core/ExtensionMethods.cs
new file mode 100644
index 0000000..e4a7f95
--- /dev/null
+++ b/test/Lucene.Net.TestFramework.Core/ExtensionMethods.cs
@@ -0,0 +1,40 @@
+/*
+ * 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.
+ */
+
+namespace Lucene.Net
+{
+    using System;
+    /// <summary>
+    /// Extension methods to make writing tests easier.
+    /// </summary>
+    public static class ExtensionMethods
+    {
+        /// <summary>
+        /// Performs a loop for the specified number of times. 
+        /// </summary>
+        /// <param name="value">The number of times to perform a loop.</param>
+        /// <param name="invoke">The code that should be ivnoked for each iteration.</param>
+        public static void Times(this int value, Action<int> invoke)
+        {
+            for(var i = 0; i < value; i++)
+            {
+                invoke(i);
+            }
+        }
+
+    }
+}

http://git-wip-us.apache.org/repos/asf/lucenenet/blob/4b4d4d93/test/Lucene.Net.TestFramework.Core/Lucene.Net.TestFramework.Core.csproj
----------------------------------------------------------------------
diff --git a/test/Lucene.Net.TestFramework.Core/Lucene.Net.TestFramework.Core.csproj b/test/Lucene.Net.TestFramework.Core/Lucene.Net.TestFramework.Core.csproj
new file mode 100644
index 0000000..3e66773
--- /dev/null
+++ b/test/Lucene.Net.TestFramework.Core/Lucene.Net.TestFramework.Core.csproj
@@ -0,0 +1,71 @@
+<?xml version="1.0" encoding="utf-8"?>
+<Project ToolsVersion="12.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
+  <Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')" />
+  <PropertyGroup>
+    <MinimumVisualStudioVersion>10.0</MinimumVisualStudioVersion>
+    <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
+    <Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
+    <ProjectGuid>{438B8450-E93A-425F-9A9B-11D02E8896D5}</ProjectGuid>
+    <OutputType>Library</OutputType>
+    <AppDesignerFolder>Properties</AppDesignerFolder>
+    <RootNamespace>Lucene.Net</RootNamespace>
+    <AssemblyName>Lucene.Net.TestFramework.Core</AssemblyName>
+    <DefaultLanguage>en-US</DefaultLanguage>
+    <FileAlignment>512</FileAlignment>
+    <ProjectTypeGuids>{786C830F-07A1-408B-BD7F-6EE04809D6DB};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</ProjectTypeGuids>
+    <TargetFrameworkProfile>Profile111</TargetFrameworkProfile>
+    <TargetFrameworkVersion>v4.5</TargetFrameworkVersion>
+  </PropertyGroup>
+  <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
+    <DebugSymbols>true</DebugSymbols>
+    <DebugType>full</DebugType>
+    <Optimize>false</Optimize>
+    <OutputPath>bin\Debug\</OutputPath>
+    <DefineConstants>TRACE;DEBUG;XUNIT</DefineConstants>
+    <ErrorReport>prompt</ErrorReport>
+    <WarningLevel>4</WarningLevel>
+  </PropertyGroup>
+  <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
+    <DebugType>pdbonly</DebugType>
+    <Optimize>true</Optimize>
+    <OutputPath>bin\Release\</OutputPath>
+    <DefineConstants>TRACE</DefineConstants>
+    <ErrorReport>prompt</ErrorReport>
+    <WarningLevel>4</WarningLevel>
+  </PropertyGroup>
+  <ItemGroup>
+    <!-- A reference to the entire .NET Framework is automatically included -->
+    <None Include="packages.config" />
+  </ItemGroup>
+  <ItemGroup>
+    <Compile Include="CategoryAttribute.cs" />
+    <Compile Include="ExtensionMethods.cs" />
+    <Compile Include="NightlyAttribute.cs" />
+    <Compile Include="PerformanceAttribute.cs" />
+    <Compile Include="Properties\AssemblyInfo.cs" />
+    <Compile Include="RandomExtensions.cs" />
+    <Compile Include="Settings.cs" />
+    <Compile Include="TestAttribute.cs" />
+    <Compile Include="TestClass.cs" />
+    <Compile Include="TicketAttribute.cs" />
+  </ItemGroup>
+  <ItemGroup>
+    <Reference Include="xunit.abstractions">
+      <HintPath>..\..\packages\xunit.abstractions.2.0.0-beta-build2700\lib\portable-net45+win+wpa81+wp80+monotouch+monoandroid\xunit.abstractions.dll</HintPath>
+    </Reference>
+    <Reference Include="xunit.assert">
+      <HintPath>..\..\packages\xunit.assert.2.0.0-beta-build2700\lib\portable-net45+win+wpa81+wp80+monoandroid+monotouch10\xunit.assert.dll</HintPath>
+    </Reference>
+    <Reference Include="xunit.core">
+      <HintPath>..\..\packages\xunit.core.2.0.0-beta-build2700\lib\portable-net45+win+wpa81+wp80+monotouch+monoandroid\xunit.core.dll</HintPath>
+    </Reference>
+  </ItemGroup>
+  <Import Project="$(MSBuildExtensionsPath32)\Microsoft\Portable\$(TargetFrameworkVersion)\Microsoft.Portable.CSharp.targets" />
+  <!-- To modify your build process, add your task inside one of the targets below and uncomment it. 
+       Other similar extension points exist, see Microsoft.Common.targets.
+  <Target Name="BeforeBuild">
+  </Target>
+  <Target Name="AfterBuild">
+  </Target>
+  -->
+</Project>
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/lucenenet/blob/4b4d4d93/test/Lucene.Net.TestFramework.Core/NightlyAttribute.cs
----------------------------------------------------------------------
diff --git a/test/Lucene.Net.TestFramework.Core/NightlyAttribute.cs b/test/Lucene.Net.TestFramework.Core/NightlyAttribute.cs
new file mode 100644
index 0000000..0eba11d
--- /dev/null
+++ b/test/Lucene.Net.TestFramework.Core/NightlyAttribute.cs
@@ -0,0 +1,18 @@
+
+
+
+namespace Lucene.Net
+{
+    using System;
+
+    [AttributeUsage(AttributeTargets.Method, AllowMultiple = true)]
+    public class NightlyAttribute : CategoryAttribute
+    {
+
+        public NightlyAttribute()
+            : base("Nightly")
+        {
+
+        }
+    }
+}

http://git-wip-us.apache.org/repos/asf/lucenenet/blob/4b4d4d93/test/Lucene.Net.TestFramework.Core/PerformanceAttribute.cs
----------------------------------------------------------------------
diff --git a/test/Lucene.Net.TestFramework.Core/PerformanceAttribute.cs b/test/Lucene.Net.TestFramework.Core/PerformanceAttribute.cs
new file mode 100644
index 0000000..f854a55
--- /dev/null
+++ b/test/Lucene.Net.TestFramework.Core/PerformanceAttribute.cs
@@ -0,0 +1,17 @@
+
+
+namespace Lucene.Net
+{
+    using System;
+
+    [AttributeUsage(AttributeTargets.Method, AllowMultiple = true)]
+    public class PerformanceAttribute : CategoryAttribute
+    {
+
+        public PerformanceAttribute()
+            : base("Performance")
+        {
+
+        }
+    }
+}

http://git-wip-us.apache.org/repos/asf/lucenenet/blob/4b4d4d93/test/Lucene.Net.TestFramework.Core/Properties/AssemblyInfo.cs
----------------------------------------------------------------------
diff --git a/test/Lucene.Net.TestFramework.Core/Properties/AssemblyInfo.cs b/test/Lucene.Net.TestFramework.Core/Properties/AssemblyInfo.cs
new file mode 100644
index 0000000..d561817
--- /dev/null
+++ b/test/Lucene.Net.TestFramework.Core/Properties/AssemblyInfo.cs
@@ -0,0 +1,30 @@
+using System.Resources;
+using System.Reflection;
+using System.Runtime.CompilerServices;
+using System.Runtime.InteropServices;
+
+// General Information about an assembly is controlled through the following 
+// set of attributes. Change these attribute values to modify the information
+// associated with an assembly.
+[assembly: AssemblyTitle("Lucene.Net.TestFramework.Core")]
+[assembly: AssemblyDescription("")]
+[assembly: AssemblyConfiguration("")]
+[assembly: AssemblyCompany("")]
+[assembly: AssemblyProduct("Lucene.Net.TestFramework.Core")]
+[assembly: AssemblyCopyright("Copyright ©  2014")]
+[assembly: AssemblyTrademark("")]
+[assembly: AssemblyCulture("")]
+[assembly: NeutralResourcesLanguage("en")]
+
+// Version information for an assembly consists of the following four values:
+//
+//      Major Version
+//      Minor Version 
+//      Build Number
+//      Revision
+//
+// You can specify all the values or you can default the Build and Revision Numbers 
+// by using the '*' as shown below:
+// [assembly: AssemblyVersion("1.0.*")]
+[assembly: AssemblyVersion("1.0.0.0")]
+[assembly: AssemblyFileVersion("1.0.0.0")]

http://git-wip-us.apache.org/repos/asf/lucenenet/blob/4b4d4d93/test/Lucene.Net.TestFramework.Core/RandomExtensions.cs
----------------------------------------------------------------------
diff --git a/test/Lucene.Net.TestFramework.Core/RandomExtensions.cs b/test/Lucene.Net.TestFramework.Core/RandomExtensions.cs
new file mode 100644
index 0000000..bff600e
--- /dev/null
+++ b/test/Lucene.Net.TestFramework.Core/RandomExtensions.cs
@@ -0,0 +1,30 @@
+
+
+
+namespace Lucene.Net
+{
+    using System;
+
+    public static class RandomExtensions
+    {
+
+        public static int AtLeast(this Random random, int minimumValue)
+        {
+            minimumValue = Settings.Nightly ? (2*minimumValue) : minimumValue;
+            minimumValue = minimumValue*Settings.RandomMultiplier;
+
+            // Even with the current short number of tests,
+            // some of tests take too long to complete due to the
+            // number of loops and computations created by using
+            // high numbers with AtLeast. This is to cut
+            // down on local development test time.
+            if (!Settings.Nightly && minimumValue > 100)
+            {
+                minimumValue = 100;
+            }
+
+            var max = minimumValue + (minimumValue / 2);
+            return random.Next(minimumValue, max);
+        }
+    }
+}

http://git-wip-us.apache.org/repos/asf/lucenenet/blob/4b4d4d93/test/Lucene.Net.TestFramework.Core/Settings.cs
----------------------------------------------------------------------
diff --git a/test/Lucene.Net.TestFramework.Core/Settings.cs b/test/Lucene.Net.TestFramework.Core/Settings.cs
new file mode 100644
index 0000000..e7a3382
--- /dev/null
+++ b/test/Lucene.Net.TestFramework.Core/Settings.cs
@@ -0,0 +1,16 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace Lucene.Net
+{
+    public static class Settings
+    {
+
+        public static bool Nightly { get; set; }
+
+        public static int RandomMultiplier { get; set; }
+    }
+}

http://git-wip-us.apache.org/repos/asf/lucenenet/blob/4b4d4d93/test/Lucene.Net.TestFramework.Core/TestAttribute.cs
----------------------------------------------------------------------
diff --git a/test/Lucene.Net.TestFramework.Core/TestAttribute.cs b/test/Lucene.Net.TestFramework.Core/TestAttribute.cs
new file mode 100644
index 0000000..5f8b3c5
--- /dev/null
+++ b/test/Lucene.Net.TestFramework.Core/TestAttribute.cs
@@ -0,0 +1,30 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace Lucene.Net
+{
+    /// <summary>
+    /// Summary description for TestAttribute
+    /// </summary>
+    public class TestAttribute : Xunit.FactAttribute
+    {
+
+        public string JavaMethodName { get; set; }
+
+        public TestAttribute(string displayName, string javaMethodName = null, string skip = null)
+        {
+            
+            // ReSharper disable DoNotCallOverridableMethodsInConstructor
+            this.DisplayName = displayName;
+            this.Skip = skip;
+            this.JavaMethodName = javaMethodName;
+        }
+
+        public TestAttribute()
+        {
+        }
+    }
+}

http://git-wip-us.apache.org/repos/asf/lucenenet/blob/4b4d4d93/test/Lucene.Net.TestFramework.Core/TestClass.cs
----------------------------------------------------------------------
diff --git a/test/Lucene.Net.TestFramework.Core/TestClass.cs b/test/Lucene.Net.TestFramework.Core/TestClass.cs
new file mode 100644
index 0000000..df433a0
--- /dev/null
+++ b/test/Lucene.Net.TestFramework.Core/TestClass.cs
@@ -0,0 +1,226 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+using Xunit;
+
+namespace Lucene.Net
+{
+    using System.Diagnostics;
+    using System.Threading;
+
+    public class TestClass
+    {
+        private static readonly ThreadLocal<System.Random> random;
+
+
+        public static Random Random
+        {
+            get { return random.Value; }
+        }
+
+        static TestClass()
+        {
+            random = new ThreadLocal<System.Random>(() => 
+                new System.Random((int) DateTime.Now.Ticks & 0x0000FFFF));
+        }
+
+        public class LuceneAssertionException : Exception
+        {
+            //
+            // For guidelines regarding the creation of new exception types, see
+            //    http://msdn.microsoft.com/library/default.asp?url=/library/en-us/cpgenref/html/cpconerrorraisinghandlingguidelines.asp
+            // and
+            //    http://msdn.microsoft.com/library/default.asp?url=/library/en-us/dncscol/html/csharp07192001.asp
+            //
+
+            public LuceneAssertionException()
+            {
+            }
+
+            public LuceneAssertionException(string message) : base(message)
+            {
+            }
+
+            public LuceneAssertionException(string message, Exception inner) : base(message, inner)
+            {
+            }
+
+#if NET45
+            protected LuceneAssertionException(
+                System.Runtime.Serialization.SerializationInfo info,
+                StreamingContext context) : base(info, context)
+            {
+            }
+#endif
+        }
+
+#if XUNIT
+
+        [DebuggerHidden]
+        public static void Null(object value, string message = null, params  object[] args)
+        {
+            try
+            {
+                Assert.Null(value);
+            }
+            catch (Exception ex)
+            {
+                var msg = message ?? "The value must be null.";
+                if (args != null && args.Length > 0)
+                    msg = string.Format(msg, args);
+
+                throw new LuceneAssertionException(msg, ex);
+            }
+        }
+
+        public static void NotNull(object value, string message = null, params object[] args)
+        {
+            try
+            {
+                Assert.NotNull(value);
+            }
+            catch (Exception ex)
+            {
+                var msg = message ?? "The value must not be null.";
+                if (args != null && args.Length > 0)
+                    msg = string.Format(msg, args);
+
+                throw new LuceneAssertionException(msg, ex);
+            }
+        }
+
+        /// <summary>
+        /// Asserts that two object are the same.
+        /// </summary>
+        /// <param name="expected">The expected value.</param>
+        /// <param name="actual">The actual value.</param>
+        [DebuggerHidden]
+        public static void Same(object expected, object actual)
+        {
+            Assert.Same(expected, actual);
+        }
+
+        /// <summary>
+        /// Assert that two objects are not the same.
+        /// </summary>
+        /// <param name="expected">The expected value.</param>
+        /// <param name="actual">The actual value.</param>
+        [DebuggerHidden]
+        public static void NotSame(object expected, object actual)
+        {
+            Assert.NotSame(expected, actual);
+        }
+
+        [DebuggerHidden]
+        public static void Equal(string expected, string actual, string message = null, params object[] args)
+        {
+            try
+            {
+                Assert.Equal(expected, actual);
+            }
+            catch (Exception ex)
+            {
+                if (message == null)
+                    throw;
+
+                var msg = message;
+                if (args != null && args.Length > 0)
+                    msg = string.Format(msg, args);
+
+                throw new LuceneAssertionException(msg, ex);
+            }
+        }
+
+        [DebuggerHidden]
+        public static void Equal<T>(T expected, T actual, string message = null, params object[] args)
+        {
+            try
+            {
+                Assert.Equal(expected, actual);
+            }
+            catch (Exception ex)
+            {
+                if (message == null)
+                    throw;
+
+                var msg = message;
+                if (args != null && args.Length > 0)
+                    msg = string.Format(msg, args);
+
+                throw new LuceneAssertionException(msg, ex);
+            }
+        }
+
+        [DebuggerHidden]
+        public static void Equal<T>(IEnumerable<T> expected, IEnumerable<T> actual, string message= null, params object[] args)
+        {
+            try
+            {
+                Assert.Equal(expected, actual);
+            }
+            catch (Exception ex)
+            {
+                if (message == null)
+                    throw;
+
+                var msg = message;
+                if (args != null && args.Length > 0)
+                    msg = string.Format(msg, args);
+
+                throw new LuceneAssertionException(msg, ex);
+            }
+        }
+
+        [DebuggerHidden]
+        public static void NotEqual<T>(T expected, T actual, string message = null, params object[] args)
+        {
+            try
+            {
+                Assert.NotEqual(expected, actual);
+            }
+            catch (Exception ex)
+            {
+                if (message == null)
+                    throw;
+
+                var msg = message;
+                if (args != null && args.Length > 0)
+                    msg = string.Format(msg, args);
+
+                throw new LuceneAssertionException(msg, ex);
+            }
+           
+        }
+
+
+        [DebuggerHidden]
+        public static void Ok(bool condition, string message = null, params object[] values)
+        {
+            if (!string.IsNullOrWhiteSpace(message))
+            {
+                var exceptionMessage = message;
+
+                if(values != null && values.Length > 0)
+                {
+                    exceptionMessage = String.Format(exceptionMessage, values);
+                }
+
+                Assert.True(condition, exceptionMessage);
+            }
+            else 
+            {
+                Assert.True(condition);    
+            }
+        }
+
+        [DebuggerHidden]
+        public static T Throws<T>(Action code) where T : Exception
+        {
+            return Assert.Throws<T>(code);
+        }
+        
+        #endif
+    }
+}

http://git-wip-us.apache.org/repos/asf/lucenenet/blob/4b4d4d93/test/Lucene.Net.TestFramework.Core/TicketAttribute.cs
----------------------------------------------------------------------
diff --git a/test/Lucene.Net.TestFramework.Core/TicketAttribute.cs b/test/Lucene.Net.TestFramework.Core/TicketAttribute.cs
new file mode 100644
index 0000000..80e973b
--- /dev/null
+++ b/test/Lucene.Net.TestFramework.Core/TicketAttribute.cs
@@ -0,0 +1,52 @@
+
+
+namespace Lucene.Net
+{
+    using System;
+    using System.Collections.Generic;
+    using System.Linq;
+    using Xunit.Abstractions;
+    using Xunit.Sdk;
+
+    [TraitDiscoverer("TicketDiscoverer", "TraitExtensibility")]
+    [AttributeUsage(AttributeTargets.Method, AllowMultiple = true)]
+    public class TicketAttribute : System.Attribute, Xunit.Sdk.ITraitAttribute
+    {
+        public string Ticket { get; private set; }
+
+        public string Description { get; private set; }
+
+        public TicketAttribute(string ticket, string description)
+        {
+            this.Ticket = ticket;
+            this.Description = description;
+        }
+    }
+
+
+    /// <summary>
+    /// This class discovers all of the tests and test classes that have
+    /// applied the Category attribute
+    /// </summary>
+    public class TicketDiscoverer : ITraitDiscoverer
+    {
+        /// <summary>
+        /// Gets the trait values from the Category attribute.
+        /// </summary>
+        /// <param name="traitAttribute">The trait attribute containing the trait values.</param>
+        /// <returns>The trait values.</returns>
+        public IEnumerable<KeyValuePair<string, string>> GetTraits(IAttributeInfo traitAttribute)
+        {
+            var ctorArgs = traitAttribute.GetConstructorArguments().ToList();
+            var message = "";
+
+            if (ctorArgs.Count > 0)
+                message = ctorArgs[1].ToString();
+
+
+            yield return new KeyValuePair<string, string>("Ticket", ctorArgs[0].ToString());
+            yield return new KeyValuePair<string, string>("Ticket Description", message);
+        }
+    }
+
+}

http://git-wip-us.apache.org/repos/asf/lucenenet/blob/4b4d4d93/test/Lucene.Net.TestFramework.Core/packages.config
----------------------------------------------------------------------
diff --git a/test/Lucene.Net.TestFramework.Core/packages.config b/test/Lucene.Net.TestFramework.Core/packages.config
new file mode 100644
index 0000000..b71d5c9
--- /dev/null
+++ b/test/Lucene.Net.TestFramework.Core/packages.config
@@ -0,0 +1,27 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!--
+
+ 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.
+
+-->
+<packages>
+  <package id="xunit" version="2.0.0-beta-build2700" targetFramework="portable-net45+win+wpa81+wp80" />
+  <package id="xunit.abstractions" version="2.0.0-beta-build2700" targetFramework="portable-net45+win+wpa81+wp80" />
+  <package id="xunit.assert" version="2.0.0-beta-build2700" targetFramework="portable-net45+win+wpa81+wp80" />
+  <package id="xunit.core" version="2.0.0-beta-build2700" targetFramework="portable-net45+win+wpa81+wp80" />
+</packages>
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/lucenenet/blob/4b4d4d93/test/Lucene.Net.TestFramework.Core/project.json
----------------------------------------------------------------------
diff --git a/test/Lucene.Net.TestFramework.Core/project.json b/test/Lucene.Net.TestFramework.Core/project.json
new file mode 100644
index 0000000..a6b6ae4
--- /dev/null
+++ b/test/Lucene.Net.TestFramework.Core/project.json
@@ -0,0 +1,34 @@
+{
+    "licenses": ["apache 2.0"],
+      "version": "5.0.0.0",
+    "compilationOptions": {
+        "warningsAsErrors": false,
+        "define": ["XUNIT"]
+    },
+    "sources": ["../src"],
+    "code": "**/*.cs",
+    "commands": {
+        "test": "Xunit.KRunner"
+    },
+
+    
+    "dependencies": {
+        "Xunit.KRunner": "1.0.0-*"
+    },
+
+    "configurations" : {
+        "net451": {},
+        "net45" : { 
+            "dependencies": {
+            }
+        },
+        "k10" : { 
+            "dependencies": {
+                "System.Runtime": "4.0.20.0",
+                "System.Linq": "",
+                "System.Diagnostics.Debug": "4.0.10.0",
+                "System.Threading": ""
+            }
+        }
+    }
+}

http://git-wip-us.apache.org/repos/asf/lucenenet/blob/4b4d4d93/test/Lucene.Net.TestFramework/Lucene.Net.TestFramework.csproj
----------------------------------------------------------------------
diff --git a/test/Lucene.Net.TestFramework/Lucene.Net.TestFramework.csproj b/test/Lucene.Net.TestFramework/Lucene.Net.TestFramework.csproj
index b44dcff..2714c6f 100644
--- a/test/Lucene.Net.TestFramework/Lucene.Net.TestFramework.csproj
+++ b/test/Lucene.Net.TestFramework/Lucene.Net.TestFramework.csproj
@@ -23,7 +23,7 @@
   <Import Project="..\..\packages\xunit.core.2.0.0-beta-build2700\build\portable-net45+win+wpa81+wp80\xunit.core.props" Condition="Exists('..\..\packages\xunit.core.2.0.0-beta-build2700\build\portable-net45+win+wpa81+wp80\xunit.core.props')" />
   <Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')" />
   <PropertyGroup>
-    <MinimumVisualStudioVersion>12.0</MinimumVisualStudioVersion>
+    <MinimumVisualStudioVersion>10.0</MinimumVisualStudioVersion>
     <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
     <Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
     <ProjectGuid>{F0D68FEA-B118-43B6-B760-3FB75CDE766D}</ProjectGuid>
@@ -34,8 +34,8 @@
     <DefaultLanguage>en-US</DefaultLanguage>
     <FileAlignment>512</FileAlignment>
     <ProjectTypeGuids>{786C830F-07A1-408B-BD7F-6EE04809D6DB};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</ProjectTypeGuids>
-    <TargetFrameworkProfile>Profile151</TargetFrameworkProfile>
-    <TargetFrameworkVersion>v4.6</TargetFrameworkVersion>
+    <TargetFrameworkProfile>Profile111</TargetFrameworkProfile>
+    <TargetFrameworkVersion>v4.5</TargetFrameworkVersion>
     <SolutionDir Condition="$(SolutionDir) == '' Or $(SolutionDir) == '*Undefined*'">..\..\</SolutionDir>
     <RestorePackages>true</RestorePackages>
   </PropertyGroup>
@@ -57,12 +57,11 @@
     <WarningLevel>4</WarningLevel>
   </PropertyGroup>
   <ItemGroup>
-    <Compile Include="Util\ExtensionMethods.cs" />
+    <Compile Include="Util\BaseDocIdSetTestCase.cs" />
     <Compile Include="Properties\AssemblyInfo.cs" />
     <Compile Include="Random\RandomExtensions.cs" />
     <Compile Include="Util\LuceneTestCase.cs" />
     <Compile Include="Util\RamUsageTester.cs" />
-    <Compile Include="Util\TestAttribute.cs" />
     <Compile Include="Util\TestUtil.cs" />
   </ItemGroup>
   <ItemGroup>
@@ -77,13 +76,19 @@
     </Reference>
   </ItemGroup>
   <ItemGroup>
-    <None Include="packages.config" />
+    <None Include="packages.config">
+      <SubType>Designer</SubType>
+    </None>
   </ItemGroup>
   <ItemGroup>
     <ProjectReference Include="..\..\src\Lucene.Net.Core\Lucene.Net.Core.csproj">
       <Project>{ad8901c0-209d-4132-80aa-257dbaceecb4}</Project>
       <Name>Lucene.Net.Core</Name>
     </ProjectReference>
+    <ProjectReference Include="..\Lucene.Net.TestFramework.Core\Lucene.Net.TestFramework.Core.csproj">
+      <Project>{438b8450-e93a-425f-9a9b-11d02e8896d5}</Project>
+      <Name>Lucene.Net.TestFramework.Core</Name>
+    </ProjectReference>
   </ItemGroup>
   <Import Project="$(MSBuildExtensionsPath32)\Microsoft\Portable\$(TargetFrameworkVersion)\Microsoft.Portable.CSharp.targets" />
   <Target Name="EnsureNuGetPackageBuildImports" BeforeTargets="PrepareForBuild">

http://git-wip-us.apache.org/repos/asf/lucenenet/blob/4b4d4d93/test/Lucene.Net.TestFramework/Random/RandomExtensions.cs
----------------------------------------------------------------------
diff --git a/test/Lucene.Net.TestFramework/Random/RandomExtensions.cs b/test/Lucene.Net.TestFramework/Random/RandomExtensions.cs
index eb0112f..00cbc59 100644
--- a/test/Lucene.Net.TestFramework/Random/RandomExtensions.cs
+++ b/test/Lucene.Net.TestFramework/Random/RandomExtensions.cs
@@ -33,12 +33,7 @@ namespace Lucene.Net.Random
     {
 
 
-        public static int AtLeast(this LuceneTestCase instance, int minimumValue)
-        {
-            int min = (LuceneTestCase.TEST_NIGHTLY ? 2 * minimumValue : minimumValue) * LuceneTestCase.RANDOM_MULTIPLIER;
-            int max = min + (min / 2);
-            return instance.Random.NextBetween(min, max);
-        }
+      
 
 	    /// <summary>
 	    /// Returns an integer between the min and max value. This is compatable 

http://git-wip-us.apache.org/repos/asf/lucenenet/blob/4b4d4d93/test/Lucene.Net.TestFramework/Util/BaseDocIdSetTestCase.cs
----------------------------------------------------------------------
diff --git a/test/Lucene.Net.TestFramework/Util/BaseDocIdSetTestCase.cs b/test/Lucene.Net.TestFramework/Util/BaseDocIdSetTestCase.cs
new file mode 100644
index 0000000..0292187
--- /dev/null
+++ b/test/Lucene.Net.TestFramework/Util/BaseDocIdSetTestCase.cs
@@ -0,0 +1,226 @@
+/*
+ * 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.
+ */
+
+namespace Lucene.Net.Util
+{
+    using Lucene.Net.Random;
+    using Lucene.Net.Support;
+    using System;
+    using System.Collections;
+    using System.Diagnostics;
+    using DocIdSet = Lucene.Net.Search.DocIdSet;
+    using DocIdSetIterator = Lucene.Net.Search.DocIdSetIterator;
+
+  
+
+    /// <summary>
+    /// Base test class for <seealso cref="DocIdSet"/>s. </summary>
+    public abstract class BaseDocIdSetTestCase<T> : LuceneTestCase
+        where T : Lucene.Net.Search.DocIdSet
+    {
+        /// <summary>
+        /// Create a copy of the given <seealso cref="BitSet"/> which has <code>length</code> bits. </summary>
+        public abstract T CopyOf(BitArray bs, int length);
+
+        /// <summary>
+        /// Create a random set which has <code>numBitsSet</code> of its <code>numBits</code> bits set. </summary>
+        protected internal BitArray RandomSet(int numberOfBits, int numberOfBitsSet)
+        {
+            Debug.Assert(numberOfBitsSet <= numberOfBits);
+            BitArray set = new BitArray(numberOfBits);
+            if (numberOfBitsSet == numberOfBits)
+            {
+                set.Set(0, numberOfBits != 0); //convert int to boolean
+            }
+            else
+            {
+                for (int i = 0; i < numberOfBitsSet; ++i)
+                {
+                    while (true)
+                    {
+                        int o = Random.Next(numberOfBits);
+                        if (!set.Get(o))
+                        {
+                            set.Set(o, true);
+                            break;
+                        }
+                    }
+                }
+            }
+            return set;
+        }
+
+        /// <summary>
+        /// Same as <seealso cref="#randomSet(int, int)"/> but given a load factor. </summary>
+        protected internal BitArray RandomSet(int numBits, float percentSet)
+        {
+            return RandomSet(numBits, (int)(percentSet * numBits));
+        }
+
+        /// <summary>
+        /// Test length=0. </summary>
+        public virtual void TestNoBit()
+        {
+            BitArray bs = new BitArray(1);
+            T copy = CopyOf(bs, 0);
+            AssertEquals(0, bs, copy);
+        }
+
+        /// <summary>
+        /// Test length=1. </summary>
+        public virtual void Test1Bit()
+        {
+            BitArray bs = new BitArray(1);
+            if (Random.NextBoolean())
+            {
+                bs.Set(0, true);
+            }
+            T copy = CopyOf(bs, 1);
+            AssertEquals(1, bs, copy);
+        }
+
+        /// <summary>
+        /// Test length=2. </summary>
+        public virtual void Test2Bits()
+        {
+            BitArray bs = new BitArray(2);
+            if (Random.NextBoolean())
+            {
+                bs.Set(0, true);
+            }
+            if (Random.NextBoolean())
+            {
+                bs.Set(1, true);
+            }
+            T copy = CopyOf(bs, 2);
+            AssertEquals(2, bs, copy);
+        }
+
+        /// <summary>
+        /// Compare the content of the set against a <seealso cref="BitSet"/>. </summary>
+        public virtual void TestAgainstBitSet()
+        {
+            int numBits = Random.NextBetween(100, 1 << 20);
+            // test various random sets with various load factors
+            foreach (float percentSet in new float[] { 0f, 0.0001f, (float)Random.NextDouble() / 2, 0.9f, 1f })
+            {
+                BitArray set = RandomSet(numBits, percentSet);
+                T copy = CopyOf(set, numBits);
+                AssertEquals(numBits, set, copy);
+            }
+            // test one doc
+            BitArray set_ = new BitArray(numBits);
+            set_.Set(0, true); // 0 first
+            T copy_ = CopyOf(set_, numBits);
+            AssertEquals(numBits, set_, copy_);
+            set_.Set(0, false);
+            set_.Set(Random.Next(numBits), true);
+            copy_ = CopyOf(set_, numBits); // then random index
+            AssertEquals(numBits, set_, copy_);
+            // test regular increments
+            for (int inc = 2; inc < 1000; inc += Random.NextBetween(1, 100))
+            {
+                set_ = new BitArray(numBits);
+                for (int d = Random.Next(10); d < numBits; d += inc)
+                {
+                    set_.Set(d, true);
+                }
+                copy_ = CopyOf(set_, numBits);
+                AssertEquals(numBits, set_, copy_);
+            }
+        }
+
+        /// <summary>
+        /// Assert that the content of the <seealso cref="DocIdSet"/> is the same as the content of the <seealso cref="BitSet"/>. </summary>
+        public virtual void AssertEquals(int numBits, BitArray ds1, T ds2)
+        {
+            /*
+            // nextDoc
+            DocIdSetIterator it2 = ds2.GetIterator();
+            if (it2 == null)
+            {
+                Equal(-1, ds1.NextSetBit(0));
+            }
+            else
+            {
+                Equal(-1, it2.DocId);
+                for (int doc = ds1.NextSetBit(0); doc != -1; doc = ds1.NextSetBit(doc + 1))
+                {
+                    Equal(doc, it2.NextDoc());
+                    Equal(doc, it2.DocId);
+                }
+                Equal(DocIdSetIterator.NO_MORE_DOCS, it2.NextDoc());
+                Equal(DocIdSetIterator.NO_MORE_DOCS, it2.DocId);
+            }
+
+            // nextDoc / advance
+            it2 = ds2.GetIterator();
+            if (it2 == null)
+            {
+                Equal(-1, ds1.NextSetBit(0));
+            }
+            else
+            {
+                for (int doc = -1; doc != DocIdSetIterator.NO_MORE_DOCS; )
+                {
+                    if (Random.NextBoolean())
+                    {
+                        doc = ds1.NextSetBit(doc + 1);
+                        if (doc == -1)
+                        {
+                            doc = DocIdSetIterator.NO_MORE_DOCS;
+                        }
+                        Equal(doc, it2.NextDoc());
+                        Equal(doc, it2.DocId);
+                    }
+                    else
+                    {
+                        int target = doc + 1 + Random.Next(Random.NextBoolean() ? 64 : Math.Max(numBits / 8, 1));
+                        doc = ds1.NextSetBit(target);
+                        if (doc == -1)
+                        {
+                            doc = DocIdSetIterator.NO_MORE_DOCS;
+                        }
+                        Equal(doc, it2.Advance(target));
+                        Equal(doc, it2.DocId);
+                    }
+                }
+            }
+
+            // bits()
+            var bits = ds2.GetBits();
+            if (bits != null)
+            {
+                // test consistency between bits and iterator
+                it2 = ds2.GetIterator();
+                for (int previousDoc = -1, doc = it2.NextDoc(); ; previousDoc = doc, doc = it2.NextDoc())
+                {
+                    int max = doc == DocIdSetIterator.NO_MORE_DOCS ? bits.Length : doc;
+                    for (int i = previousDoc + 1; i < max; ++i)
+                    {
+                        Equal(false, bits[i]);
+                    }
+                    if (doc == DocIdSetIterator.NO_MORE_DOCS)
+                    {
+                        break;
+                    }
+                    Equal(true, bits[doc]);
+                }
+            }*/
+        }
+    }
+}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/lucenenet/blob/4b4d4d93/test/Lucene.Net.TestFramework/Util/ExtensionMethods.cs
----------------------------------------------------------------------
diff --git a/test/Lucene.Net.TestFramework/Util/ExtensionMethods.cs b/test/Lucene.Net.TestFramework/Util/ExtensionMethods.cs
deleted file mode 100644
index 94cac09..0000000
--- a/test/Lucene.Net.TestFramework/Util/ExtensionMethods.cs
+++ /dev/null
@@ -1,41 +0,0 @@
-/*
- * 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.
- */
-
-namespace Lucene.Net.Util
-{
-    using System;
-    using Lucene.Net.Random;
-    /// <summary>
-    /// Extension methods to make writing tests easier.
-    /// </summary>
-    public static class ExtensionMethods
-    {
-        /// <summary>
-        /// Performs a loop for the specified number of times. 
-        /// </summary>
-        /// <param name="value">The number of times to perform a loop.</param>
-        /// <param name="invoke">The code that should be ivnoked for each iteration.</param>
-        public static void Times(this int value, Action<int> invoke)
-        {
-            for(var i = 0; i < value; i++)
-            {
-                invoke(i);
-            }
-        }
-
-    }
-}


Mime
View raw message