lucenenet-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From synhers...@apache.org
Subject [2/3] lucenenet git commit: Fixing some more tests by asserting on the right things
Date Wed, 07 Jan 2015 01:23:09 GMT
Fixing some more tests by asserting on the right things

I've extended the test framework to support Java style asserts, and will bring more as needed.
This will help porting tests in the future (less style changes), abstract away the testing
framework, and most importantly make sure we don't assert differently than in the Java world


Project: http://git-wip-us.apache.org/repos/asf/lucenenet/repo
Commit: http://git-wip-us.apache.org/repos/asf/lucenenet/commit/c9426e74
Tree: http://git-wip-us.apache.org/repos/asf/lucenenet/tree/c9426e74
Diff: http://git-wip-us.apache.org/repos/asf/lucenenet/diff/c9426e74

Branch: refs/heads/master
Commit: c9426e746c41c2498df6616753236c6899034d65
Parents: f79148c
Author: Itamar Syn-Hershko <itamar@code972.com>
Authored: Wed Jan 7 03:22:47 2015 +0200
Committer: Itamar Syn-Hershko <itamar@code972.com>
Committed: Wed Jan 7 03:22:47 2015 +0200

----------------------------------------------------------------------
 .../Index/BaseDocValuesFormatTestCase.cs              |  4 ++--
 .../Index/BaseIndexFileFormatTestCase.cs              |  2 +-
 .../JavaCompatibility/LuceneTestCase.cs               | 14 +++++++++++---
 src/Lucene.Net.TestFramework/Util/LuceneTestCase.cs   |  2 +-
 4 files changed, 15 insertions(+), 7 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/lucenenet/blob/c9426e74/src/Lucene.Net.TestFramework/Index/BaseDocValuesFormatTestCase.cs
----------------------------------------------------------------------
diff --git a/src/Lucene.Net.TestFramework/Index/BaseDocValuesFormatTestCase.cs b/src/Lucene.Net.TestFramework/Index/BaseDocValuesFormatTestCase.cs
index 4e940ee..970805c 100644
--- a/src/Lucene.Net.TestFramework/Index/BaseDocValuesFormatTestCase.cs
+++ b/src/Lucene.Net.TestFramework/Index/BaseDocValuesFormatTestCase.cs
@@ -1477,12 +1477,12 @@ namespace Lucene.Net.Index
 
             // compare
             DirectoryReader ir = DirectoryReader.Open(dir);
-            foreach (AtomicReaderContext context in ir.Leaves)
+            foreach (var context in ir.Leaves)
             {
                 AtomicReader r = context.AtomicReader;
                 Bits expected = FieldCache.DEFAULT.GetDocsWithField(r, "indexed");
                 Bits actual = FieldCache.DEFAULT.GetDocsWithField(r, "dv");
-                Assert.AreEqual(expected, actual);
+                AssertEquals(expected, actual);
             }
             ir.Dispose();
             dir.Dispose();

http://git-wip-us.apache.org/repos/asf/lucenenet/blob/c9426e74/src/Lucene.Net.TestFramework/Index/BaseIndexFileFormatTestCase.cs
----------------------------------------------------------------------
diff --git a/src/Lucene.Net.TestFramework/Index/BaseIndexFileFormatTestCase.cs b/src/Lucene.Net.TestFramework/Index/BaseIndexFileFormatTestCase.cs
index 67e606c..2ce7711 100644
--- a/src/Lucene.Net.TestFramework/Index/BaseIndexFileFormatTestCase.cs
+++ b/src/Lucene.Net.TestFramework/Index/BaseIndexFileFormatTestCase.cs
@@ -120,7 +120,7 @@ namespace Lucene.Net.Index
             w.Commit();
             w.Dispose();
 
-            Assert.AreEqual(BytesUsedByExtension(dir), BytesUsedByExtension(dir2));
+            assertEquals(BytesUsedByExtension(dir), BytesUsedByExtension(dir2));
 
             reader.Dispose();
             dir.Dispose();

http://git-wip-us.apache.org/repos/asf/lucenenet/blob/c9426e74/src/Lucene.Net.TestFramework/JavaCompatibility/LuceneTestCase.cs
----------------------------------------------------------------------
diff --git a/src/Lucene.Net.TestFramework/JavaCompatibility/LuceneTestCase.cs b/src/Lucene.Net.TestFramework/JavaCompatibility/LuceneTestCase.cs
index b2c23f5..9f8c484 100644
--- a/src/Lucene.Net.TestFramework/JavaCompatibility/LuceneTestCase.cs
+++ b/src/Lucene.Net.TestFramework/JavaCompatibility/LuceneTestCase.cs
@@ -1,9 +1,8 @@
-´╗┐using System;
-using System.Collections;
+´╗┐using System.Collections;
 using System.Collections.Generic;
 using NUnit.Framework;
 
-namespace Lucene.Net
+namespace Lucene.Net.Util
 {
     public abstract partial class LuceneTestCase
     {
@@ -57,6 +56,15 @@ namespace Lucene.Net
             Assert.True(expected.SetEquals(actual), message);
         }
 
+        public static void assertEquals<T, S>(IDictionary<T, S> expected, IDictionary<T,
S> actual)
+        {
+            Assert.AreEqual(expected.Count, actual.Count);
+            foreach (var key in expected.Keys)
+            {
+                Assert.AreEqual(expected[key], actual[key]);
+            }
+        }
+
         public static void assertNotSame(object unexpected, object actual)
         {
             Assert.AreNotSame(unexpected, actual);

http://git-wip-us.apache.org/repos/asf/lucenenet/blob/c9426e74/src/Lucene.Net.TestFramework/Util/LuceneTestCase.cs
----------------------------------------------------------------------
diff --git a/src/Lucene.Net.TestFramework/Util/LuceneTestCase.cs b/src/Lucene.Net.TestFramework/Util/LuceneTestCase.cs
index 66bf0ca..564b30a 100644
--- a/src/Lucene.Net.TestFramework/Util/LuceneTestCase.cs
+++ b/src/Lucene.Net.TestFramework/Util/LuceneTestCase.cs
@@ -190,7 +190,7 @@ namespace Lucene.Net.Util
     /// </ul>
     /// </summary>
     [TestFixture]
-    public abstract class LuceneTestCase : Assert // Wait long for leaked threads to complete
before failure. zk needs this. -  See LUCENE-3995 for rationale.
+    public abstract partial class LuceneTestCase : Assert // Wait long for leaked threads
to complete before failure. zk needs this. -  See LUCENE-3995 for rationale.
     {
         public static System.IO.FileInfo TEMP_DIR;
 


Mime
View raw message