lucenenet-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From synhers...@apache.org
Subject [3/6] lucenenet git commit: Replacing [ExpectedException(T)] with Assert.Throws<T>
Date Fri, 16 Dec 2016 10:18:16 GMT
Replacing [ExpectedException(T)] with Assert.Throws<T>


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

Branch: refs/heads/master
Commit: d2a26793d63894966d8c475abb6ccee7e092e7c7
Parents: 0171a22
Author: Connie Yau <conniey@microsoft.com>
Authored: Sun Oct 30 22:34:49 2016 -0700
Committer: Connie Yau <conniey@microsoft.com>
Committed: Sat Nov 12 13:25:34 2016 -0800

----------------------------------------------------------------------
 .../Miscellaneous/TestCapitalizationFilter.cs   | 12 +++----
 .../Miscellaneous/TestCodepointCountFilter.cs   |  4 +--
 .../Analysis/Miscellaneous/TestLengthFilter.cs  |  4 +--
 .../Miscellaneous/TestLimitTokenCountFilter.cs  |  4 +--
 .../TestLimitTokenPositionFilter.cs             |  3 +-
 .../Miscellaneous/TestTruncateTokenFilter.cs    |  3 +-
 .../Sinks/TokenRangeSinkTokenizerTest.cs        |  3 +-
 .../Analysis/Synonym/TestSolrSynonymParser.cs   | 15 +++------
 .../TestCompressingStoredFieldsFormat.cs        | 35 +++++++++++---------
 .../core/Support/TestLurchTable.cs              |  4 +--
 .../core/Util/TestBytesRefHash.cs               | 22 ++++++------
 src/Lucene.Net.Tests/core/Util/TestSetOnce.cs   | 12 ++++---
 12 files changed, 61 insertions(+), 60 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/lucenenet/blob/d2a26793/src/Lucene.Net.Tests.Analysis.Common/Analysis/Miscellaneous/TestCapitalizationFilter.cs
