Skip to content

Commit

Permalink
Fix compile errors because of NUnit 3.5.
Browse files Browse the repository at this point in the history
  • Loading branch information
conniey committed Jan 10, 2017
1 parent f69653a commit 40cac52
Show file tree
Hide file tree
Showing 19 changed files with 45 additions and 48 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -139,24 +139,30 @@ public override TokenStreamComponents CreateComponents(string fieldName, TextRea
/// checking the validity of constructor arguments
/// </summary>
[Test]
[ExpectedException(ExpectedException = typeof(ArgumentOutOfRangeException))]
public virtual void TestIllegalArguments()
{
new CapitalizationFilter(new MockTokenizer(new StringReader("accept only valid arguments"), MockTokenizer.WHITESPACE, false), true, null, true, null, -1, CapitalizationFilter.DEFAULT_MAX_WORD_COUNT, CapitalizationFilter.DEFAULT_MAX_TOKEN_LENGTH);
Assert.Throws<ArgumentOutOfRangeException>(() =>
{
new CapitalizationFilter(new MockTokenizer(new StringReader("accept only valid arguments"), MockTokenizer.WHITESPACE, false), true, null, true, null, -1, CapitalizationFilter.DEFAULT_MAX_WORD_COUNT, CapitalizationFilter.DEFAULT_MAX_TOKEN_LENGTH);
});
}

[Test]
[ExpectedException(ExpectedException = typeof(ArgumentOutOfRangeException))]
public virtual void TestIllegalArguments1()
{
new CapitalizationFilter(new MockTokenizer(new StringReader("accept only valid arguments"), MockTokenizer.WHITESPACE, false), true, null, true, null, 0, -10, CapitalizationFilter.DEFAULT_MAX_TOKEN_LENGTH);
Assert.Throws<ArgumentOutOfRangeException>(() =>
{
new CapitalizationFilter(new MockTokenizer(new StringReader("accept only valid arguments"), MockTokenizer.WHITESPACE, false), true, null, true, null, 0, -10, CapitalizationFilter.DEFAULT_MAX_TOKEN_LENGTH);
});
}

[Test]
[ExpectedException(ExpectedException = typeof(ArgumentOutOfRangeException))]
public virtual void TestIllegalArguments2()
{
new CapitalizationFilter(new MockTokenizer(new StringReader("accept only valid arguments"), MockTokenizer.WHITESPACE, false), true, null, true, null, 0, CapitalizationFilter.DEFAULT_MAX_WORD_COUNT, -50);
Assert.Throws<ArgumentOutOfRangeException>(() =>
{
new CapitalizationFilter(new MockTokenizer(new StringReader("accept only valid arguments"), MockTokenizer.WHITESPACE, false), true, null, true, null, 0, CapitalizationFilter.DEFAULT_MAX_WORD_COUNT, -50);
});
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -86,10 +86,11 @@ public virtual void TestRandomStrings()
/// checking the validity of constructor arguments
/// </summary>
[Test]
[ExpectedException(ExpectedException = typeof(ArgumentOutOfRangeException))]
public virtual void TestIllegalArguments()
{
new CodepointCountFilter(TEST_VERSION_CURRENT, new MockTokenizer(new StringReader("accept only valid arguments"), MockTokenizer.WHITESPACE, false), 4, 1);
Assert.Throws<ArgumentOutOfRangeException>(() => {
new CodepointCountFilter(TEST_VERSION_CURRENT, new MockTokenizer(new StringReader("accept only valid arguments"), MockTokenizer.WHITESPACE, false), 4, 1);
});
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -71,10 +71,9 @@ public override TokenStreamComponents CreateComponents(string fieldName, TextRea
/// checking the validity of constructor arguments
/// </summary>
[Test]
[ExpectedException(ExpectedException = typeof(ArgumentOutOfRangeException))]
public virtual void TestIllegalArguments()
{
new LengthFilter(TEST_VERSION_CURRENT, new MockTokenizer(new StringReader("accept only valid arguments")), -4, -1);
Assert.Throws<ArgumentOutOfRangeException>(() => new LengthFilter(TEST_VERSION_CURRENT, new MockTokenizer(new StringReader("accept only valid arguments")), -4, -1));
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -37,10 +37,9 @@ public virtual void Test()
}

[Test]
[ExpectedException(ExpectedException = typeof(ArgumentOutOfRangeException))]
public virtual void TestIllegalArguments()
{
new LimitTokenCountFilter(new MockTokenizer(new StringReader("A1 B2 C3 D4 E5 F6"), MockTokenizer.WHITESPACE, false), -1);
Assert.Throws<ArgumentOutOfRangeException>(() => new LimitTokenCountFilter(new MockTokenizer(new StringReader("A1 B2 C3 D4 E5 F6"), MockTokenizer.WHITESPACE, false), -1));
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -92,10 +92,9 @@ public virtual void TestMaxPosition3WithSynomyms()
}

[Test]
[ExpectedException(ExpectedException = typeof(ArgumentException))]
public virtual void TestIllegalArguments()
{
new LimitTokenPositionFilter(new MockTokenizer(new StringReader("one two three four five")), 0);
Assert.Throws<ArgumentException>(() => new LimitTokenPositionFilter(new MockTokenizer(new StringReader("one two three four five")), 0));
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -36,10 +36,11 @@ public virtual void TestTruncating()
}

[Test]
[ExpectedException(ExpectedException = typeof(ArgumentOutOfRangeException))]
public virtual void TestNonPositiveLength()
{
new TruncateTokenFilter(new MockTokenizer(new StringReader("length must be a positive number")), -48);
Assert.Throws<ArgumentOutOfRangeException>(() => {
new TruncateTokenFilter(new MockTokenizer(new StringReader("length must be a positive number")), -48);
});
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -51,10 +51,11 @@ public virtual void Test()
}

[Test]
[ExpectedException(ExpectedException = typeof(ArgumentOutOfRangeException))]
public virtual void TestIllegalArguments()
{
new TokenRangeSinkFilter(4, 2);
Assert.Throws<ArgumentOutOfRangeException>(() => {
new TokenRangeSinkFilter(4, 2);
});
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -73,56 +73,51 @@ public override TokenStreamComponents CreateComponents(string fieldName, TextRea
/// <summary>
/// parse a syn file with bad syntax </summary>
[Test]
[ExpectedException(ExpectedException = typeof(Exception))]
public virtual void TestInvalidDoubleMap()
{
string testFile = "a => b => c";
SolrSynonymParser parser = new SolrSynonymParser(true, true, new MockAnalyzer(Random()));
parser.Parse(new StringReader(testFile));
Assert.Throws<Exception>(() => parser.Parse(new StringReader(testFile)));
}

/// <summary>
/// parse a syn file with bad syntax </summary>
[Test]
[ExpectedException(ExpectedException = typeof(Exception))]
public virtual void TestInvalidAnalyzesToNothingOutput()
{
string testFile = "a => 1";
SolrSynonymParser parser = new SolrSynonymParser(true, true, new MockAnalyzer(Random(), MockTokenizer.SIMPLE, false));
parser.Parse(new StringReader(testFile));
Assert.Throws<Exception>(() => parser.Parse(new StringReader(testFile)));
}

/// <summary>
/// parse a syn file with bad syntax </summary>
[Test]
[ExpectedException(ExpectedException = typeof(Exception))]
public virtual void TestInvalidAnalyzesToNothingInput()
{
string testFile = "1 => a";
SolrSynonymParser parser = new SolrSynonymParser(true, true, new MockAnalyzer(Random(), MockTokenizer.SIMPLE, false));
parser.Parse(new StringReader(testFile));
Assert.Throws<Exception>(() => parser.Parse(new StringReader(testFile)));
}

/// <summary>
/// parse a syn file with bad syntax </summary>
[Test]
[ExpectedException(ExpectedException = typeof(Exception))]
public virtual void TestInvalidPositionsInput()
{
string testFile = "testola => the test";
SolrSynonymParser parser = new SolrSynonymParser(true, true, new EnglishAnalyzer(TEST_VERSION_CURRENT));
parser.Parse(new StringReader(testFile));
Assert.Throws<Exception>(() => parser.Parse(new StringReader(testFile)));
}

/// <summary>
/// parse a syn file with bad syntax </summary>
[Test]
[ExpectedException(ExpectedException = typeof(Exception))]
public virtual void TestInvalidPositionsOutput()
{
string testFile = "the test => testola";
SolrSynonymParser parser = new SolrSynonymParser(true, true, new EnglishAnalyzer(TEST_VERSION_CURRENT));
parser.Parse(new StringReader(testFile));
Assert.Throws<Exception>(() => parser.Parse(new StringReader(testFile)));
}

/// <summary>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -209,7 +209,7 @@ public bool HasContexts
}
}

[Ignore]
[Ignore("Ignored test.")]
public void TestWiki()
{
LineFileDocs lfd = new LineFileDocs(null, "/lucenedata/enwiki/enwiki-20120502-lines-1k.txt", false);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,6 @@ protected override Codec Codec
}

[Test]
[ExpectedException("System.ArgumentException")]
public virtual void TestDeletePartiallyWrittenFilesIfAbort()
{
Directory dir = NewDirectory();
Expand All @@ -72,8 +71,10 @@ public virtual void TestDeletePartiallyWrittenFilesIfAbort()

try
{
iw.AddDocument(invalidDoc);
iw.Commit();
Assert.Throws<ArgumentException>(() => {
iw.AddDocument(invalidDoc);
iw.Commit();
});
}
finally
{
Expand Down
2 changes: 1 addition & 1 deletion src/Lucene.Net.Tests/core/Index/Test2BTerms.cs
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ namespace Lucene.Net.Index
// java -server -Xmx8g -d64 -cp .:lib/junit-4.10.jar:./build/classes/test:./build/classes/test-framework:./build/classes/java -Dlucene.version=4.0-dev -Dtests.directory=MMapDirectory -DtempDir=build -ea org.junit.runner.JUnitCore Lucene.Net.Index.Test2BTerms
//
[SuppressCodecs("SimpleText", "Memory", "Direct")]
[Ignore]
[Ignore("SimpleText codec will consume very large amounts of memory.")]
[TestFixture]
public class Test2BTerms : LuceneTestCase
{
Expand Down
2 changes: 1 addition & 1 deletion src/Lucene.Net.Tests/core/Index/Test4GBStoredFields.cs
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ namespace Lucene.Net.Index
[TestFixture]
public class Test4GBStoredFields : LuceneTestCase
{
[Ignore] // LUCENENET NOTE: This was marked Nightly in Java
[Ignore("//LUCENENET NOTE: This was marked Nightly in Java")]
[Test]
public virtual void Test([ValueSource(typeof(ConcurrentMergeSchedulers), "Values")]IConcurrentMergeScheduler scheduler)
{
Expand Down
4 changes: 2 additions & 2 deletions src/Lucene.Net.Tests/core/Support/TestLurchTable.cs
Original file line number Diff line number Diff line change
Expand Up @@ -504,7 +504,7 @@ public void TestSampleValueCollection()
VerifyCollection(EqualityComparer<string>.Default, values.AsReadOnly(), dict.Values);
}

[Test, ExpectedException(typeof(ObjectDisposedException))]
[Test]
public void TestDisposed()
{
IDictionary<int, string> test = new LurchTableTest<int, string>();
Expand All @@ -513,7 +513,7 @@ public void TestDisposed()
{
disposable.Dispose();
}
test.Add(1, "");
Assert.Throws<ObjectDisposedException>(() => { test.Add(1, ""); });
}

class KeyValueEquality<TKey, TValue> : IEqualityComparer<KeyValuePair<TKey, TValue>>
Expand Down
3 changes: 1 addition & 2 deletions src/Lucene.Net.Tests/core/Util/Packed/TestPackedInts.cs
Original file line number Diff line number Diff line change
Expand Up @@ -911,8 +911,7 @@ public virtual void TestPagedMutable()
}
}

// memory hole
[Ignore]
[Ignore("// memory hole")]
[Test]
public virtual void TestPagedGrowableWriterOverflow()
{
Expand Down
3 changes: 1 addition & 2 deletions src/Lucene.Net.Tests/core/Util/StressRamUsageEstimator.cs
Original file line number Diff line number Diff line change
Expand Up @@ -46,8 +46,7 @@ public virtual Entry CreateNext(object o)
}
}

// this shows an easy stack overflow because we're counting recursively.
[Ignore]
[Ignore("// this shows an easy stack overflow because we're counting recursively.")]
[Test]
public virtual void TestChainedEstimation()
{
Expand Down
3 changes: 1 addition & 2 deletions src/Lucene.Net.Tests/core/Util/TestBytesRefHash.cs
Original file line number Diff line number Diff line change
Expand Up @@ -323,7 +323,6 @@ public virtual void TestFind()
}

[Test]
[ExpectedException(typeof(MaxBytesLengthExceededException))]
public virtual void TestLargeValue()
{
int[] sizes = { Random().Next(5), ByteBlockPool.BYTE_BLOCK_SIZE - 33 + Random().Next(31), ByteBlockPool.BYTE_BLOCK_SIZE - 1 + Random().Next(37) };
Expand All @@ -342,11 +341,11 @@ public virtual void TestLargeValue()
}
catch (MaxBytesLengthExceededException e)
{
exceptionThrown = true;
if (i < sizes.Length - 1)
{
Assert.Fail("unexpected exception at size: " + sizes[i]);
}
throw e;
}
}

Expand Down
2 changes: 1 addition & 1 deletion src/Lucene.Net.Tests/core/Util/TestPagedBytes.cs
Original file line number Diff line number Diff line change
Expand Up @@ -178,7 +178,7 @@ public virtual void TestDataInputOutput2()
}
}

[Ignore] // memory hole
[Ignore("// memory hole")]
[Test]
#if !NETSTANDARD
// LUCENENET: There is no Timeout on NUnit for .NET Core.
Expand Down
2 changes: 1 addition & 1 deletion src/Lucene.Net.Tests/core/Util/TestPriorityQueue.cs
Original file line number Diff line number Diff line change
Expand Up @@ -210,7 +210,7 @@ public int Compare(int? a, int? b)
}
}

