lucenenet-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ccurr...@apache.org
Subject svn commit: r1326749 [2/2] - in /incubator/lucene.net/trunk: src/core/Index/ src/core/Store/ test/contrib/Analyzers/Ru/ test/contrib/FastVectorHighlighter/ test/contrib/SpellChecker/Test/ test/core/Analysis/ test/core/Document/ test/core/Index/ test/co...
Date Mon, 16 Apr 2012 19:11:51 GMT
Modified: incubator/lucene.net/trunk/test/core/QueryParser/TestMultiFieldQueryParser.cs
URL: http://svn.apache.org/viewvc/incubator/lucene.net/trunk/test/core/QueryParser/TestMultiFieldQueryParser.cs?rev=1326749&r1=1326748&r2=1326749&view=diff
==============================================================================
--- incubator/lucene.net/trunk/test/core/QueryParser/TestMultiFieldQueryParser.cs (original)
+++ incubator/lucene.net/trunk/test/core/QueryParser/TestMultiFieldQueryParser.cs Mon Apr
16 19:11:49 2012
@@ -58,9 +58,9 @@ namespace Lucene.Net.QueryParsers
 		}
 		
 		// verify parsing of query using a stopping analyzer  
-		private void  AssertStopQueryEquals(System.String qtxt, System.String expectedRes)
+		private void  AssertStopQueryEquals(string qtxt, string expectedRes)
 		{
-			System.String[] fields = new System.String[]{"b", "t"};
+			string[] fields = new string[]{"b", "t"};
 			Occur[] occur = new Occur[]{Occur.SHOULD, Occur.SHOULD};
 			TestQueryParser.QPTestAnalyzer a = new TestQueryParser.QPTestAnalyzer();
 			MultiFieldQueryParser mfqp = new MultiFieldQueryParser(Util.Version.LUCENE_CURRENT, fields,
a);
@@ -75,7 +75,7 @@ namespace Lucene.Net.QueryParsers
 		[Test]
 		public virtual void  TestSimple()
 		{
-			System.String[] fields = new System.String[]{"b", "t"};
+			string[] fields = new string[]{"b", "t"};
 			MultiFieldQueryParser mfqp = new MultiFieldQueryParser(Util.Version.LUCENE_CURRENT, fields,
new StandardAnalyzer(Util.Version.LUCENE_CURRENT));
 			
 			Query q = mfqp.Parse("one");
@@ -139,7 +139,7 @@ namespace Lucene.Net.QueryParsers
 			IDictionary<string, float> boosts = new Dictionary<string,float>();
 			boosts["b"] = (float) 5;
 			boosts["t"] = (float) 10;
-			System.String[] fields = new System.String[]{"b", "t"};
+			string[] fields = new string[]{"b", "t"};
             MultiFieldQueryParser mfqp = new MultiFieldQueryParser(Util.Version.LUCENE_CURRENT,
fields, new StandardAnalyzer(Util.Version.LUCENE_CURRENT), boosts);
 			
 			
@@ -166,42 +166,35 @@ namespace Lucene.Net.QueryParsers
 		[Test]
 		public virtual void  TestStaticMethod1()
 		{
-			System.String[] fields = new System.String[]{"b", "t"};
-			System.String[] queries = new System.String[]{"one", "two"};
+			var fields = new []{"b", "t"};
+            var queries = new [] { "one", "two" };
             Query q = MultiFieldQueryParser.Parse(Util.Version.LUCENE_CURRENT, queries, fields,
new StandardAnalyzer(Util.Version.LUCENE_CURRENT));
 			Assert.AreEqual("b:one t:two", q.ToString());
-			
-			System.String[] queries2 = new System.String[]{"+one", "+two"};
+
+            var queries2 = new [] { "+one", "+two" };
             q = MultiFieldQueryParser.Parse(Util.Version.LUCENE_CURRENT, queries2, fields,
new StandardAnalyzer(Util.Version.LUCENE_CURRENT));
 			Assert.AreEqual("(+b:one) (+t:two)", q.ToString());
-			
-			System.String[] queries3 = new System.String[]{"one", "+two"};
+
+            var queries3 = new [] { "one", "+two" };
             q = MultiFieldQueryParser.Parse(Util.Version.LUCENE_CURRENT, queries3, fields,
new StandardAnalyzer(Util.Version.LUCENE_CURRENT));
 			Assert.AreEqual("b:one (+t:two)", q.ToString());
-			
-			System.String[] queries4 = new System.String[]{"one +more", "+two"};
+
+            var queries4 = new [] { "one +more", "+two" };
             q = MultiFieldQueryParser.Parse(Util.Version.LUCENE_CURRENT, queries4, fields,
new StandardAnalyzer(Util.Version.LUCENE_CURRENT));
 			Assert.AreEqual("(b:one +b:more) (+t:two)", q.ToString());
-			
-			System.String[] queries5 = new System.String[]{"blah"};
-			try
-			{
-                q = MultiFieldQueryParser.Parse(Util.Version.LUCENE_CURRENT, queries5, fields,
new StandardAnalyzer(Util.Version.LUCENE_CURRENT));
-				Assert.Fail();
-			}
-			catch (System.ArgumentException e)
-			{
-				// expected exception, array length differs
-			}
+
+            var queries5 = new [] { "blah" };
+		    Assert.Throws<ArgumentException>(() => MultiFieldQueryParser.Parse(Util.Version.LUCENE_CURRENT,
queries5, fields,
+		                                                                 new StandardAnalyzer(Util.Version.LUCENE_CURRENT)));
 			
 			// check also with stop words for this static form (qtxts[], fields[]).
-			TestQueryParser.QPTestAnalyzer stopA = new TestQueryParser.QPTestAnalyzer();
-			
-			System.String[] queries6 = new System.String[]{"((+stop))", "+((stop))"};
+            var stopA = new TestQueryParser.QPTestAnalyzer();
+
+            var queries6 = new [] { "((+stop))", "+((stop))" };
             q = MultiFieldQueryParser.Parse(Util.Version.LUCENE_CURRENT, queries6, fields,
stopA);
 			Assert.AreEqual("", q.ToString());
-			
-			System.String[] queries7 = new System.String[]{"one ((+stop)) +more", "+((stop)) +two"};
+
+            var queries7 = new [] { "one ((+stop)) +more", "+((stop)) +two" };
             q = MultiFieldQueryParser.Parse(Util.Version.LUCENE_CURRENT, queries7, fields,
stopA);
 			Assert.AreEqual("(b:one +b:more) (+t:two)", q.ToString());
 		}
@@ -209,33 +202,28 @@ namespace Lucene.Net.QueryParsers
 		[Test]
 		public virtual void  TestStaticMethod2()
 		{
-			System.String[] fields = new System.String[]{"b", "t"};
-			Occur[] flags = new Occur[]{Occur.MUST, Occur.MUST_NOT};
+			string[] fields = new []{"b", "t"};
+			Occur[] flags = new []{Occur.MUST, Occur.MUST_NOT};
 			Query q = MultiFieldQueryParser.Parse(Util.Version.LUCENE_CURRENT, "one", fields, flags,
new StandardAnalyzer(Util.Version.LUCENE_CURRENT));
 			Assert.AreEqual("+b:one -t:one", q.ToString());
 			
 			q = MultiFieldQueryParser.Parse(Util.Version.LUCENE_CURRENT, "one two", fields, flags,
new StandardAnalyzer(Util.Version.LUCENE_CURRENT));
 			Assert.AreEqual("+(b:one b:two) -(t:one t:two)", q.ToString());
 			
-			try
-			{
-				Occur[] flags2 = new Occur[]{Occur.MUST};
-				q = MultiFieldQueryParser.Parse(Util.Version.LUCENE_CURRENT, "blah", fields, flags2,
new StandardAnalyzer(Util.Version.LUCENE_CURRENT));
-				Assert.Fail();
-			}
-			catch (System.ArgumentException e)
-			{
-				// expected exception, array length differs
-			}
+			Occur[] flags2 = new []{Occur.MUST};
+			Assert.Throws<ArgumentException>(
+			    () =>
+			    MultiFieldQueryParser.Parse(Util.Version.LUCENE_CURRENT, "blah", fields, flags2,
+			                                new StandardAnalyzer(Util.Version.LUCENE_CURRENT)));
 		}
 		
 		[Test]
 		public virtual void  TestStaticMethod2Old()
 		{
-			System.String[] fields = new System.String[]{"b", "t"};
+            var fields = new[] { "b", "t" };
 			//int[] flags = {MultiFieldQueryParser.REQUIRED_FIELD, MultiFieldQueryParser.PROHIBITED_FIELD};
-			Occur[] flags = new Occur[]{Occur.MUST, Occur.MUST_NOT};
-            MultiFieldQueryParser parser = new MultiFieldQueryParser(Util.Version.LUCENE_CURRENT,
fields, new StandardAnalyzer(Util.Version.LUCENE_CURRENT));
+            var flags = new[] { Occur.MUST, Occur.MUST_NOT };
+            var parser = new MultiFieldQueryParser(Util.Version.LUCENE_CURRENT, fields, new
StandardAnalyzer(Util.Version.LUCENE_CURRENT));
 			
 			Query q = MultiFieldQueryParser.Parse(Util.Version.LUCENE_CURRENT, "one", fields, flags,
new StandardAnalyzer(Util.Version.LUCENE_CURRENT)); //, fields, flags, new StandardAnalyzer(Util.Version.LUCENE_CURRENT));
 			Assert.AreEqual("+b:one -t:one", q.ToString());
@@ -243,66 +231,51 @@ namespace Lucene.Net.QueryParsers
 			q = MultiFieldQueryParser.Parse(Util.Version.LUCENE_CURRENT, "one two", fields, flags,
new StandardAnalyzer(Util.Version.LUCENE_CURRENT));
 			Assert.AreEqual("+(b:one b:two) -(t:one t:two)", q.ToString());
 			
-			try
-			{
-				Occur[] flags2 = new Occur[]{Occur.MUST};
-				q = MultiFieldQueryParser.Parse(Util.Version.LUCENE_CURRENT, "blah", fields, flags2,
new StandardAnalyzer(Util.Version.LUCENE_CURRENT));
-				Assert.Fail();
-			}
-			catch (System.ArgumentException e)
-			{
-				// expected exception, array length differs
-			}
+			var flags2 = new []{Occur.MUST};
+			Assert.Throws<ArgumentException>(
+			    () =>
+			    MultiFieldQueryParser.Parse(Util.Version.LUCENE_CURRENT, "blah", fields, flags2,
+			                                new StandardAnalyzer(Util.Version.LUCENE_CURRENT)));
 		}
 		
 		[Test]
 		public virtual void  TestStaticMethod3()
 		{
-			System.String[] queries = new System.String[]{"one", "two", "three"};
-			System.String[] fields = new System.String[]{"f1", "f2", "f3"};
-			Occur[] flags = new Occur[]{Occur.MUST, Occur.MUST_NOT, Occur.SHOULD};
-            Query q = MultiFieldQueryParser.Parse(Util.Version.LUCENE_CURRENT, queries, fields,
flags, new StandardAnalyzer(Util.Version.LUCENE_CURRENT));
+            var queries = new [] { "one", "two", "three" };
+            var fields = new [] { "f1", "f2", "f3" };
+            var flags = new [] { Occur.MUST, Occur.MUST_NOT, Occur.SHOULD };
+            var q = MultiFieldQueryParser.Parse(Util.Version.LUCENE_CURRENT, queries, fields,
flags, new StandardAnalyzer(Util.Version.LUCENE_CURRENT));
 			Assert.AreEqual("+f1:one -f2:two f3:three", q.ToString());
 			
-			try
-			{
-				Occur[] flags2 = new Occur[]{Occur.MUST};
-                q = MultiFieldQueryParser.Parse(Util.Version.LUCENE_CURRENT, queries, fields,
flags2, new StandardAnalyzer(Util.Version.LUCENE_CURRENT));
-				Assert.Fail();
-			}
-			catch (System.ArgumentException e)
-			{
-				// expected exception, array length differs
-			}
+            var flags2 = new[] { Occur.MUST };
+			Assert.Throws<ArgumentException>(
+			    () =>
+			    MultiFieldQueryParser.Parse(Util.Version.LUCENE_CURRENT, queries, fields, flags2,
+			                                new StandardAnalyzer(Util.Version.LUCENE_CURRENT)));
 		}
 		
 		[Test]
 		public virtual void  TestStaticMethod3Old()
 		{
-			System.String[] queries = new System.String[]{"one", "two"};
-			System.String[] fields = new System.String[]{"b", "t"};
-			Occur[] flags = new Occur[]{Occur.MUST, Occur.MUST_NOT};
-            Query q = MultiFieldQueryParser.Parse(Util.Version.LUCENE_CURRENT, queries, fields,
flags, new StandardAnalyzer(Util.Version.LUCENE_CURRENT));
+            var queries = new [] { "one", "two" };
+            var fields = new [] { "b", "t" };
+            var flags = new [] { Occur.MUST, Occur.MUST_NOT };
+            var q = MultiFieldQueryParser.Parse(Util.Version.LUCENE_CURRENT, queries, fields,
flags, new StandardAnalyzer(Util.Version.LUCENE_CURRENT));
 			Assert.AreEqual("+b:one -t:two", q.ToString());
 			
-			try
-			{
-				Occur[] flags2 = new Occur[]{Occur.MUST};
-                q = MultiFieldQueryParser.Parse(Util.Version.LUCENE_CURRENT, queries, fields,
flags2, new StandardAnalyzer(Util.Version.LUCENE_CURRENT));
-				Assert.Fail();
-			}
-			catch (System.ArgumentException e)
-			{
-				// expected exception, array length differs
-			}
+			var flags2 = new []{Occur.MUST};
+			Assert.Throws<ArgumentException>(
+			    () =>
+			    MultiFieldQueryParser.Parse(Util.Version.LUCENE_CURRENT, queries, fields, flags2,
+			                                new StandardAnalyzer(Util.Version.LUCENE_CURRENT)));
 		}
 		
 		[Test]
 		public virtual void  TestAnalyzerReturningNull()
 		{
-			System.String[] fields = new System.String[]{"f1", "f2", "f3"};
-            MultiFieldQueryParser parser = new MultiFieldQueryParser(Util.Version.LUCENE_CURRENT,
fields, new AnalyzerReturningNull());
-			Query q = parser.Parse("bla AND blo");
+			var fields = new string[]{"f1", "f2", "f3"};
+            var parser = new MultiFieldQueryParser(Util.Version.LUCENE_CURRENT, fields, new
AnalyzerReturningNull());
+			var q = parser.Parse("bla AND blo");
 			Assert.AreEqual("+(f2:bla f3:bla) +(f2:blo f3:blo)", q.ToString());
 			// the following queries are not affected as their terms are not analyzed anyway:
 			q = parser.Parse("bla*");
@@ -318,17 +291,17 @@ namespace Lucene.Net.QueryParsers
 		{
 			Analyzer analyzer = new StandardAnalyzer(Util.Version.LUCENE_CURRENT);
 			Directory ramDir = new RAMDirectory();
-			IndexWriter iw = new IndexWriter(ramDir, analyzer, true, IndexWriter.MaxFieldLength.LIMITED);
-			Document doc = new Document();
+			var iw = new IndexWriter(ramDir, analyzer, true, IndexWriter.MaxFieldLength.LIMITED);
+            var doc = new Document();
 			doc.Add(new Field("body", "blah the footest blah", Field.Store.NO, Field.Index.ANALYZED));
 			iw.AddDocument(doc);
 			iw.Close();
-			
-			MultiFieldQueryParser mfqp = new MultiFieldQueryParser(Util.Version.LUCENE_CURRENT, new
[]{"body"}, analyzer);
+
+            var mfqp = new MultiFieldQueryParser(Util.Version.LUCENE_CURRENT, new[] { "body"
}, analyzer);
 			mfqp.DefaultOperator = QueryParser.Operator.AND;
-			Query q = mfqp.Parse("the footest");
-			IndexSearcher is_Renamed = new IndexSearcher(ramDir, true);
-			ScoreDoc[] hits = is_Renamed.Search(q, null, 1000).ScoreDocs;
+            var q = mfqp.Parse("the footest");
+            var is_Renamed = new IndexSearcher(ramDir, true);
+            var hits = is_Renamed.Search(q, null, 1000).ScoreDocs;
 			Assert.AreEqual(1, hits.Length);
 			is_Renamed.Close();
 		}
@@ -342,7 +315,7 @@ namespace Lucene.Net.QueryParsers
 			{
 			}
 			
-			public override TokenStream TokenStream(System.String fieldName, System.IO.TextReader
reader)
+			public override TokenStream TokenStream(string fieldName, System.IO.TextReader reader)
 			{
 				if ("f1".Equals(fieldName))
 				{

Modified: incubator/lucene.net/trunk/test/core/QueryParser/TestQueryParser.cs
URL: http://svn.apache.org/viewvc/incubator/lucene.net/trunk/test/core/QueryParser/TestQueryParser.cs?rev=1326749&r1=1326748&r2=1326749&view=diff
==============================================================================
--- incubator/lucene.net/trunk/test/core/QueryParser/TestQueryParser.cs (original)
+++ incubator/lucene.net/trunk/test/core/QueryParser/TestQueryParser.cs Mon Apr 16 19:11:49
2012
@@ -227,30 +227,21 @@ namespace Lucene.Net.QueryParsers
 		public virtual void  AssertQueryEquals(System.String query, Analyzer a, System.String result)
 		{
 			Query q = GetQuery(query, a);
-			System.String s = q.ToString("field");
-			if (!s.Equals(result))
-			{
-				Assert.Fail("Query /" + query + "/ yielded /" + s + "/, expecting /" + result + "/");
-			}
+			var s = q.ToString("field");
+            Assert.AreEqual(s, result, "Query /" + query + "/ yielded /" + s + "/, expecting
/" + result + "/");
 		}
 		
 		public virtual void  AssertQueryEquals(QueryParser qp, System.String field, System.String
query, System.String result)
 		{
 			Query q = qp.Parse(query);
-			System.String s = q.ToString(field);
-			if (!s.Equals(result))
-			{
-				Assert.Fail("Query /" + query + "/ yielded /" + s + "/, expecting /" + result + "/");
-			}
+            System.String s = q.ToString(field);
+            Assert.AreEqual(s, result, "Query /" + query + "/ yielded /" + s + "/, expecting
/" + result + "/");
 		}
 		
 		public virtual void  AssertEscapedQueryEquals(System.String query, Analyzer a, System.String
result)
 		{
-			System.String escapedQuery = QueryParser.Escape(query);
-			if (!escapedQuery.Equals(result))
-			{
-				Assert.Fail("Query /" + query + "/ yielded /" + escapedQuery + "/, expecting /" + result
+ "/");
-			}
+            System.String escapedQuery = QueryParser.Escape(query);
+            Assert.AreEqual(escapedQuery, result, "Query /" + query + "/ yielded /" + escapedQuery
+ "/, expecting /" + result + "/");
 		}
 		
 		public virtual void  AssertWildcardQueryEquals(System.String query, bool lowercase, System.String
result, bool allowLeadingWildcard)
@@ -259,11 +250,8 @@ namespace Lucene.Net.QueryParsers
 			qp.LowercaseExpandedTerms = lowercase;
 			qp.AllowLeadingWildcard = allowLeadingWildcard;
 			Query q = qp.Parse(query);
-			System.String s = q.ToString("field");
-			if (!s.Equals(result))
-			{
-				Assert.Fail("WildcardQuery /" + query + "/ yielded /" + s + "/, expecting /" + result
+ "/");
-			}
+            System.String s = q.ToString("field");
+            Assert.AreEqual(s, result, "WildcardQuery /" + query + "/ yielded /" + s + "/,
expecting /" + result + "/");
 		}
 		
 		public virtual void  AssertWildcardQueryEquals(System.String query, bool lowercase, System.String
result)
@@ -275,11 +263,8 @@ namespace Lucene.Net.QueryParsers
 		{
 			QueryParser qp = GetParser(null);
 			Query q = qp.Parse(query);
-			System.String s = q.ToString("field");
-			if (!s.Equals(result))
-			{
-				Assert.Fail("WildcardQuery /" + query + "/ yielded /" + s + "/, expecting /" + result
+ "/");
-			}
+            System.String s = q.ToString("field");
+            Assert.AreEqual(s, result, "WildcardQuery /" + query + "/ yielded /" + s + "/,
expecting /" + result + "/");
 		}
 		
 		public virtual Query GetQueryDOA(System.String query, Analyzer a)
@@ -294,11 +279,8 @@ namespace Lucene.Net.QueryParsers
 		public virtual void  AssertQueryEqualsDOA(System.String query, Analyzer a, System.String
result)
 		{
 			Query q = GetQueryDOA(query, a);
-			System.String s = q.ToString("field");
-			if (!s.Equals(result))
-			{
-				Assert.Fail("Query /" + query + "/ yielded /" + s + "/, expecting /" + result + "/");
-			}
+            System.String s = q.ToString("field");
+            Assert.AreEqual(s, result, "Query /" + query + "/ yielded /" + s + "/, expecting
/" + result + "/");
 		}
 		
 		[Test]
@@ -476,25 +458,11 @@ namespace Lucene.Net.QueryParsers
 			AssertWildcardQueryEquals("[A TO C]", "[a TO c]");
 			AssertWildcardQueryEquals("[A TO C]", true, "[a TO c]");
 			AssertWildcardQueryEquals("[A TO C]", false, "[A TO C]");
+
 			// Test suffix queries: first disallow
-			try
-			{
-				AssertWildcardQueryEquals("*Term", true, "*term");
-				Assert.Fail();
-			}
-			catch (ParseException pe)
-			{
-				// expected exception
-			}
-			try
-			{
-				AssertWildcardQueryEquals("?Term", true, "?term");
-				Assert.Fail();
-			}
-			catch (ParseException pe)
-			{
-				// expected exception
-			}
+            Assert.Throws<ParseException>(() => AssertWildcardQueryEquals("*Term",
true, "*term"));
+		    Assert.Throws<ParseException>(() => AssertWildcardQueryEquals("?Term", true,
"?term"));
+
 			// Test suffix queries: then allow
 			AssertWildcardQueryEquals("*Term", true, "*term", true);
 			AssertWildcardQueryEquals("?Term", true, "?term", true);
@@ -914,15 +882,7 @@ namespace Lucene.Net.QueryParsers
 		
 		public virtual void  AssertParseException(System.String queryString)
 		{
-			try
-			{
-				GetQuery(queryString, null);
-			}
-			catch (ParseException expected)
-			{
-				return ;
-			}
-			Assert.Fail("ParseException expected, not thrown");
+		    Assert.Throws<ParseException>(() => GetQuery(queryString, null), "ParseException
expected, not thrown");
 		}
 		
 		[Test]
@@ -940,45 +900,24 @@ namespace Lucene.Net.QueryParsers
 		[Test]
 		public virtual void  TestCustomQueryParserWildcard()
 		{
-			try
-			{
-				new QPTestParser("contents", new WhitespaceAnalyzer()).Parse("a?t");
-				Assert.Fail("Wildcard queries should not be allowed");
-			}
-			catch (ParseException expected)
-			{
-				// expected exception
-			}
+		    Assert.Throws<ParseException>(() => new QPTestParser("contents", new WhitespaceAnalyzer()).Parse("a?t"),
+		                                  "Wildcard queries should not be allowed");
 		}
 		
 		[Test]
 		public virtual void  TestCustomQueryParserFuzzy()
 		{
-			try
-			{
-				new QPTestParser("contents", new WhitespaceAnalyzer()).Parse("xunit~");
-				Assert.Fail("Fuzzy queries should not be allowed");
-			}
-			catch (ParseException expected)
-			{
-				// expected exception
-			}
+		    Assert.Throws<ParseException>(() => new QPTestParser("contents", new WhitespaceAnalyzer()).Parse("xunit~"),
+		                                  "Fuzzy queries should not be allowed");
 		}
 		
 		[Test]
 		public virtual void  TestBooleanQuery()
 		{
 			BooleanQuery.MaxClauseCount = 2;
-			try
-			{
-                QueryParser qp = new QueryParser(Version.LUCENE_CURRENT, "field", new WhitespaceAnalyzer());
-				qp.Parse("one two three");
-				Assert.Fail("ParseException expected due to too many boolean clauses");
-			}
-			catch (ParseException expected)
-			{
-				// too many boolean clauses, so ParseException is expected
-			}
+		    QueryParser qp = new QueryParser(Version.LUCENE_CURRENT, "field", new WhitespaceAnalyzer());
+		    Assert.Throws<ParseException>(() => qp.Parse("one two three"),
+		                                  "ParseException expected due to too many boolean clauses");
 		}
 		
 		/// <summary> This test differs from TestPrecedenceQueryParser</summary>
@@ -1166,18 +1105,12 @@ namespace Lucene.Net.QueryParsers
 		public virtual void  TestProtectedCtors()
 		{
             // If the return type is not null, then fail the assertion.
-			if (typeof(QueryParser).GetConstructor(new System.Type[]{typeof(ICharStream)}) != null)
-            {
-                // Fail the assertion.
-				Assert.Fail("please switch public QueryParser(CharStream) to be protected");
-			}
+		    Assert.IsNull(typeof (QueryParser).GetConstructor(new System.Type[] {typeof (ICharStream)}),
+		                  "please switch public QueryParser(CharStream) to be protected");
 
             // Same for the constructor for the constructor with the query parser token manager.
-            if (typeof(QueryParser).GetConstructor(new System.Type[]{typeof(QueryParserTokenManager)})
!= null)
-            {
-                // Fail the assertion.
-                Assert.Fail("please switch public QueryParser(QueryParserTokenManager) to
be protected");
-			}
+            Assert.IsNull(typeof(QueryParser).GetConstructor(new System.Type[] { typeof(QueryParserTokenManager)
}),
+                          "please switch public QueryParser(QueryParserTokenManager) to be
protected");
 		}
 
         [Test]

Modified: incubator/lucene.net/trunk/test/core/Search/CheckHits.cs
URL: http://svn.apache.org/viewvc/incubator/lucene.net/trunk/test/core/Search/CheckHits.cs?rev=1326749&r1=1326748&r2=1326749&view=diff
==============================================================================
--- incubator/lucene.net/trunk/test/core/Search/CheckHits.cs (original)
+++ incubator/lucene.net/trunk/test/core/Search/CheckHits.cs Mon Apr 16 19:11:49 2012
@@ -217,22 +217,18 @@ namespace Lucene.Net.Search
 		public static void  CheckEqual(Query query, ScoreDoc[] hits1, ScoreDoc[] hits2)
 		{
 			float scoreTolerance = 1.0e-6f;
-			if (hits1.Length != hits2.Length)
-			{
-				Assert.Fail("Unequal lengths: hits1=" + hits1.Length + ",hits2=" + hits2.Length);
-			}
-			for (int i = 0; i < hits1.Length; i++)
-			{
-				if (hits1[i].Doc != hits2[i].Doc)
-				{
-					Assert.Fail("Hit " + i + " docnumbers don't match\n" + Hits2str(hits1, hits2, 0, 0)
+ "for query:" + query.ToString());
-				}
-				
-				if ((hits1[i].Doc != hits2[i].Doc) || System.Math.Abs(hits1[i].Score - hits2[i].Score)
> scoreTolerance)
-				{
-					Assert.Fail("Hit " + i + ", doc nrs " + hits1[i].Doc + " and " + hits2[i].Doc + "\nunequal
      : " + hits1[i].Score + "\n           and: " + hits2[i].Score + "\nfor query:" + query.ToString());
-				}
-			}
+            Assert.IsTrue(hits1.Length == hits2.Length, "Unequal lengths: hits1=" + hits1.Length
+ ",hits2=" + hits2.Length);
+
+            for (int i = 0; i < hits1.Length; i++)
+            {
+                Assert.IsTrue(hits1[i].Doc == hits2[i].Doc,
+                              "Hit " + i + " docnumbers don't match\n" + Hits2str(hits1,
hits2, 0, 0) + "for query:" +
+                              query);
+                Assert.IsFalse(
+                    (hits1[i].Doc != hits2[i].Doc) || System.Math.Abs(hits1[i].Score - hits2[i].Score)
> scoreTolerance,
+                    "Hit " + i + ", doc nrs " + hits1[i].Doc + " and " + hits2[i].Doc + "\nunequal
      : " +
+                    hits1[i].Score + "\n           and: " + hits2[i].Score + "\nfor query:"
+ query);
+            }
 		}
 		
 		public static System.String Hits2str(ScoreDoc[] hits1, ScoreDoc[] hits2, int start, int
end)

Modified: incubator/lucene.net/trunk/test/core/Search/TestBooleanMinShouldMatch.cs
URL: http://svn.apache.org/viewvc/incubator/lucene.net/trunk/test/core/Search/TestBooleanMinShouldMatch.cs?rev=1326749&r1=1326748&r2=1326749&view=diff
==============================================================================
--- incubator/lucene.net/trunk/test/core/Search/TestBooleanMinShouldMatch.cs (original)
+++ incubator/lucene.net/trunk/test/core/Search/TestBooleanMinShouldMatch.cs Mon Apr 16 19:11:49
2012
@@ -388,11 +388,9 @@ namespace Lucene.Net.Search
 				
 				// The constrained query
 				// should be a superset to the unconstrained query.
-				if (top2.TotalHits > top1.TotalHits)
-				{
-					//TestCase.fail("Constrained results not a subset:\n" + CheckHits.TopdocsString(top1,
0, 0) + CheckHits.TopdocsString(top2, 0, 0) + "for query:" + q2.ToString());
-					Assert.Fail("Constrained results not a subset:\n" + CheckHits.TopdocsString(top1, 0,
0) + CheckHits.TopdocsString(top2, 0, 0) + "for query:" + q2.ToString());
-				}
+			    Assert.IsFalse(top2.TotalHits > top1.TotalHits,
+			                  "Constrained results not a subset:\n" + CheckHits.TopdocsString(top1,
0, 0) +
+			                  CheckHits.TopdocsString(top2, 0, 0) + "for query:" + q2);
 				
 				for (int hit = 0; hit < top2.TotalHits; hit++)
 				{
@@ -407,20 +405,16 @@ namespace Lucene.Net.Search
 							found = true;
 							float otherScore = top1.ScoreDocs[other].Score;
 							// check if scores match
-							if (System.Math.Abs(otherScore - score) > 1.0e-6f)
-							{
-								//TestCase.fail("Doc " + id + " scores don't match\n" + CheckHits.TopdocsString(top1,
0, 0) + CheckHits.TopdocsString(top2, 0, 0) + "for query:" + q2.ToString());
-								Assert.Fail("Doc " + id + " scores don't match\n" + CheckHits.TopdocsString(top1,
0, 0) + CheckHits.TopdocsString(top2, 0, 0) + "for query:" + q2.ToString());
-							}
+						    Assert.IsFalse(Math.Abs(otherScore - score) > 1.0e-6f,
+						                  "Doc " + id + " scores don't match\n" + CheckHits.TopdocsString(top1,
0, 0) +
+						                  CheckHits.TopdocsString(top2, 0, 0) + "for query:" + q2);
 						}
 					}
 					
 					// check if subset
-					if (!found)
-					{
-						//TestCase.fail("Doc " + id + " not found\n" + CheckHits.TopdocsString(top1, 0, 0)
+ CheckHits.TopdocsString(top2, 0, 0) + "for query:" + q2.ToString());
-						Assert.Fail("Doc " + id + " not found\n" + CheckHits.TopdocsString(top1, 0, 0) + CheckHits.TopdocsString(top2,
0, 0) + "for query:" + q2.ToString());
-					}
+				    Assert.IsTrue(found,
+				                  "Doc " + id + " not found\n" + CheckHits.TopdocsString(top1, 0, 0)
+
+				                  CheckHits.TopdocsString(top2, 0, 0) + "for query:" + q2);
 				}
 			}
 			// System.out.println("Total hits:"+tot);

Modified: incubator/lucene.net/trunk/test/core/Search/TestBooleanQuery.cs
URL: http://svn.apache.org/viewvc/incubator/lucene.net/trunk/test/core/Search/TestBooleanQuery.cs?rev=1326749&r1=1326748&r2=1326749&view=diff
==============================================================================
--- incubator/lucene.net/trunk/test/core/Search/TestBooleanQuery.cs (original)
+++ incubator/lucene.net/trunk/test/core/Search/TestBooleanQuery.cs Mon Apr 16 19:11:49 2012
@@ -61,15 +61,7 @@ namespace Lucene.Net.Search
 		[Test]
 		public virtual void  TestException()
 		{
-			try
-			{
-				BooleanQuery.MaxClauseCount = 0;
-				Assert.Fail();
-			}
-			catch (System.ArgumentException e)
-			{
-				// okay
-			}
+            Assert.Throws<ArgumentException>(() => BooleanQuery.MaxClauseCount =
0);
 		}
 		
 		// LUCENE-1630

Modified: incubator/lucene.net/trunk/test/core/Search/TestFuzzyQuery.cs
URL: http://svn.apache.org/viewvc/incubator/lucene.net/trunk/test/core/Search/TestFuzzyQuery.cs?rev=1326749&r1=1326748&r2=1326749&view=diff
==============================================================================
--- incubator/lucene.net/trunk/test/core/Search/TestFuzzyQuery.cs (original)
+++ incubator/lucene.net/trunk/test/core/Search/TestFuzzyQuery.cs Mon Apr 16 19:11:49 2012
@@ -280,25 +280,11 @@ namespace Lucene.Net.Search
 			query = new FuzzyQuery(new Term("field", "student"), 0.6f, 0);
 			hits = searcher.Search(query, null, 1000).ScoreDocs;
 			Assert.AreEqual(0, hits.Length);
-			
-			try
-			{
-				query = new FuzzyQuery(new Term("field", "student"), 1.1f);
-				Assert.Fail("Expected IllegalArgumentException");
-			}
-			catch (System.ArgumentException e)
-			{
-				// expecting exception
-			}
-			try
-			{
-				query = new FuzzyQuery(new Term("field", "student"), - 0.1f);
-				Assert.Fail("Expected IllegalArgumentException");
-			}
-			catch (System.ArgumentException e)
-			{
-				// expecting exception
-			}
+
+	        Assert.Throws<ArgumentException>(() => new FuzzyQuery(new Term("field",
"student"), 1.1f),
+	                                         "Expected ArgumentException");
+	        Assert.Throws<ArgumentException>(() => new FuzzyQuery(new Term("field",
"student"), -0.1f),
+	                                         "Expected ArgumentException");
 			
 			searcher.Close();
 			directory.Close();

Modified: incubator/lucene.net/trunk/test/core/Search/TestMultiPhraseQuery.cs
URL: http://svn.apache.org/viewvc/incubator/lucene.net/trunk/test/core/Search/TestMultiPhraseQuery.cs?rev=1326749&r1=1326748&r2=1326749&view=diff
==============================================================================
--- incubator/lucene.net/trunk/test/core/Search/TestMultiPhraseQuery.cs (original)
+++ incubator/lucene.net/trunk/test/core/Search/TestMultiPhraseQuery.cs Mon Apr 16 19:11:49
2012
@@ -114,16 +114,13 @@ namespace Lucene.Net.Search
 			Assert.AreEqual(3, result.Length); // blueberry pizza, bluebird pizza, bluebird foobar
pizza
 			
 			MultiPhraseQuery query4 = new MultiPhraseQuery();
-			try
-			{
-				query4.Add(new Term("field1", "foo"));
-				query4.Add(new Term("field2", "foobar"));
-				Assert.Fail();
-			}
-			catch (System.ArgumentException e)
-			{
-				// okay, all terms must belong to the same field
-			}
+
+            // okay, all terms must belong to the same field
+		    Assert.Throws<ArgumentException>(() =>
+		                                         {
+		                                             query4.Add(new Term("field1", "foo"));
+		                                             query4.Add(new Term("field2", "foobar"));
+		                                         });
 			
 			searcher.Close();
 			indexStore.Close();

Modified: incubator/lucene.net/trunk/test/core/Store/TestBufferedIndexInput.cs
URL: http://svn.apache.org/viewvc/incubator/lucene.net/trunk/test/core/Store/TestBufferedIndexInput.cs?rev=1326749&r1=1326748&r2=1326749&view=diff
==============================================================================
--- incubator/lucene.net/trunk/test/core/Store/TestBufferedIndexInput.cs (original)
+++ incubator/lucene.net/trunk/test/core/Store/TestBufferedIndexInput.cs Mon Apr 16 19:11:49
2012
@@ -209,38 +209,18 @@ namespace Lucene.Net.Store
 			// go back and see that we can't read more than that, for small and
 			// large overflows:
 			int pos = (int) input.Length() - 10;
+
 			input.Seek(pos);
 			CheckReadBytes(input, 10, pos);
+
 			input.Seek(pos);
-			try
-			{
-				CheckReadBytes(input, 11, pos);
-				Assert.Fail("Block read past end of file");
-			}
-			catch (System.IO.IOException e)
-			{
-				/* success */
-			}
+            Assert.Throws<System.IO.IOException>(() => CheckReadBytes(input, 11,
pos), "Block read past end of file");
+
 			input.Seek(pos);
-			try
-			{
-				CheckReadBytes(input, 50, pos);
-				Assert.Fail("Block read past end of file");
-			}
-			catch (System.IO.IOException e)
-			{
-				/* success */
-			}
+            Assert.Throws<System.IO.IOException>(() => CheckReadBytes(input, 50,
pos), "Block read past end of file");
+
 			input.Seek(pos);
-			try
-			{
-				CheckReadBytes(input, 100000, pos);
-				Assert.Fail("Block read past end of file");
-			}
-			catch (System.IO.IOException e)
-			{
-				/* success */
-			}
+            Assert.Throws<System.IO.IOException>(() => CheckReadBytes(input, 100000,
pos), "Block read past end of file");
 		}
 		
 		// byten emulates a file - byten(n) returns the n'th byte in that file.

Modified: incubator/lucene.net/trunk/test/core/Store/TestDirectory.cs
URL: http://svn.apache.org/viewvc/incubator/lucene.net/trunk/test/core/Store/TestDirectory.cs?rev=1326749&r1=1326748&r2=1326749&view=diff
==============================================================================
--- incubator/lucene.net/trunk/test/core/Store/TestDirectory.cs (original)
+++ incubator/lucene.net/trunk/test/core/Store/TestDirectory.cs Mon Apr 16 19:11:49 2012
@@ -34,25 +34,12 @@ namespace Lucene.Net.Store
 		{
 			Directory dir = new RAMDirectory();
 			dir.Close();
-			try
-			{
-				dir.CreateOutput("test");
-				Assert.Fail("did not hit expected exception");
-			}
-			catch (AlreadyClosedException ace)
-			{
-			}
+
+            Assert.Throws<AlreadyClosedException>(() => dir.CreateOutput("test"),
"did not hit expected exception");
 			
 			dir = FSDirectory.Open(new System.IO.DirectoryInfo(AppSettings.Get("tempDir", System.IO.Path.GetTempPath())));
 			dir.Close();
-			try
-			{
-				dir.CreateOutput("test");
-				Assert.Fail("did not hit expected exception");
-			}
-			catch (AlreadyClosedException ace)
-			{
-			}
+			Assert.Throws<AlreadyClosedException>(() => dir.CreateOutput("test"), "did not
hit expected exception");
 		}
 		
 		
@@ -228,15 +215,11 @@ namespace Lucene.Net.Store
 				IndexOutput out_Renamed = fsDir.CreateOutput("afile");
 				out_Renamed.Close();
 				Assert.IsTrue(fsDir.FileExists("afile"));
-				try
-				{
-					new SimpleFSDirectory(new System.IO.DirectoryInfo(System.IO.Path.Combine(path.FullName,
"afile")), null);
-					Assert.Fail("did not hit expected exception");
-				}
-				catch (NoSuchDirectoryException nsde)
-				{
-					// Expected
-				}
+
+			    Assert.Throws<NoSuchDirectoryException>(
+			        () =>
+			        new SimpleFSDirectory(new System.IO.DirectoryInfo(System.IO.Path.Combine(path.FullName,
"afile")), null),
+			        "did not hit expected exception");
 			}
 			finally
 			{

Modified: incubator/lucene.net/trunk/test/core/Store/TestLock.cs
URL: http://svn.apache.org/viewvc/incubator/lucene.net/trunk/test/core/Store/TestLock.cs?rev=1326749&r1=1326748&r2=1326749&view=diff
==============================================================================
--- incubator/lucene.net/trunk/test/core/Store/TestLock.cs (original)
+++ incubator/lucene.net/trunk/test/core/Store/TestLock.cs Mon Apr 16 19:11:49 2012
@@ -27,25 +27,19 @@ namespace Lucene.Net.Store
 	[TestFixture]
 	public class TestLock:LuceneTestCase
 	{
-		
-		[Test]
-		public virtual void  TestObtain()
-		{
-			LockMock lock_Renamed = new LockMock(this);
-			Lock.LOCK_POLL_INTERVAL = 10;
-			
-			try
-			{
-				lock_Renamed.Obtain(Lock.LOCK_POLL_INTERVAL);
-				Assert.Fail("Should have failed to obtain lock");
-			}
-			catch (System.IO.IOException e)
-			{
-				Assert.AreEqual(lock_Renamed.lockAttempts, 2, "should attempt to lock more than once");
-			}
-		}
-		
-		private class LockMock:Lock
+
+        [Test]
+        public virtual void TestObtain()
+        {
+            LockMock lock_Renamed = new LockMock(this);
+            Lock.LOCK_POLL_INTERVAL = 10;
+
+            Assert.Throws<LockObtainFailedException>(() => lock_Renamed.Obtain(Lock.LOCK_POLL_INTERVAL),
+                                                 "Should have failed to obtain lock");
+            Assert.AreEqual(lock_Renamed.lockAttempts, 2, "should attempt to lock more than
once");
+        }
+
+	    private class LockMock:Lock
 		{
 			public LockMock(TestLock enclosingInstance)
 			{

Modified: incubator/lucene.net/trunk/test/core/Store/TestLockFactory.cs
URL: http://svn.apache.org/viewvc/incubator/lucene.net/trunk/test/core/Store/TestLockFactory.cs?rev=1326749&r1=1326748&r2=1326749&view=diff
==============================================================================
--- incubator/lucene.net/trunk/test/core/Store/TestLockFactory.cs (original)
+++ incubator/lucene.net/trunk/test/core/Store/TestLockFactory.cs Mon Apr 16 19:11:49 2012
@@ -119,14 +119,10 @@ namespace Lucene.Net.Store
 			
 			// Create a 2nd IndexWriter.  This should fail:
 			IndexWriter writer2 = null;
-			try
-			{
-				writer2 = new IndexWriter(dir, new WhitespaceAnalyzer(), false, IndexWriter.MaxFieldLength.LIMITED);
-				Assert.Fail("Should have hit an IOException with two IndexWriters on default SingleInstanceLockFactory");
-			}
-			catch (System.IO.IOException e)
-			{
-			}
+
+		    Assert.Throws<LockObtainFailedException>(
+		        () => writer2 = new IndexWriter(dir, new WhitespaceAnalyzer(), false, IndexWriter.MaxFieldLength.LIMITED),
+		        "Should have hit an IOException with two IndexWriters on default SingleInstanceLockFactory");
 			
 			writer.Close();
 			if (writer2 != null)

Modified: incubator/lucene.net/trunk/test/core/Support/TestIDisposable.cs
URL: http://svn.apache.org/viewvc/incubator/lucene.net/trunk/test/core/Support/TestIDisposable.cs?rev=1326749&r1=1326748&r2=1326749&view=diff
==============================================================================
--- incubator/lucene.net/trunk/test/core/Support/TestIDisposable.cs (original)
+++ incubator/lucene.net/trunk/test/core/Support/TestIDisposable.cs Mon Apr 16 19:11:49 2012
@@ -51,26 +51,13 @@ namespace Lucene.Net.Support
 
                     using (reader = writer.GetReader())
                     {
-                        IndexReader r1 =  reader.Reopen();
+                        IndexReader r1 = reader.Reopen();
                     }
 
-                    try
-                    {
-                        IndexReader r2 = reader.Reopen();
-                        Assert.Fail("IndexReader shouldn't be open here");
-                    }
-                    catch (AlreadyClosedException)
-                    {
-                    }
-                }
-                try
-                {
-                    writer.AddDocument(doc);
-                    Assert.Fail("IndexWriter shouldn't be open here");
-                }
-                catch (AlreadyClosedException)
-                {
+                    Assert.Throws<AlreadyClosedException>(() => reader.Reopen(),
"IndexReader shouldn't be open here");
                 }
+                
+                Assert.Throws<AlreadyClosedException>(() => writer.AddDocument(doc),
"IndexWriter shouldn't be open here");
 
                 Assert.IsTrue(dir.isOpen_ForNUnit, "RAMDirectory");
             }

Modified: incubator/lucene.net/trunk/test/core/Support/TestWeakHashTable.cs
URL: http://svn.apache.org/viewvc/incubator/lucene.net/trunk/test/core/Support/TestWeakHashTable.cs?rev=1326749&r1=1326748&r2=1326749&view=diff
==============================================================================
--- incubator/lucene.net/trunk/test/core/Support/TestWeakHashTable.cs (original)
+++ incubator/lucene.net/trunk/test/core/Support/TestWeakHashTable.cs Mon Apr 16 19:11:49
2012
@@ -140,7 +140,7 @@ namespace Lucene.Net.Support
 
             GC.Collect();
             int memUsage = GetMemUsageInKB();
-            if (memUsage > initialMemUsage * 2) Assert.Fail("Memory Leakage.MemUsage =
" + memUsage);
+            Assert.IsFalse(memUsage > initialMemUsage * 2, "Memory Leakage.MemUsage =
" + memUsage);
         }
 
     }

Modified: incubator/lucene.net/trunk/test/core/Util/TestAttributeSource.cs
URL: http://svn.apache.org/viewvc/incubator/lucene.net/trunk/test/core/Util/TestAttributeSource.cs?rev=1326749&r1=1326748&r2=1326749&view=diff
==============================================================================
--- incubator/lucene.net/trunk/test/core/Util/TestAttributeSource.cs (original)
+++ incubator/lucene.net/trunk/test/core/Util/TestAttributeSource.cs Mon Apr 16 19:11:49 2012
@@ -76,15 +76,9 @@ namespace Lucene.Net.Util
             // init a third instance missing one Attribute
             AttributeSource src3 = new AttributeSource();
             termAtt = src3.AddAttribute<ITermAttribute>();
-            try
-            {
-                src3.RestoreState(state);
-                Assert.Fail("The third instance is missing the TypeAttribute, so restoreState()
should throw IllegalArgumentException");
-            }
-            catch (System.ArgumentException iae)
-            {
-                // pass
-            }
+
+            Assert.Throws<ArgumentException>(() => src3.RestoreState(state),
+                                             "The third instance is missing the TypeAttribute,
so restoreState() should throw IllegalArgumentException");
         }
 
         [Test]
@@ -165,21 +159,11 @@ namespace Lucene.Net.Util
         [Test]
         public void TestInvalidArguments()
         {
-            try
-            {
-                AttributeSource src = new AttributeSource();
-                src.AddAttribute<Token>();
-                Assert.Fail("Should throw ArgumentException");
-            }
-            catch (ArgumentException iae) { }
-
-            try
-            {
-                AttributeSource src = new AttributeSource();
-                src.AddAttribute<Token>();
-                Assert.Fail("Should throw IllegalArgumentException");
-            }
-            catch (ArgumentException iae) { }
+            var src = new AttributeSource();
+            Assert.Throws<ArgumentException>(() => src.AddAttribute<Token>(),
"Should throw ArgumentException");
+
+            src = new AttributeSource();
+            Assert.Throws<ArgumentException>(() => src.AddAttribute<Token>(),
"Should throw ArgumentException");
 
             //try
             //{

Modified: incubator/lucene.net/trunk/test/core/Util/TestNumericUtils.cs
URL: http://svn.apache.org/viewvc/incubator/lucene.net/trunk/test/core/Util/TestNumericUtils.cs?rev=1326749&r1=1326748&r2=1326749&view=diff
==============================================================================
--- incubator/lucene.net/trunk/test/core/Util/TestNumericUtils.cs (original)
+++ incubator/lucene.net/trunk/test/core/Util/TestNumericUtils.cs Mon Apr 16 19:11:49 2012
@@ -196,15 +196,8 @@ namespace Lucene.Net.Util
 				Assert.AreEqual(vals[i], NumericUtils.PrefixCodedToLong(prefixVals[i]), "forward and
back conversion should generate same long");
 				
 				// test if decoding values as int fails correctly
-				try
-				{
-					NumericUtils.PrefixCodedToInt(prefixVals[i]);
-					Assert.Fail("decoding a prefix coded long value as int should fail");
-				}
-				catch (System.FormatException e)
-				{
-					// worked
-				}
+			    Assert.Throws<FormatException>(() => NumericUtils.PrefixCodedToInt(prefixVals[i]),
+			                                   "decoding a prefix coded long value as int should fail");
 			}
 			
 			// check sort order (prefixVals should be ascending)
@@ -239,15 +232,8 @@ namespace Lucene.Net.Util
 				Assert.AreEqual(vals[i], NumericUtils.PrefixCodedToInt(prefixVals[i]), "forward and back
conversion should generate same int");
 				
 				// test if decoding values as long fails correctly
-				try
-				{
-					NumericUtils.PrefixCodedToLong(prefixVals[i]);
-					Assert.Fail("decoding a prefix coded int value as long should fail");
-				}
-				catch (System.FormatException e)
-				{
-					// worked
-				}
+			    Assert.Throws<FormatException>(() => NumericUtils.PrefixCodedToLong(prefixVals[i]),
+			                                   "decoding a prefix coded int value as long should fail");
 			}
 			
 			// check sort order (prefixVals should be ascending)

Modified: incubator/lucene.net/trunk/test/core/Util/TestOpenBitSet.cs
URL: http://svn.apache.org/viewvc/incubator/lucene.net/trunk/test/core/Util/TestOpenBitSet.cs?rev=1326749&r1=1326748&r2=1326749&view=diff
==============================================================================
--- incubator/lucene.net/trunk/test/core/Util/TestOpenBitSet.cs (original)
+++ incubator/lucene.net/trunk/test/core/Util/TestOpenBitSet.cs Mon Apr 16 19:11:49 2012
@@ -36,10 +36,7 @@ namespace Lucene.Net.Util
 			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));
-				}
+                Assert.AreEqual(a.Get(i) != b.Get(i), "mismatch: BitSet=[" + i + "]=" + a.Get(i));
 			}
 		}
 		

Modified: incubator/lucene.net/trunk/test/core/Util/TestSortedVIntList.cs
URL: http://svn.apache.org/viewvc/incubator/lucene.net/trunk/test/core/Util/TestSortedVIntList.cs?rev=1326749&r1=1326748&r2=1326749&view=diff
==============================================================================
--- incubator/lucene.net/trunk/test/core/Util/TestSortedVIntList.cs (original)
+++ incubator/lucene.net/trunk/test/core/Util/TestSortedVIntList.cs Mon Apr 16 19:11:49 2012
@@ -123,15 +123,7 @@ namespace Lucene.Net.Util
 		
 		public virtual void  TstIllegalArgExc(int[] ints)
 		{
-			try
-			{
-				new SortedVIntList(ints);
-			}
-			catch (System.ArgumentException e)
-			{
-				return ;
-			}
-			Assert.Fail("Expected IllegalArgumentException");
+            Assert.Throws<ArgumentException>(() => new SortedVIntList(ints), "Expected
ArgumentException");
 		}
 		
 		private int[] FibArray(int a, int b, int size)

Modified: incubator/lucene.net/trunk/test/core/Util/TestStringIntern.cs
URL: http://svn.apache.org/viewvc/incubator/lucene.net/trunk/test/core/Util/TestStringIntern.cs?rev=1326749&r1=1326748&r2=1326749&view=diff
==============================================================================
--- incubator/lucene.net/trunk/test/core/Util/TestStringIntern.cs (original)
+++ incubator/lucene.net/trunk/test/core/Util/TestStringIntern.cs Mon Apr 16 19:11:49 2012
@@ -70,17 +70,11 @@ namespace Lucene.Net.Util
 					System.String otherInterned = Enclosing_Instance.internedStrings[idx];
 					
 					// test against other threads
-					if (otherInterned != null && otherInterned != interned)
-					{
-						Assert.Fail(); // TestCase.fail();
-					}
+                    Assert.IsFalse(otherInterned != null && otherInterned != interned);
 					Enclosing_Instance.internedStrings[idx] = interned;
 					
 					// test against local copy
-					if (prevInterned != null && prevInterned != interned)
-					{
-						Assert.Fail(); // TestCase.fail();
-					}
+                    Assert.IsFalse(prevInterned != null && prevInterned != interned);
 					myInterned[idx] = interned;
 				}
                 this.Reset.Set();



Mime
View raw message