----------------------------------------------------------------------
diff --git a/src/Lucene.Net.Tests.Analysis.Common/Analysis/Miscellaneous/TestCapitalizationFilter.cs
b/src/Lucene.Net.Tests.Analysis.Common/Analysis/Miscellaneous/TestCapitalizationFilter.cs
index cff486e..ffa38db 100644
--- a/src/Lucene.Net.Tests.Analysis.Common/Analysis/Miscellaneous/TestCapitalizationFilter.cs
+++ b/src/Lucene.Net.Tests.Analysis.Common/Analysis/Miscellaneous/TestCapitalizationFilter.cs
@@ -139,24 +139,24 @@ namespace Lucene.Net.Analysis.Miscellaneous
         /// 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));
         }
     }
 }
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/lucenenet/blob/d2a26793/src/Lucene.Net.Tests.Analysis.Common/Analysis/Miscellaneous/TestCodepointCountFilter.cs
----------------------------------------------------------------------
diff --git a/src/Lucene.Net.Tests.Analysis.Common/Analysis/Miscellaneous/TestCodepointCountFilter.cs
b/src/Lucene.Net.Tests.Analysis.Common/Analysis/Miscellaneous/TestCodepointCountFilter.cs
index b690ae9..78c9f67 100644
--- a/src/Lucene.Net.Tests.Analysis.Common/Analysis/Miscellaneous/TestCodepointCountFilter.cs
+++ b/src/Lucene.Net.Tests.Analysis.Common/Analysis/Miscellaneous/TestCodepointCountFilter.cs
@@ -86,10 +86,10 @@ namespace Lucene.Net.Analysis.Miscellaneous
         /// 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));
         }
     }
 }
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/lucenenet/blob/d2a26793/src/Lucene.Net.Tests.Analysis.Common/Analysis/Miscellaneous/TestLengthFilter.cs
----------------------------------------------------------------------
diff --git a/src/Lucene.Net.Tests.Analysis.Common/Analysis/Miscellaneous/TestLengthFilter.cs
b/src/Lucene.Net.Tests.Analysis.Common/Analysis/Miscellaneous/TestLengthFilter.cs
index 43eb450..47b9614 100644
--- a/src/Lucene.Net.Tests.Analysis.Common/Analysis/Miscellaneous/TestLengthFilter.cs
+++ b/src/Lucene.Net.Tests.Analysis.Common/Analysis/Miscellaneous/TestLengthFilter.cs
@@ -71,10 +71,10 @@ namespace Lucene.Net.Analysis.Miscellaneous
         /// 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));
         }
     }
 }
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/lucenenet/blob/d2a26793/src/Lucene.Net.Tests.Analysis.Common/Analysis/Miscellaneous/TestLimitTokenCountFilter.cs
----------------------------------------------------------------------
diff --git a/src/Lucene.Net.Tests.Analysis.Common/Analysis/Miscellaneous/TestLimitTokenCountFilter.cs
b/src/Lucene.Net.Tests.Analysis.Common/Analysis/Miscellaneous/TestLimitTokenCountFilter.cs
index f0e9e4b..e1d12e0 100644
--- a/src/Lucene.Net.Tests.Analysis.Common/Analysis/Miscellaneous/TestLimitTokenCountFilter.cs
+++ b/src/Lucene.Net.Tests.Analysis.Common/Analysis/Miscellaneous/TestLimitTokenCountFilter.cs
@@ -37,10 +37,10 @@ namespace Lucene.Net.Analysis.Miscellaneous
         }
 
         [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));
         }
     }
 }
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/lucenenet/blob/d2a26793/src/Lucene.Net.Tests.Analysis.Common/Analysis/Miscellaneous/TestLimitTokenPositionFilter.cs
----------------------------------------------------------------------
diff --git a/src/Lucene.Net.Tests.Analysis.Common/Analysis/Miscellaneous/TestLimitTokenPositionFilter.cs
b/src/Lucene.Net.Tests.Analysis.Common/Analysis/Miscellaneous/TestLimitTokenPositionFilter.cs
index c32b5f9..933c744 100644
--- a/src/Lucene.Net.Tests.Analysis.Common/Analysis/Miscellaneous/TestLimitTokenPositionFilter.cs
+++ b/src/Lucene.Net.Tests.Analysis.Common/Analysis/Miscellaneous/TestLimitTokenPositionFilter.cs
@@ -92,10 +92,9 @@ namespace Lucene.Net.Analysis.Miscellaneous
         }
 
         [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));
         }
     }
 }
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/lucenenet/blob/d2a26793/src/Lucene.Net.Tests.Analysis.Common/Analysis/Miscellaneous/TestTruncateTokenFilter.cs
----------------------------------------------------------------------
diff --git a/src/Lucene.Net.Tests.Analysis.Common/Analysis/Miscellaneous/TestTruncateTokenFilter.cs
b/src/Lucene.Net.Tests.Analysis.Common/Analysis/Miscellaneous/TestTruncateTokenFilter.cs
index dcd886d..26ea658 100644
--- a/src/Lucene.Net.Tests.Analysis.Common/Analysis/Miscellaneous/TestTruncateTokenFilter.cs
+++ b/src/Lucene.Net.Tests.Analysis.Common/Analysis/Miscellaneous/TestTruncateTokenFilter.cs
@@ -36,10 +36,9 @@ namespace Lucene.Net.Analysis.Miscellaneous
         }
 
         [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));
         }
     }
 }
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/lucenenet/blob/d2a26793/src/Lucene.Net.Tests.Analysis.Common/Analysis/Sinks/TokenRangeSinkTokenizerTest.cs
----------------------------------------------------------------------
diff --git a/src/Lucene.Net.Tests.Analysis.Common/Analysis/Sinks/TokenRangeSinkTokenizerTest.cs
b/src/Lucene.Net.Tests.Analysis.Common/Analysis/Sinks/TokenRangeSinkTokenizerTest.cs
index 5ec9ade..80444c7 100644
--- a/src/Lucene.Net.Tests.Analysis.Common/Analysis/Sinks/TokenRangeSinkTokenizerTest.cs
+++ b/src/Lucene.Net.Tests.Analysis.Common/Analysis/Sinks/TokenRangeSinkTokenizerTest.cs
@@ -51,10 +51,9 @@ namespace Lucene.Net.Analysis.Sinks
         }
 
         [Test]