[Ignore] // Increase heap size to run this test
[Ignore("Increase heap size to run this test")]
[Test, LuceneNetSpecific]
public static void TestMaxSizeBounds()
{
Expand Down
6 changes: 2 additions & 4 deletions src/Lucene.Net.Tests/core/Util/TestSetOnce.cs
Original file line number Diff line number Diff line change
Expand Up @@ -67,22 +67,20 @@ public virtual void TestEmptyCtor()
}

[Test]
[ExpectedException(typeof(SetOnce<int?>.AlreadySetException))]
public virtual void TestSettingCtor()
{
SetOnce<int?> set = new SetOnce<int?>(new int?(5));
Assert.AreEqual(5, (int)set.Get());
set.Set(new int?(7));
Assert.Throws<SetOnce<int?>.AlreadySetException>(() => set.Set(new int?(7)));
}

[Test]
[ExpectedException(typeof(SetOnce<int?>.AlreadySetException))]
public virtual void TestSetOnce_mem()
{
SetOnce<int?> set = new SetOnce<int?>();
set.Set(new int?(5));
Assert.AreEqual(5, (int)set.Get());
set.Set(new int?(7));
Assert.Throws<SetOnce<int?>.AlreadySetException>(() => set.Set(new int?(7)));
}

[Test]
Expand Down

0 comments on commit 40cac52

Please sign in to comment.