-        [ExpectedException(ExpectedException = typeof(ArgumentOutOfRangeException))]
         public virtual void TestIllegalArguments()
         {
-            new TokenRangeSinkFilter(4, 2);
+            Assert.Throws<ArgumentOutOfRangeException>(() => new TokenRangeSinkFilter(4,
2));
         }
     }
 }
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/lucenenet/blob/d2a26793/src/Lucene.Net.Tests.Analysis.Common/Analysis/Synonym/TestSolrSynonymParser.cs
----------------------------------------------------------------------
diff --git a/src/Lucene.Net.Tests.Analysis.Common/Analysis/Synonym/TestSolrSynonymParser.cs
b/src/Lucene.Net.Tests.Analysis.Common/Analysis/Synonym/TestSolrSynonymParser.cs
index 983c75c..b04f6cc 100644
--- a/src/Lucene.Net.Tests.Analysis.Common/Analysis/Synonym/TestSolrSynonymParser.cs
+++ b/src/Lucene.Net.Tests.Analysis.Common/Analysis/Synonym/TestSolrSynonymParser.cs
@@ -73,56 +73,51 @@ namespace Lucene.Net.Analysis.Synonym
         /// <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>

http://git-wip-us.apache.org/repos/asf/lucenenet/blob/d2a26793/src/Lucene.Net.Tests/core/Codecs/Compressing/TestCompressingStoredFieldsFormat.cs
----------------------------------------------------------------------
diff --git a/src/Lucene.Net.Tests/core/Codecs/Compressing/TestCompressingStoredFieldsFormat.cs
b/src/Lucene.Net.Tests/core/Codecs/Compressing/TestCompressingStoredFieldsFormat.cs
index 998b942..e902cb1 100644
--- a/src/Lucene.Net.Tests/core/Codecs/Compressing/TestCompressingStoredFieldsFormat.cs
+++ b/src/Lucene.Net.Tests/core/Codecs/Compressing/TestCompressingStoredFieldsFormat.cs
@@ -1,4 +1,5 @@
 using Lucene.Net.Documents;
+using System;
 using Field = Lucene.Net.Documents.Field;
 
 namespace Lucene.Net.Codecs.Compressing
@@ -45,7 +46,6 @@ namespace Lucene.Net.Codecs.Compressing
         }
 
         [Test]
-        [ExpectedException("System.ArgumentException")]
         public virtual void TestDeletePartiallyWrittenFilesIfAbort()
         {
             Directory dir = NewDirectory();
@@ -68,26 +68,29 @@ namespace Lucene.Net.Codecs.Compressing
             fieldType.Stored = true;
             invalidDoc.Add(new FieldAnonymousInnerClassHelper(this, fieldType));
 
-            try
+            Assert.Throws<ArgumentException>(() =>
             {
-                iw.AddDocument(invalidDoc);
-                iw.Commit();
-            }
-            finally
-            {
-                int counter = 0;
-                foreach (string fileName in dir.ListAll())
+                try
                 {
-                    if (fileName.EndsWith(".fdt") || fileName.EndsWith(".fdx"))
+                    iw.AddDocument(invalidDoc);
+                    iw.Commit();
+                }
+                finally
+                {
+                    int counter = 0;
+                    foreach (string fileName in dir.ListAll())
                     {
-                        counter++;
+                        if (fileName.EndsWith(".fdt") || fileName.EndsWith(".fdx"))
+                        {
+                            counter++;
+                        }
                     }
+                    // Only one .fdt and one .fdx files must have been found
+                    Assert.AreEqual(2, counter);
+                    iw.Dispose();
+                    dir.Dispose();
                 }
-                // Only one .fdt and one .fdx files must have been found
-                Assert.AreEqual(2, counter);
-                iw.Dispose();
-                dir.Dispose();
-            }
+            });
         }
 
         private class FieldAnonymousInnerClassHelper : Field

http://git-wip-us.apache.org/repos/asf/lucenenet/blob/d2a26793/src/Lucene.Net.Tests/core/Support/TestLurchTable.cs
----------------------------------------------------------------------
diff --git a/src/Lucene.Net.Tests/core/Support/TestLurchTable.cs b/src/Lucene.Net.Tests/core/Support/TestLurchTable.cs
index 264e95c..778b419 100644
--- a/src/Lucene.Net.Tests/core/Support/TestLurchTable.cs
+++ b/src/Lucene.Net.Tests/core/Support/TestLurchTable.cs
@@ -504,7 +504,7 @@ namespace Lucene.Net.Support
             VerifyCollection(EqualityComparer<string>.Default, values.AsReadOnly(),
dict.Values);
         }
 
-        [Test, ExpectedException(typeof(ObjectDisposedException))]
+        [Test]
         public void TestDisposed()
         {
             IDictionary<int, string> test = new LurchTableTest<int, string>();
@@ -513,7 +513,7 @@ namespace Lucene.Net.Support
             {
                 disposable.Dispose();
             }
-            test.Add(1, "");
+            Assert.Throws<ObjectDisposedException>(() => test.Add(1, ""));
         }
 
         class KeyValueEquality<TKey, TValue> : IEqualityComparer<KeyValuePair<TKey,
TValue>>

http://git-wip-us.apache.org/repos/asf/lucenenet/blob/d2a26793/src/Lucene.Net.Tests/core/Util/TestBytesRefHash.cs
----------------------------------------------------------------------
diff --git a/src/Lucene.Net.Tests/core/Util/TestBytesRefHash.cs b/src/Lucene.Net.Tests/core/Util/TestBytesRefHash.cs
index c439dfd..a6ecf0e 100644
--- a/src/Lucene.Net.Tests/core/Util/TestBytesRefHash.cs
+++ b/src/Lucene.Net.Tests/core/Util/TestBytesRefHash.cs
@@ -323,7 +323,6 @@ namespace Lucene.Net.Util
         }
 
         [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) };
@@ -333,18 +332,21 @@ namespace Lucene.Net.Util
                 @ref.Bytes = new byte[sizes[i]];
                 @ref.Offset = 0;
                 @ref.Length = sizes[i];
-                try
+                Assert.Throws<MaxBytesLengthExceededException>(() =>
                 {
-                    Assert.AreEqual(i, Hash.Add(@ref));
-                }
-                catch (MaxBytesLengthExceededException e)
-                {
-                    if (i < sizes.Length - 1)
+                    try
                     {
-                        Assert.Fail("unexpected exception at size: " + sizes[i]);
+                        Assert.AreEqual(i, Hash.Add(@ref));
                     }
-                    throw e;
-                }
+                    catch (MaxBytesLengthExceededException e)
+                    {
+                        if (i < sizes.Length - 1)
+                        {
+                            Assert.Fail("unexpected exception at size: " + sizes[i]);
+                        }
+                        throw e;
+                    }
+                });
             }
         }
 

http://git-wip-us.apache.org/repos/asf/lucenenet/blob/d2a26793/src/Lucene.Net.Tests/core/Util/TestSetOnce.cs
----------------------------------------------------------------------
diff --git a/src/Lucene.Net.Tests/core/Util/TestSetOnce.cs b/src/Lucene.Net.Tests/core/Util/TestSetOnce.cs
index af0cd37..4bd23bf 100644
--- a/src/Lucene.Net.Tests/core/Util/TestSetOnce.cs
+++ b/src/Lucene.Net.Tests/core/Util/TestSetOnce.cs
@@ -65,22 +65,26 @@ namespace Lucene.Net.Util
         }
 
         [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]


Mime
View raw message