Replaced all ExpectedExceptionAttributes with the new Assert.Throws<>() method to work around a compatibility issue between TeamCity 4.5 and NUnit 2.5 Final
git-svn-id: file:///srv/devel/repo-conversion/nusu@137 d2e56fa2-650e-0410-a79f-9358c0239efd
This commit is contained in:
parent
06749b9cbb
commit
d0fe47239e
|
@ -228,10 +228,11 @@ namespace Nuclex.Support.Collections {
|
|||
/// Tests whether an exception is thrown if the indexer of the observable dictionary
|
||||
/// is used to attempt to retrieve a non-existing value
|
||||
/// </summary>
|
||||
[Test, ExpectedException(typeof(KeyNotFoundException))]
|
||||
public void TestThrowOnRetrieveNonExistingValueByIndexer() {
|
||||
string numberName = this.observedDictionary[24];
|
||||
Console.WriteLine(numberName);
|
||||
[Test]
|
||||
public void TestRetrieveNonExistingValueByIndexer() {
|
||||
Assert.Throws<KeyNotFoundException>(
|
||||
delegate() { Console.WriteLine(this.observedDictionary[24]); }
|
||||
);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
|
|
@ -100,33 +100,39 @@ namespace Nuclex.Support.Collections {
|
|||
/// Tests whether the priority queue's enumerators are invalidated when the queue's
|
||||
/// contents are modified
|
||||
/// </summary>
|
||||
[Test, ExpectedException(typeof(InvalidOperationException))]
|
||||
[Test]
|
||||
public void TestEnumeratorInvalidationOnModify() {
|
||||
PriorityQueue<int> testQueue = new PriorityQueue<int>();
|
||||
IEnumerator<int> testQueueEnumerator = testQueue.GetEnumerator();
|
||||
|
||||
testQueue.Enqueue(123);
|
||||
|
||||
testQueueEnumerator.MoveNext();
|
||||
|
||||
Assert.Throws<InvalidOperationException>(
|
||||
delegate() { testQueueEnumerator.MoveNext(); }
|
||||
);
|
||||
}
|
||||
#endif
|
||||
|
||||
/// <summary>
|
||||
/// Verifies that an exception is thrown when Peek() is called on an empty queue
|
||||
/// </summary>
|
||||
[Test, ExpectedException(typeof(InvalidOperationException))]
|
||||
[Test]
|
||||
public void TestPeekEmptyQueue() {
|
||||
PriorityQueue<int> testQueue = new PriorityQueue<int>();
|
||||
testQueue.Peek();
|
||||
Assert.Throws<InvalidOperationException>(
|
||||
delegate() { testQueue.Peek(); }
|
||||
);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Verifies that an exception is thrown when Dequeue() is called on an empty queue
|
||||
/// </summary>
|
||||
[Test, ExpectedException(typeof(InvalidOperationException))]
|
||||
[Test]
|
||||
public void TestDequeueEmptyQueue() {
|
||||
PriorityQueue<int> testQueue = new PriorityQueue<int>();
|
||||
testQueue.Dequeue();
|
||||
Assert.Throws<InvalidOperationException>(
|
||||
delegate() { testQueue.Dequeue(); }
|
||||
);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
|
|
@ -81,28 +81,34 @@ namespace Nuclex.Support.Collections {
|
|||
/// <summary>
|
||||
/// Ensures that the Add() method of the read only collection throws an exception
|
||||
/// </summary>
|
||||
[Test, ExpectedException(typeof(NotSupportedException))]
|
||||
[Test]
|
||||
public void TestThrowOnAdd() {
|
||||
ReadOnlyCollection<int> testCollection = new ReadOnlyCollection<int>(new int[0]);
|
||||
(testCollection as ICollection<int>).Add(123);
|
||||
Assert.Throws<NotSupportedException>(
|
||||
delegate() { (testCollection as ICollection<int>).Add(123); }
|
||||
);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Ensures that the Remove() method of the read only collection throws an exception
|
||||
/// </summary>
|
||||
[Test, ExpectedException(typeof(NotSupportedException))]
|
||||
[Test]
|
||||
public void TestThrowOnRemove() {
|
||||
ReadOnlyCollection<int> testCollection = new ReadOnlyCollection<int>(new int[0]);
|
||||
(testCollection as ICollection<int>).Remove(123);
|
||||
Assert.Throws<NotSupportedException>(
|
||||
delegate() { (testCollection as ICollection<int>).Remove(123); }
|
||||
);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Ensures that the Clear() method of the read only collection throws an exception
|
||||
/// </summary>
|
||||
[Test, ExpectedException(typeof(NotSupportedException))]
|
||||
[Test]
|
||||
public void TestThrowOnClear() {
|
||||
ReadOnlyCollection<int> testCollection = new ReadOnlyCollection<int>(new int[0]);
|
||||
(testCollection as ICollection<int>).Clear();
|
||||
Assert.Throws<NotSupportedException>(
|
||||
delegate() { (testCollection as ICollection<int>).Clear(); }
|
||||
);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
@ -118,7 +124,7 @@ namespace Nuclex.Support.Collections {
|
|||
outputIntegers.Add(value);
|
||||
}
|
||||
|
||||
CollectionAssert.AreEqual(inputIntegers, outputIntegers);
|
||||
CollectionAssert.AreEqual(inputIntegers, outputIntegers);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
|
|
@ -174,37 +174,42 @@ namespace Nuclex.Support.Collections {
|
|||
/// Tests whether an exception is thrown if the indexer of the read only dictionary
|
||||
/// is used to attempt to retrieve a non-existing value
|
||||
/// </summary>
|
||||
[Test, ExpectedException(typeof(KeyNotFoundException))]
|
||||
[Test]
|
||||
public void TestThrowOnRetrieveNonExistingValueByIndexer() {
|
||||
Dictionary<int, string> numbers = createTestDictionary();
|
||||
ReadOnlyDictionary<int, string> testDictionary = makeReadOnly(numbers);
|
||||
|
||||
string numberName = testDictionary[24];
|
||||
Console.WriteLine(numberName);
|
||||
Assert.Throws<KeyNotFoundException>(
|
||||
delegate() { Console.WriteLine(testDictionary[24]); }
|
||||
);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Checks whether the read only dictionary will throw an exception if its
|
||||
/// Add() method is called via the generic IDictionary<> interface
|
||||
/// </summary>
|
||||
[Test, ExpectedException(typeof(NotSupportedException))]
|
||||
[Test]
|
||||
public void TestThrowOnAddViaGenericIDictionary() {
|
||||
Dictionary<int, string> numbers = createTestDictionary();
|
||||
ReadOnlyDictionary<int, string> testDictionary = makeReadOnly(numbers);
|
||||
|
||||
(testDictionary as IDictionary<int, string>).Add(10, "ten");
|
||||
Assert.Throws<NotSupportedException>(
|
||||
delegate() { (testDictionary as IDictionary<int, string>).Add(10, "ten"); }
|
||||
);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Checks whether the read only dictionary will throw an exception if its
|
||||
/// Remove() method is called via the generic IDictionary<> interface
|
||||
/// </summary>
|
||||
[Test, ExpectedException(typeof(NotSupportedException))]
|
||||
[Test]
|
||||
public void TestThrowOnRemoveViaGenericIDictionary() {
|
||||
Dictionary<int, string> numbers = createTestDictionary();
|
||||
ReadOnlyDictionary<int, string> testDictionary = makeReadOnly(numbers);
|
||||
|
||||
(testDictionary as IDictionary<int, string>).Remove(3);
|
||||
Assert.Throws<NotSupportedException>(
|
||||
delegate() { (testDictionary as IDictionary<int, string>).Remove(3); }
|
||||
);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
@ -222,36 +227,42 @@ namespace Nuclex.Support.Collections {
|
|||
/// Checks whether the read only dictionary will throw an exception if its
|
||||
/// indexer is used to insert an item via the generic IDictionar<> interface
|
||||
/// </summary>
|
||||
[Test, ExpectedException(typeof(NotSupportedException))]
|
||||
[Test]
|
||||
public void TestThrowOnReplaceByIndexerViaGenericIDictionary() {
|
||||
Dictionary<int, string> numbers = createTestDictionary();
|
||||
ReadOnlyDictionary<int, string> testDictionary = makeReadOnly(numbers);
|
||||
|
||||
(testDictionary as IDictionary<int, string>)[24] = "twenty-four";
|
||||
Assert.Throws<NotSupportedException>(
|
||||
delegate() { (testDictionary as IDictionary<int, string>)[24] = "twenty-four"; }
|
||||
);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Checks whether the read only dictionary will throw an exception if its
|
||||
/// Clear() method is called via the IDictionary interface
|
||||
/// </summary>
|
||||
[Test, ExpectedException(typeof(NotSupportedException))]
|
||||
[Test]
|
||||
public void TestThrowOnClearViaIDictionary() {
|
||||
Dictionary<int, string> numbers = createTestDictionary();
|
||||
ReadOnlyDictionary<int, string> testDictionary = makeReadOnly(numbers);
|
||||
|
||||
(testDictionary as IDictionary).Clear();
|
||||
Assert.Throws<NotSupportedException>(
|
||||
delegate() { (testDictionary as IDictionary).Clear(); }
|
||||
);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Checks whether the read only dictionary will throw an exception if its
|
||||
/// Add() method is called via the IDictionary interface
|
||||
/// </summary>
|
||||
[Test, ExpectedException(typeof(NotSupportedException))]
|
||||
[Test]
|
||||
public void TestThrowOnAddViaIDictionary() {
|
||||
Dictionary<int, string> numbers = createTestDictionary();
|
||||
ReadOnlyDictionary<int, string> testDictionary = makeReadOnly(numbers);
|
||||
|
||||
(testDictionary as IDictionary).Add(24, "twenty-four");
|
||||
|
||||
Assert.Throws<NotSupportedException>(
|
||||
delegate() { (testDictionary as IDictionary).Add(24, "twenty-four"); }
|
||||
);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
@ -328,12 +339,14 @@ namespace Nuclex.Support.Collections {
|
|||
/// Checks whether the read only dictionary will throw an exception if its
|
||||
/// Remove() method is called via the IDictionary interface
|
||||
/// </summary>
|
||||
[Test, ExpectedException(typeof(NotSupportedException))]
|
||||
[Test]
|
||||
public void TestThrowOnRemoveViaIDictionary() {
|
||||
Dictionary<int, string> numbers = createTestDictionary();
|
||||
ReadOnlyDictionary<int, string> testDictionary = makeReadOnly(numbers);
|
||||
|
||||
(testDictionary as IDictionary).Remove(3);
|
||||
Assert.Throws<NotSupportedException>(
|
||||
delegate() { (testDictionary as IDictionary).Remove(3); }
|
||||
);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
@ -352,25 +365,31 @@ namespace Nuclex.Support.Collections {
|
|||
/// Checks whether the read only dictionary will throw an exception if its
|
||||
/// indexer is used to insert an item via the IDictionary interface
|
||||
/// </summary>
|
||||
[Test, ExpectedException(typeof(NotSupportedException))]
|
||||
[Test]
|
||||
public void TestThrowOnReplaceByIndexerViaIDictionary() {
|
||||
Dictionary<int, string> numbers = createTestDictionary();
|
||||
ReadOnlyDictionary<int, string> testDictionary = makeReadOnly(numbers);
|
||||
|
||||
(testDictionary as IDictionary)[24] = "twenty-four";
|
||||
Assert.Throws<NotSupportedException>(
|
||||
delegate() { (testDictionary as IDictionary)[24] = "twenty-four"; }
|
||||
);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Checks whether the read only dictionary will throw an exception if its
|
||||
/// Add() method is used via the generic ICollection<> interface
|
||||
/// </summary>
|
||||
[Test, ExpectedException(typeof(NotSupportedException))]
|
||||
[Test]
|
||||
public void TestThrowOnAddViaGenericICollection() {
|
||||
Dictionary<int, string> numbers = createTestDictionary();
|
||||
ReadOnlyDictionary<int, string> testDictionary = makeReadOnly(numbers);
|
||||
|
||||
(testDictionary as ICollection<KeyValuePair<int, string>>).Add(
|
||||
new KeyValuePair<int, string>(24, "twenty-four")
|
||||
Assert.Throws<NotSupportedException>(
|
||||
delegate() {
|
||||
(testDictionary as ICollection<KeyValuePair<int, string>>).Add(
|
||||
new KeyValuePair<int, string>(24, "twenty-four")
|
||||
);
|
||||
}
|
||||
);
|
||||
}
|
||||
|
||||
|
@ -378,25 +397,31 @@ namespace Nuclex.Support.Collections {
|
|||
/// Checks whether the read only dictionary will throw an exception if its
|
||||
/// Clear() method is used via the generic ICollection<> interface
|
||||
/// </summary>
|
||||
[Test, ExpectedException(typeof(NotSupportedException))]
|
||||
[Test]
|
||||
public void TestThrowOnClearViaGenericICollection() {
|
||||
Dictionary<int, string> numbers = createTestDictionary();
|
||||
ReadOnlyDictionary<int, string> testDictionary = makeReadOnly(numbers);
|
||||
|
||||
(testDictionary as ICollection<KeyValuePair<int, string>>).Clear();
|
||||
Assert.Throws<NotSupportedException>(
|
||||
delegate() { (testDictionary as ICollection<KeyValuePair<int, string>>).Clear(); }
|
||||
);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Checks whether the read only dictionary will throw an exception if its
|
||||
/// Remove() method is used via the generic ICollection<> interface
|
||||
/// </summary>
|
||||
[Test, ExpectedException(typeof(NotSupportedException))]
|
||||
[Test]
|
||||
public void TestThrowOnRemoveViaGenericICollection() {
|
||||
Dictionary<int, string> numbers = createTestDictionary();
|
||||
ReadOnlyDictionary<int, string> testDictionary = makeReadOnly(numbers);
|
||||
|
||||
(testDictionary as ICollection<KeyValuePair<int, string>>).Remove(
|
||||
new KeyValuePair<int, string>(42, "fourty-two")
|
||||
Assert.Throws<NotSupportedException>(
|
||||
delegate() {
|
||||
(testDictionary as ICollection<KeyValuePair<int, string>>).Remove(
|
||||
new KeyValuePair<int, string>(42, "fourty-two")
|
||||
);
|
||||
}
|
||||
);
|
||||
}
|
||||
|
||||
|
|
|
@ -112,20 +112,24 @@ namespace Nuclex.Support.Collections {
|
|||
/// Checks whether the read only list will throw an exception if its Insert() method
|
||||
/// is called via the generic IList<> interface
|
||||
/// </summary>
|
||||
[Test, ExpectedException(typeof(NotSupportedException))]
|
||||
[Test]
|
||||
public void TestThrowOnInsertViaGenericIList() {
|
||||
ReadOnlyList<int> testList = new ReadOnlyList<int>(new int[0]);
|
||||
(testList as IList<int>).Insert(0, 12345);
|
||||
Assert.Throws<NotSupportedException>(
|
||||
delegate() { (testList as IList<int>).Insert(0, 12345); }
|
||||
);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Checks whether the read only list will throw an exception if its RemoveAt() method
|
||||
/// is called via the generic IList<> interface
|
||||
/// </summary>
|
||||
[Test, ExpectedException(typeof(NotSupportedException))]
|
||||
[Test]
|
||||
public void TestThrowOnRemoveViaGenericIList() {
|
||||
ReadOnlyList<int> testList = new ReadOnlyList<int>(new int[1]);
|
||||
(testList as IList<int>).RemoveAt(0);
|
||||
Assert.Throws<NotSupportedException>(
|
||||
delegate() { (testList as IList<int>).RemoveAt(0); }
|
||||
);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
@ -147,43 +151,51 @@ namespace Nuclex.Support.Collections {
|
|||
/// Checks whether the indexer method of the read only list will throw an exception
|
||||
/// if it is attempted to be used for replacing an item
|
||||
/// </summary>
|
||||
[Test, ExpectedException(typeof(NotSupportedException))]
|
||||
[Test]
|
||||
public void TestThrowOnReplaceByIndexerViaGenericIList() {
|
||||
ReadOnlyList<int> testList = new ReadOnlyList<int>(new int[1]);
|
||||
|
||||
(testList as IList<int>)[0] = 12345;
|
||||
Assert.Throws<NotSupportedException>(
|
||||
delegate() { (testList as IList<int>)[0] = 12345; }
|
||||
);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Checks whether the read only list will throw an exception if its Add() method
|
||||
/// is called via the generic ICollection<> interface
|
||||
/// </summary>
|
||||
[Test, ExpectedException(typeof(NotSupportedException))]
|
||||
[Test]
|
||||
public void TestThrowOnAddViaGenericICollection() {
|
||||
ReadOnlyList<int> testList = new ReadOnlyList<int>(new int[0]);
|
||||
(testList as ICollection<int>).Add(12345);
|
||||
Assert.Throws<NotSupportedException>(
|
||||
delegate() { (testList as ICollection<int>).Add(12345); }
|
||||
);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Checks whether the read only list will throw an exception if its Clear() method
|
||||
/// is called via the generic ICollection<> interface
|
||||
/// </summary>
|
||||
[Test, ExpectedException(typeof(NotSupportedException))]
|
||||
[Test]
|
||||
public void TestThrowOnClearViaGenericICollection() {
|
||||
ReadOnlyList<int> testList = new ReadOnlyList<int>(new int[1]);
|
||||
(testList as ICollection<int>).Clear();
|
||||
Assert.Throws<NotSupportedException>(
|
||||
delegate() { (testList as ICollection<int>).Clear(); }
|
||||
);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Checks whether the read only list will throw an exception if its Remove() method
|
||||
/// is called via the generic ICollection<> interface
|
||||
/// </summary>
|
||||
[Test, ExpectedException(typeof(NotSupportedException))]
|
||||
[Test]
|
||||
public void TestThrowOnRemoveViaGenericICollection() {
|
||||
int[] integers = new int[] { 12, 34, 67, 89 };
|
||||
ReadOnlyList<int> testList = new ReadOnlyList<int>(integers);
|
||||
|
||||
(testList as ICollection<int>).Remove(89);
|
||||
Assert.Throws<NotSupportedException>(
|
||||
delegate() { (testList as ICollection<int>).Remove(89); }
|
||||
);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
@ -206,20 +218,24 @@ namespace Nuclex.Support.Collections {
|
|||
/// Checks whether the read only list will throw an exception if its Clear() method
|
||||
/// is called via the IList interface
|
||||
/// </summary>
|
||||
[Test, ExpectedException(typeof(NotSupportedException))]
|
||||
[Test]
|
||||
public void TestThrowOnClearViaIList() {
|
||||
ReadOnlyList<int> testList = new ReadOnlyList<int>(new int[1]);
|
||||
(testList as IList).Clear();
|
||||
Assert.Throws<NotSupportedException>(
|
||||
delegate() { (testList as IList).Clear(); }
|
||||
);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Checks whether the read only list will throw an exception if its Add() method
|
||||
/// is called via the IList interface
|
||||
/// </summary>
|
||||
[Test, ExpectedException(typeof(NotSupportedException))]
|
||||
[Test]
|
||||
public void TestThrowOnAddViaIList() {
|
||||
ReadOnlyList<int> testList = new ReadOnlyList<int>(new int[0]);
|
||||
(testList as IList).Add(12345);
|
||||
Assert.Throws<NotSupportedException>(
|
||||
delegate() { (testList as IList).Add(12345); }
|
||||
);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
@ -254,10 +270,12 @@ namespace Nuclex.Support.Collections {
|
|||
/// Checks whether the read only list will throw an exception if its Insert() method
|
||||
/// is called via the IList interface
|
||||
/// </summary>
|
||||
[Test, ExpectedException(typeof(NotSupportedException))]
|
||||
[Test]
|
||||
public void TestThrowOnInsertViaIList() {
|
||||
ReadOnlyList<int> testList = new ReadOnlyList<int>(new int[0]);
|
||||
(testList as IList).Insert(0, 12345);
|
||||
Assert.Throws<NotSupportedException>(
|
||||
delegate() { (testList as IList).Insert(0, 12345); }
|
||||
);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
@ -276,23 +294,27 @@ namespace Nuclex.Support.Collections {
|
|||
/// Checks whether the read only list will throw an exception if its Remove() method
|
||||
/// is called via the IList interface
|
||||
/// </summary>
|
||||
[Test, ExpectedException(typeof(NotSupportedException))]
|
||||
[Test]
|
||||
public void TestThrowOnRemoveViaIList() {
|
||||
int[] integers = new int[] { 1234, 6789 };
|
||||
ReadOnlyList<int> testList = new ReadOnlyList<int>(integers);
|
||||
|
||||
(testList as IList).Remove(6789);
|
||||
Assert.Throws<NotSupportedException>(
|
||||
delegate() { (testList as IList).Remove(6789); }
|
||||
);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Checks whether the read only list will throw an exception if its Remove() method
|
||||
/// is called via the IList interface
|
||||
/// </summary>
|
||||
[Test, ExpectedException(typeof(NotSupportedException))]
|
||||
[Test]
|
||||
public void TestThrowOnRemoveAtViaIList() {
|
||||
ReadOnlyList<int> testList = new ReadOnlyList<int>(new int[1]);
|
||||
|
||||
(testList as IList).RemoveAt(0);
|
||||
Assert.Throws<NotSupportedException>(
|
||||
delegate() { (testList as IList).RemoveAt(0); }
|
||||
);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
@ -314,11 +336,13 @@ namespace Nuclex.Support.Collections {
|
|||
/// Checks whether the indexer method of the read only list will throw an exception
|
||||
/// if it is attempted to be used for replacing an item
|
||||
/// </summary>
|
||||
[Test, ExpectedException(typeof(NotSupportedException))]
|
||||
[Test]
|
||||
public void TestThrowOnReplaceByIndexerViaIList() {
|
||||
ReadOnlyList<int> testList = new ReadOnlyList<int>(new int[1]);
|
||||
|
||||
(testList as IList)[0] = 12345;
|
||||
Assert.Throws<NotSupportedException>(
|
||||
delegate() { (testList as IList)[0] = 12345; }
|
||||
);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
|
|
@ -102,13 +102,15 @@ namespace Nuclex.Support.Collections {
|
|||
/// Verifies that the CopyTo() method of the transforming read only collection throws
|
||||
/// an exception if the target array is too small to hold the collection's contents
|
||||
/// </summary>
|
||||
[Test, ExpectedException(typeof(ArgumentException))]
|
||||
[Test]
|
||||
public void TestThrowOnCopyToTooSmallArray() {
|
||||
int[] inputIntegers = new int[] { 12, 34, 56, 78 };
|
||||
StringTransformer testCollection = new StringTransformer(inputIntegers);
|
||||
|
||||
string[] outputStrings = new string[testCollection.Count - 1];
|
||||
testCollection.CopyTo(outputStrings, 0);
|
||||
Assert.Throws<ArgumentException>(
|
||||
delegate() { testCollection.CopyTo(outputStrings, 0); }
|
||||
);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
@ -203,20 +205,24 @@ namespace Nuclex.Support.Collections {
|
|||
/// Checks whether the transforming read only collection will throw an exception
|
||||
/// if its Insert() method is called via the generic IList<> interface
|
||||
/// </summary>
|
||||
[Test, ExpectedException(typeof(NotSupportedException))]
|
||||
[Test]
|
||||
public void TestThrowOnInsertViaGenericIList() {
|
||||
StringTransformer testCollection = new StringTransformer(new int[0]);
|
||||
(testCollection as IList<string>).Insert(0, "12345");
|
||||
Assert.Throws<NotSupportedException>(
|
||||
delegate() { (testCollection as IList<string>).Insert(0, "12345"); }
|
||||
);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Checks whether the transforming read only collection will throw an exception
|
||||
/// if its RemoveAt() method is called via the generic IList<> interface
|
||||
/// </summary>
|
||||
[Test, ExpectedException(typeof(NotSupportedException))]
|
||||
[Test]
|
||||
public void TestThrowOnRemoveViaGenericIList() {
|
||||
StringTransformer testCollection = new StringTransformer(new int[1]);
|
||||
(testCollection as IList<string>).RemoveAt(0);
|
||||
Assert.Throws<NotSupportedException>(
|
||||
delegate() { (testCollection as IList<string>).RemoveAt(0); }
|
||||
);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
@ -238,43 +244,51 @@ namespace Nuclex.Support.Collections {
|
|||
/// Checks whether the indexer method of the transforming read only collection
|
||||
/// will throw an exception if it is attempted to be used for replacing an item
|
||||
/// </summary>
|
||||
[Test, ExpectedException(typeof(NotSupportedException))]
|
||||
[Test]
|
||||
public void TestThrowOnReplaceByIndexerViaGenericIList() {
|
||||
StringTransformer testCollection = new StringTransformer(new int[1]);
|
||||
|
||||
(testCollection as IList<string>)[0] = "12345";
|
||||
Assert.Throws<NotSupportedException>(
|
||||
delegate() { (testCollection as IList<string>)[0] = "12345"; }
|
||||
);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Checks whether the transforming read only collection will throw an exception
|
||||
/// if its Add() method is called via the generic ICollection<> interface
|
||||
/// </summary>
|
||||
[Test, ExpectedException(typeof(NotSupportedException))]
|
||||
[Test]
|
||||
public void TestThrowOnAddViaGenericICollection() {
|
||||
StringTransformer testCollection = new StringTransformer(new int[0]);
|
||||
(testCollection as ICollection<string>).Add("12345");
|
||||
Assert.Throws<NotSupportedException>(
|
||||
delegate() { (testCollection as ICollection<string>).Add("12345"); }
|
||||
);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Checks whether the transforming read only collection will throw an exception
|
||||
/// if its Clear() method is called via the generic ICollection<> interface
|
||||
/// </summary>
|
||||
[Test, ExpectedException(typeof(NotSupportedException))]
|
||||
[Test]
|
||||
public void TestThrowOnClearViaGenericICollection() {
|
||||
StringTransformer testCollection = new StringTransformer(new int[1]);
|
||||
(testCollection as ICollection<string>).Clear();
|
||||
Assert.Throws<NotSupportedException>(
|
||||
delegate() { (testCollection as ICollection<string>).Clear(); }
|
||||
);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Checks whether the transforming read only collection will throw an exception
|
||||
/// if its Remove() method is called via the generic ICollection<> interface
|
||||
/// </summary>
|
||||
[Test, ExpectedException(typeof(NotSupportedException))]
|
||||
[Test]
|
||||
public void TestThrowOnRemoveViaGenericICollection() {
|
||||
int[] integers = new int[] { 12, 34, 67, 89 };
|
||||
StringTransformer testCollection = new StringTransformer(integers);
|
||||
|
||||
(testCollection as ICollection<string>).Remove("89");
|
||||
Assert.Throws<NotSupportedException>(
|
||||
delegate() { (testCollection as ICollection<string>).Remove("89"); }
|
||||
);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
@ -298,20 +312,24 @@ namespace Nuclex.Support.Collections {
|
|||
/// Checks whether the transforming read only collection will throw an exception
|
||||
/// if its Clear() method is called via the IList interface
|
||||
/// </summary>
|
||||
[Test, ExpectedException(typeof(NotSupportedException))]
|
||||
[Test]
|
||||
public void TestThrowOnClearViaIList() {
|
||||
StringTransformer testCollection = new StringTransformer(new int[1]);
|
||||
(testCollection as IList).Clear();
|
||||
Assert.Throws<NotSupportedException>(
|
||||
delegate() { (testCollection as IList).Clear(); }
|
||||
);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Checks whether the transforming read only collection will throw an exception
|
||||
/// if its Add() method is called via the IList interface
|
||||
/// </summary>
|
||||
[Test, ExpectedException(typeof(NotSupportedException))]
|
||||
[Test]
|
||||
public void TestThrowOnAddViaIList() {
|
||||
StringTransformer testCollection = new StringTransformer(new int[0]);
|
||||
(testCollection as IList).Add("12345");
|
||||
Assert.Throws<NotSupportedException>(
|
||||
delegate() { (testCollection as IList).Add("12345"); }
|
||||
);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
@ -346,10 +364,12 @@ namespace Nuclex.Support.Collections {
|
|||
/// Checks whether the transforming read only collection will throw an exception
|
||||
/// if its Insert() method is called via the IList interface
|
||||
/// </summary>
|
||||
[Test, ExpectedException(typeof(NotSupportedException))]
|
||||
[Test]
|
||||
public void TestThrowOnInsertViaIList() {
|
||||
StringTransformer testCollection = new StringTransformer(new int[0]);
|
||||
(testCollection as IList).Insert(0, "12345");
|
||||
Assert.Throws<NotSupportedException>(
|
||||
delegate() { (testCollection as IList).Insert(0, "12345"); }
|
||||
);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
@ -369,23 +389,27 @@ namespace Nuclex.Support.Collections {
|
|||
/// Checks whether the transforming read only collection will throw an exception
|
||||
/// if its Remove() method is called via the IList interface
|
||||
/// </summary>
|
||||
[Test, ExpectedException(typeof(NotSupportedException))]
|
||||
[Test]
|
||||
public void TestThrowOnRemoveViaIList() {
|
||||
int[] integers = new int[] { 1234, 6789 };
|
||||
StringTransformer testCollection = new StringTransformer(integers);
|
||||
|
||||
(testCollection as IList).Remove("6789");
|
||||
Assert.Throws<NotSupportedException>(
|
||||
delegate() { (testCollection as IList).Remove("6789"); }
|
||||
);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Checks whether the transforming read only collection will throw an exception
|
||||
/// if its Remove() method is called via the IList interface
|
||||
/// </summary>
|
||||
[Test, ExpectedException(typeof(NotSupportedException))]
|
||||
[Test]
|
||||
public void TestThrowOnRemoveAtViaIList() {
|
||||
StringTransformer testCollection = new StringTransformer(new int[1]);
|
||||
|
||||
(testCollection as IList).RemoveAt(0);
|
||||
Assert.Throws<NotSupportedException>(
|
||||
delegate() { (testCollection as IList).RemoveAt(0); }
|
||||
);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
@ -407,11 +431,13 @@ namespace Nuclex.Support.Collections {
|
|||
/// Checks whether the indexer method of the transforming read only collection
|
||||
/// will throw an exception if it is attempted to be used for replacing an item
|
||||
/// </summary>
|
||||
[Test, ExpectedException(typeof(NotSupportedException))]
|
||||
[Test]
|
||||
public void TestThrowOnReplaceByIndexerViaIList() {
|
||||
StringTransformer testCollection = new StringTransformer(new int[1]);
|
||||
|
||||
(testCollection as IList)[0] = "12345";
|
||||
Assert.Throws<NotSupportedException>(
|
||||
delegate() { (testCollection as IList)[0] = "12345"; }
|
||||
);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
|
|
@ -104,13 +104,15 @@ namespace Nuclex.Support.Collections {
|
|||
/// Test whether the non-typesafe Add() method throws an exception if an object is
|
||||
/// added that is not compatible to the collection's item type
|
||||
/// </summary>
|
||||
[Test, ExpectedException(typeof(ArgumentException))]
|
||||
[Test]
|
||||
public void TestThrowOnAddIncompatibleObject() {
|
||||
WeakCollection<Dummy> dummies = new WeakCollection<Dummy>(
|
||||
new List<WeakReference<Dummy>>()
|
||||
);
|
||||
|
||||
(dummies as IList).Add(new object());
|
||||
Assert.Throws<ArgumentException>(
|
||||
delegate() { (dummies as IList).Add(new object()); }
|
||||
);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
@ -243,13 +245,15 @@ namespace Nuclex.Support.Collections {
|
|||
/// Verifies that an exception is thrown if an incompatible object is passed to
|
||||
/// the non-typesafe variant of the IndexOf() method
|
||||
/// </summary>
|
||||
[Test, ExpectedException(typeof(ArgumentException))]
|
||||
[Test]
|
||||
public void TestThrowOnIndexOfWithIncompatibleObject() {
|
||||
WeakCollection<Dummy> dummies = new WeakCollection<Dummy>(
|
||||
new List<WeakReference<Dummy>>()
|
||||
);
|
||||
|
||||
Assert.IsNull((dummies as IList).IndexOf(new object()));
|
||||
Assert.Throws<ArgumentException>(
|
||||
delegate() { Assert.IsNull((dummies as IList).IndexOf(new object())); }
|
||||
);
|
||||
}
|
||||
|
||||
/// <summary>Test whether the IndexOf() method can cope with null references</summary>
|
||||
|
@ -289,7 +293,7 @@ namespace Nuclex.Support.Collections {
|
|||
/// Verifies that the CopyTo() method of the weak collection throws an exception
|
||||
/// if the target array is too small to hold the collection's contents
|
||||
/// </summary>
|
||||
[Test, ExpectedException(typeof(ArgumentException))]
|
||||
[Test]
|
||||
public void TestThrowOnCopyToTooSmallArray() {
|
||||
WeakCollection<Dummy> dummies = new WeakCollection<Dummy>(
|
||||
new List<WeakReference<Dummy>>()
|
||||
|
@ -300,7 +304,9 @@ namespace Nuclex.Support.Collections {
|
|||
dummies.Add(fourFiveSixDummy);
|
||||
|
||||
Dummy[] outputStrings = new Dummy[dummies.Count - 1];
|
||||
dummies.CopyTo(outputStrings, 0);
|
||||
Assert.Throws<ArgumentException>(
|
||||
delegate() { dummies.CopyTo(outputStrings, 0); }
|
||||
);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
@ -368,7 +374,7 @@ namespace Nuclex.Support.Collections {
|
|||
/// Verifies that the non-typesafe Insert() method correctly shifts items in
|
||||
/// the collection
|
||||
/// </summary>
|
||||
[Test, ExpectedException(typeof(ArgumentException))]
|
||||
[Test]
|
||||
public void TestThrowOnInsertIncompatibleObject() {
|
||||
WeakCollection<Dummy> dummies = new WeakCollection<Dummy>(
|
||||
new List<WeakReference<Dummy>>()
|
||||
|
@ -377,7 +383,9 @@ namespace Nuclex.Support.Collections {
|
|||
dummies.Add(oneTwoThreeDummy);
|
||||
|
||||
Dummy fourFiveSixDummy = new Dummy(456);
|
||||
(dummies as IList).Insert(0, new object());
|
||||
Assert.Throws<ArgumentException>(
|
||||
delegate() { (dummies as IList).Insert(0, new object()); }
|
||||
);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
@ -476,7 +484,7 @@ namespace Nuclex.Support.Collections {
|
|||
/// Tests whether the non-typesafe indexer of the weak collection throws
|
||||
/// the correct exception if an incompatible object is assigned
|
||||
/// </summary>
|
||||
[Test, ExpectedException(typeof(ArgumentException))]
|
||||
[Test]
|
||||
public void TestThrowOnIndexerWithIncompatibleObject() {
|
||||
WeakCollection<Dummy> dummies = new WeakCollection<Dummy>(
|
||||
new List<WeakReference<Dummy>>()
|
||||
|
@ -484,7 +492,9 @@ namespace Nuclex.Support.Collections {
|
|||
Dummy oneTwoThreeDummy = new Dummy(123);
|
||||
dummies.Add(oneTwoThreeDummy);
|
||||
|
||||
(dummies as IList)[0] = new object();
|
||||
Assert.Throws<ArgumentException>(
|
||||
delegate() { (dummies as IList)[0] = new object(); }
|
||||
);
|
||||
}
|
||||
|
||||
/// <summary>Tests the Remove() method of the weak collection</summary>
|
||||
|
@ -540,12 +550,14 @@ namespace Nuclex.Support.Collections {
|
|||
/// an exception if an object is tried to be removed that is incompatible with
|
||||
/// the collection's item type
|
||||
/// </summary>
|
||||
[Test, ExpectedException(typeof(ArgumentException))]
|
||||
[Test]
|
||||
public void TestThrowOnRemoveIncompatibleObject() {
|
||||
WeakCollection<Dummy> dummies = new WeakCollection<Dummy>(
|
||||
new List<WeakReference<Dummy>>()
|
||||
);
|
||||
(dummies as IList).Remove(new object());
|
||||
Assert.Throws<ArgumentException>(
|
||||
delegate() { (dummies as IList).Remove(new object()); }
|
||||
);
|
||||
}
|
||||
|
||||
/// <summary>Tests the RemoveAt() method of the weak collection</summary>
|
||||
|
|
|
@ -323,35 +323,39 @@ namespace Nuclex.Support.IO {
|
|||
/// <summary>
|
||||
/// Tests reading from a stream chainer that contains an unreadable stream
|
||||
/// </summary>
|
||||
[Test, ExpectedException(typeof(NotSupportedException))]
|
||||
[Test]
|
||||
public void TestThrowOnReadFromUnreadableStream() {
|
||||
MemoryStream memoryStream = new MemoryStream();
|
||||
TestStream testStream = new TestStream(memoryStream, false, true, true);
|
||||
ChainStream chainer = new ChainStream(new Stream[] { testStream });
|
||||
|
||||
chainer.Read(new byte[5], 0, 5);
|
||||
Assert.Throws<NotSupportedException>(
|
||||
delegate() { chainer.Read(new byte[5], 0, 5); }
|
||||
);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Tests writing to a stream chainer that contains an unwriteable stream
|
||||
/// </summary>
|
||||
[Test, ExpectedException(typeof(NotSupportedException))]
|
||||
[Test]
|
||||
public void TestThrowOnWriteToUnwriteableStream() {
|
||||
MemoryStream memoryStream = new MemoryStream();
|
||||
TestStream testStream = new TestStream(memoryStream, true, false, true);
|
||||
ChainStream chainer = new ChainStream(new Stream[] { testStream });
|
||||
|
||||
chainer.Write(new byte[] { 1, 2, 3, 4, 5 }, 0, 5);
|
||||
Assert.Throws<NotSupportedException>(
|
||||
delegate() { chainer.Write(new byte[] { 1, 2, 3, 4, 5 }, 0, 5); }
|
||||
);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Verifies that the stream chainer throws an exception if the attempt is
|
||||
/// made to change the length of the stream
|
||||
/// </summary>
|
||||
[Test, ExpectedException(typeof(NotSupportedException))]
|
||||
[Test]
|
||||
public void TestThrowOnLengthChange() {
|
||||
ChainStream chainer = chainTwoStreamsOfTenBytes();
|
||||
chainer.SetLength(123);
|
||||
Assert.Throws<NotSupportedException>(
|
||||
delegate() { chainer.SetLength(123); }
|
||||
);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
@ -409,52 +413,60 @@ namespace Nuclex.Support.IO {
|
|||
/// Tests whether an exception is thrown if the Seek() method is called on
|
||||
/// a stream chainer with streams that do not support seeking
|
||||
/// </summary>
|
||||
[Test, ExpectedException(typeof(NotSupportedException))]
|
||||
[Test]
|
||||
public void TestThrowOnSeekWithUnseekableStream() {
|
||||
MemoryStream memoryStream = new MemoryStream();
|
||||
TestStream testStream = new TestStream(memoryStream, true, true, false);
|
||||
|
||||
ChainStream chainer = new ChainStream(new Stream[] { testStream });
|
||||
chainer.Seek(123, SeekOrigin.Begin);
|
||||
Assert.Throws<NotSupportedException>(
|
||||
delegate() { chainer.Seek(123, SeekOrigin.Begin); }
|
||||
);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Tests whether an exception is thrown if the Position property is retrieved
|
||||
/// on a stream chainer with streams that do not support seeking
|
||||
/// </summary>
|
||||
[Test, ExpectedException(typeof(NotSupportedException))]
|
||||
[Test]
|
||||
public void TestThrowOnGetPositionWithUnseekableStream() {
|
||||
MemoryStream memoryStream = new MemoryStream();
|
||||
TestStream testStream = new TestStream(memoryStream, true, true, false);
|
||||
|
||||
ChainStream chainer = new ChainStream(new Stream[] { testStream });
|
||||
Assert.IsTrue(chainer.Position != chainer.Position); // ;-)
|
||||
Assert.Throws<NotSupportedException>(
|
||||
delegate() { Console.WriteLine(chainer.Position); }
|
||||
);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Tests whether an exception is thrown if the Position property is set
|
||||
/// on a stream chainer with streams that do not support seeking
|
||||
/// </summary>
|
||||
[Test, ExpectedException(typeof(NotSupportedException))]
|
||||
[Test]
|
||||
public void TestThrowOnSetPositionWithUnseekableStream() {
|
||||
MemoryStream memoryStream = new MemoryStream();
|
||||
TestStream testStream = new TestStream(memoryStream, true, true, false);
|
||||
|
||||
ChainStream chainer = new ChainStream(new Stream[] { testStream });
|
||||
chainer.Position = 123;
|
||||
Assert.Throws<NotSupportedException>(
|
||||
delegate() { chainer.Position = 123; }
|
||||
);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Tests whether an exception is thrown if the Length property is retrieved
|
||||
/// on a stream chainer with streams that do not support seeking
|
||||
/// </summary>
|
||||
[Test, ExpectedException(typeof(NotSupportedException))]
|
||||
[Test]
|
||||
public void TestThrowOnGetLengthWithUnseekableStream() {
|
||||
MemoryStream memoryStream = new MemoryStream();
|
||||
TestStream testStream = new TestStream(memoryStream, true, true, false);
|
||||
|
||||
ChainStream chainer = new ChainStream(new Stream[] { testStream });
|
||||
Assert.IsTrue(chainer.Length != chainer.Length); // ;-)
|
||||
Assert.Throws<NotSupportedException>(
|
||||
delegate() { Assert.IsTrue(chainer.Length != chainer.Length); }
|
||||
);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
@ -486,10 +498,12 @@ namespace Nuclex.Support.IO {
|
|||
/// Tests whether the Seek() method throws an exception if an invalid
|
||||
/// reference point is provided
|
||||
/// </summary>
|
||||
[Test, ExpectedException(typeof(ArgumentException))]
|
||||
[Test]
|
||||
public void TestThrowOnInvalidSeekReferencePoint() {
|
||||
ChainStream chainer = chainTwoStreamsOfTenBytes();
|
||||
chainer.Seek(1, (SeekOrigin)12345);
|
||||
Assert.Throws<ArgumentException>(
|
||||
delegate() { chainer.Seek(1, (SeekOrigin)12345); }
|
||||
);
|
||||
}
|
||||
|
||||
/// <summary>Verifies that the position property works correctly</summary>
|
||||
|
|
|
@ -207,12 +207,13 @@ namespace Nuclex.Support.IO {
|
|||
/// Verifies that the partial stream constructor throws an exception if
|
||||
/// it's invoked with an invalid start offset
|
||||
/// </summary>
|
||||
[Test, ExpectedException(typeof(ArgumentException))]
|
||||
[Test]
|
||||
public void TestThrowOnInvalidStartInConstructor() {
|
||||
using(MemoryStream memoryStream = new MemoryStream()) {
|
||||
memoryStream.SetLength(123);
|
||||
PartialStream partialStream = new PartialStream(memoryStream, -1, 10);
|
||||
Assert.AreNotEqual(partialStream.Length, partialStream.Length);
|
||||
Assert.Throws<ArgumentException>(
|
||||
delegate() { Console.WriteLine(new PartialStream(memoryStream, -1, 10)); }
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -220,12 +221,13 @@ namespace Nuclex.Support.IO {
|
|||
/// Verifies that the partial stream constructor throws an exception if
|
||||
/// it's invoked with an invalid start offset
|
||||
/// </summary>
|
||||
[Test, ExpectedException(typeof(ArgumentException))]
|
||||
[Test]
|
||||
public void TestThrowOnInvalidLengthInConstructor() {
|
||||
using(MemoryStream memoryStream = new MemoryStream()) {
|
||||
memoryStream.SetLength(123);
|
||||
PartialStream partialStream = new PartialStream(memoryStream, 100, 24);
|
||||
Assert.AreNotEqual(partialStream.Length, partialStream.Length);
|
||||
Assert.Throws<ArgumentException>(
|
||||
delegate() { Console.WriteLine(new PartialStream(memoryStream, 100, 24)); }
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -233,13 +235,14 @@ namespace Nuclex.Support.IO {
|
|||
/// Verifies that the partial stream constructor throws an exception if
|
||||
/// it's invoked with a start offset on an unseekable stream
|
||||
/// </summary>
|
||||
[Test, ExpectedException(typeof(ArgumentException))]
|
||||
[Test]
|
||||
public void TestThrowOnUnseekableStreamWithOffsetInConstructor() {
|
||||
using(MemoryStream memoryStream = new MemoryStream()) {
|
||||
memoryStream.SetLength(123);
|
||||
TestStream testStream = new TestStream(memoryStream, true, true, false);
|
||||
PartialStream partialStream = new PartialStream(testStream, 23, 100);
|
||||
Assert.AreNotEqual(partialStream.Length, partialStream.Length);
|
||||
Assert.Throws<ArgumentException>(
|
||||
delegate() { Console.WriteLine(new PartialStream(testStream, 23, 100)); }
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -351,13 +354,15 @@ namespace Nuclex.Support.IO {
|
|||
/// Tests whether the Position property throws an exception if the stream does
|
||||
/// not support seeking.
|
||||
/// </summary>
|
||||
[Test, ExpectedException(typeof(NotSupportedException))]
|
||||
[Test]
|
||||
public void TestThrowOnGetPositionOnUnseekableStream() {
|
||||
using(MemoryStream memoryStream = new MemoryStream()) {
|
||||
TestStream testStream = new TestStream(memoryStream, true, true, false);
|
||||
|
||||
PartialStream partialStream = new PartialStream(testStream, 0, 0);
|
||||
Assert.AreEqual(-12345, partialStream.Position);
|
||||
Assert.Throws<NotSupportedException>(
|
||||
delegate() { Console.WriteLine(partialStream.Position); }
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -365,13 +370,15 @@ namespace Nuclex.Support.IO {
|
|||
/// Tests whether the Position property throws an exception if the stream does
|
||||
/// not support seeking.
|
||||
/// </summary>
|
||||
[Test, ExpectedException(typeof(NotSupportedException))]
|
||||
[Test]
|
||||
public void TestThrowOnSetPositionOnUnseekableStream() {
|
||||
using(MemoryStream memoryStream = new MemoryStream()) {
|
||||
TestStream testStream = new TestStream(memoryStream, true, true, false);
|
||||
|
||||
PartialStream partialStream = new PartialStream(testStream, 0, 0);
|
||||
partialStream.Position = 0;
|
||||
Assert.Throws<NotSupportedException>(
|
||||
delegate() { partialStream.Position = 0; }
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -379,16 +386,16 @@ namespace Nuclex.Support.IO {
|
|||
/// Tests whether the Read() method throws an exception if the stream does
|
||||
/// not support reading
|
||||
/// </summary>
|
||||
[Test, ExpectedException(typeof(NotSupportedException))]
|
||||
[Test]
|
||||
public void TestThrowOnReadFromUnreadableStream() {
|
||||
using(MemoryStream memoryStream = new MemoryStream()) {
|
||||
TestStream testStream = new TestStream(memoryStream, false, true, true);
|
||||
PartialStream partialStream = new PartialStream(testStream, 0, 0);
|
||||
|
||||
byte[] test = new byte[10];
|
||||
int bytesRead = partialStream.Read(test, 0, 10);
|
||||
|
||||
Assert.AreNotEqual(bytesRead, bytesRead);
|
||||
Assert.Throws<NotSupportedException>(
|
||||
delegate() { Console.WriteLine(partialStream.Read(test, 0, 10)); }
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -411,11 +418,13 @@ namespace Nuclex.Support.IO {
|
|||
/// Tests whether the Seek() method throws an exception if an invalid
|
||||
/// reference point is provided
|
||||
/// </summary>
|
||||
[Test, ExpectedException(typeof(ArgumentException))]
|
||||
[Test]
|
||||
public void TestThrowOnInvalidSeekReferencePoint() {
|
||||
using(MemoryStream memoryStream = new MemoryStream()) {
|
||||
PartialStream partialStream = new PartialStream(memoryStream, 0, 0);
|
||||
partialStream.Seek(1, (SeekOrigin)12345);
|
||||
Assert.Throws<ArgumentException>(
|
||||
delegate() { partialStream.Seek(1, (SeekOrigin)12345); }
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -423,11 +432,13 @@ namespace Nuclex.Support.IO {
|
|||
/// Verifies that the partial stream throws an exception if the attempt is
|
||||
/// made to change the length of the stream
|
||||
/// </summary>
|
||||
[Test, ExpectedException(typeof(NotSupportedException))]
|
||||
[Test]
|
||||
public void TestThrowOnLengthChange() {
|
||||
using(MemoryStream memoryStream = new MemoryStream()) {
|
||||
PartialStream partialStream = new PartialStream(memoryStream, 0, 0);
|
||||
partialStream.SetLength(123);
|
||||
Assert.Throws<NotSupportedException>(
|
||||
delegate() { partialStream.SetLength(123); }
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -497,14 +508,16 @@ namespace Nuclex.Support.IO {
|
|||
/// Verifies that an exception is thrown if the Write() method of the partial stream
|
||||
/// is attempted to be used to extend the partial stream's length
|
||||
/// </summary>
|
||||
[Test, ExpectedException(typeof(NotSupportedException))]
|
||||
[Test]
|
||||
public void TestThrowOnExtendPartialStream() {
|
||||
using(MemoryStream memoryStream = new MemoryStream()) {
|
||||
memoryStream.SetLength(25);
|
||||
|
||||
PartialStream partialStream = new PartialStream(memoryStream, 10, 10);
|
||||
partialStream.Position = 5;
|
||||
partialStream.Write(new byte[] { 1, 2, 3, 4, 5, 6 }, 0, 6);
|
||||
Assert.Throws<NotSupportedException>(
|
||||
delegate() { partialStream.Write(new byte[] { 1, 2, 3, 4, 5, 6 }, 0, 6); }
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -42,9 +42,11 @@ namespace Nuclex.Support.IO {
|
|||
/// <summary>
|
||||
/// Ensures that the ring buffer blocks write attempts that would exceed its capacity
|
||||
/// </summary>
|
||||
[Test, ExpectedException(typeof(OverflowException))]
|
||||
[Test]
|
||||
public void TestWriteTooLargeChunk() {
|
||||
new RingMemoryStream(10).Write(this.testBytes, 0, 11);
|
||||
Assert.Throws<OverflowException>(
|
||||
delegate() { new RingMemoryStream(10).Write(this.testBytes, 0, 11); }
|
||||
);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
@ -93,13 +95,15 @@ namespace Nuclex.Support.IO {
|
|||
/// Ensures that the ring buffer still detects write that would exceed its capacity
|
||||
/// if they write into the gap after the ring buffer's data has become split
|
||||
/// </summary>
|
||||
[Test, ExpectedException(typeof(OverflowException))]
|
||||
[Test]
|
||||
public void TestWriteSplitAndLinearTooLargeBlock() {
|
||||
RingMemoryStream testRing = new RingMemoryStream(10);
|
||||
testRing.Write(this.testBytes, 0, 8);
|
||||
testRing.Read(this.testBytes, 0, 5);
|
||||
testRing.Write(this.testBytes, 0, 5);
|
||||
testRing.Write(this.testBytes, 0, 3);
|
||||
Assert.Throws<OverflowException>(
|
||||
delegate() { testRing.Write(this.testBytes, 0, 3); }
|
||||
);
|
||||
}
|
||||
|
||||
/// <summary>Tests whether the ring buffer correctly handles fragmentation</summary>
|
||||
|
@ -182,12 +186,14 @@ namespace Nuclex.Support.IO {
|
|||
/// Checks that an exception is thrown when the ring buffer's capacity is
|
||||
/// reduced so much it would have to give up some of its contained data
|
||||
/// </summary>
|
||||
[Test, ExpectedException(typeof(ArgumentOutOfRangeException))]
|
||||
[Test]
|
||||
public void TestCapacityDecreaseException() {
|
||||
RingMemoryStream testRing = new RingMemoryStream(20);
|
||||
testRing.Write(this.testBytes, 0, 20);
|
||||
|
||||
testRing.Capacity = 10;
|
||||
Assert.Throws<ArgumentOutOfRangeException>(
|
||||
delegate() { testRing.Capacity = 10; }
|
||||
);
|
||||
}
|
||||
|
||||
/// <summary>Tests whether the Capacity property returns the current capacity</summary>
|
||||
|
@ -238,37 +244,44 @@ namespace Nuclex.Support.IO {
|
|||
/// Verifies that an exception is thrown when the Position property of the ring
|
||||
/// memory stream is used to retrieve the current file pointer position
|
||||
/// </summary>
|
||||
[Test, ExpectedException(typeof(NotSupportedException))]
|
||||
[Test]
|
||||
public void TestThrowOnRetrievePosition() {
|
||||
long position = new RingMemoryStream(10).Position;
|
||||
Console.WriteLine(position.ToString());
|
||||
Assert.Throws<NotSupportedException>(
|
||||
delegate() { Console.WriteLine(new RingMemoryStream(10).Position); }
|
||||
);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Verifies that an exception is thrown when the Position property of the ring
|
||||
/// memory stream is used to modify the current file pointer position
|
||||
/// </summary>
|
||||
[Test, ExpectedException(typeof(NotSupportedException))]
|
||||
[Test]
|
||||
public void TestThrowOnAssignPosition() {
|
||||
new RingMemoryStream(10).Position = 0;
|
||||
Assert.Throws<NotSupportedException>(
|
||||
delegate() { new RingMemoryStream(10).Position = 0; }
|
||||
);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Verifies that an exception is thrown when the Seek() method of the ring memory
|
||||
/// stream is attempted to be used
|
||||
/// </summary>
|
||||
[Test, ExpectedException(typeof(NotSupportedException))]
|
||||
[Test]
|
||||
public void TestThrowOnSeek() {
|
||||
new RingMemoryStream(10).Seek(0, SeekOrigin.Begin);
|
||||
Assert.Throws<NotSupportedException>(
|
||||
delegate() { new RingMemoryStream(10).Seek(0, SeekOrigin.Begin); }
|
||||
);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Verifies that an exception is thrown when the SetLength() method of the ring
|
||||
/// memory stream is attempted to be used
|
||||
/// </summary>
|
||||
[Test, ExpectedException(typeof(NotSupportedException))]
|
||||
[Test]
|
||||
public void TestThrowOnSetLength() {
|
||||
new RingMemoryStream(10).SetLength(10);
|
||||
Assert.Throws<NotSupportedException>(
|
||||
delegate() { new RingMemoryStream(10).SetLength(10); }
|
||||
);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
|
|
@ -95,30 +95,35 @@ namespace Nuclex.Support.Licensing {
|
|||
}
|
||||
|
||||
/// <summary>Tests whether license keys can be modified without destroying them</summary>
|
||||
[Test, ExpectedException(typeof(ArgumentException))]
|
||||
[Test]
|
||||
public void TestParseInvalidLicenseKey() {
|
||||
LicenseKey.Parse("hello world");
|
||||
Assert.Throws<ArgumentException>(
|
||||
delegate() { LicenseKey.Parse("hello world"); }
|
||||
);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Tests whether an exception is thrown if the indexer of a license key is used
|
||||
/// with an invalid index to retrieve a component of the key
|
||||
/// </summary>
|
||||
[Test, ExpectedException(typeof(IndexOutOfRangeException))]
|
||||
[Test]
|
||||
public void TestGetByIndexerWithInvalidIndex() {
|
||||
LicenseKey key = new LicenseKey();
|
||||
int indexMinusOne = key[-1];
|
||||
Console.WriteLine(indexMinusOne.ToString());
|
||||
Assert.Throws<IndexOutOfRangeException>(
|
||||
delegate() { Console.WriteLine(key[-1]); }
|
||||
);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Tests whether an exception is thrown if the indexer of a license key is used
|
||||
/// with an invalid index to set a component of the key
|
||||
/// </summary>
|
||||
[Test, ExpectedException(typeof(IndexOutOfRangeException))]
|
||||
[Test]
|
||||
public void TestSetByIndexerWithInvalidIndex() {
|
||||
LicenseKey key = new LicenseKey();
|
||||
key[-1] = 0;
|
||||
Assert.Throws<IndexOutOfRangeException>(
|
||||
delegate() { key[-1] = 0; }
|
||||
);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
|
|
@ -73,22 +73,26 @@ namespace Nuclex.Support.Plugins {
|
|||
/// Tests whether the factory employer throws an exception when it is asked to
|
||||
/// employ an abstract class
|
||||
/// </summary>
|
||||
[Test, ExpectedException(typeof(MissingMethodException))]
|
||||
[Test]
|
||||
public void TestThrowOnEmployAbstractClass() {
|
||||
FactoryEmployer<Base> testEmployer = new FactoryEmployer<Base>();
|
||||
|
||||
testEmployer.Employ(typeof(Base));
|
||||
Assert.Throws<MissingMethodException>(
|
||||
delegate() { testEmployer.Employ(typeof(Base)); }
|
||||
);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Tests whether the factory employer throws an exception when it is asked to
|
||||
/// employ a class that is not the product type or a derivative thereof
|
||||
/// </summary>
|
||||
[Test, ExpectedException(typeof(InvalidCastException))]
|
||||
[Test]
|
||||
public void TestThrowOnEmployUnrelatedClass() {
|
||||
FactoryEmployer<Base> testEmployer = new FactoryEmployer<Base>();
|
||||
|
||||
testEmployer.Employ(typeof(Unrelated));
|
||||
Assert.Throws<InvalidCastException>(
|
||||
delegate() { testEmployer.Employ(typeof(Unrelated)); }
|
||||
);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
|
|
@ -74,22 +74,26 @@ namespace Nuclex.Support.Plugins {
|
|||
/// Tests whether the instance employer throws an exception when it is asked to
|
||||
/// employ an abstract class
|
||||
/// </summary>
|
||||
[Test, ExpectedException(typeof(MissingMethodException))]
|
||||
[Test]
|
||||
public void TestThrowOnEmployAbstractClass() {
|
||||
InstanceEmployer<Base> testEmployer = new InstanceEmployer<Base>();
|
||||
|
||||
testEmployer.Employ(typeof(Base));
|
||||
Assert.Throws<MissingMethodException>(
|
||||
delegate() { testEmployer.Employ(typeof(Base)); }
|
||||
);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Tests whether the instance employer throws an exception when it is asked to
|
||||
/// employ a class that is not the product type or a derivative thereof
|
||||
/// </summary>
|
||||
[Test, ExpectedException(typeof(InvalidCastException))]
|
||||
[Test]
|
||||
public void TestThrowOnEmployUnrelatedClass() {
|
||||
InstanceEmployer<Base> testEmployer = new InstanceEmployer<Base>();
|
||||
|
||||
testEmployer.Employ(typeof(Unrelated));
|
||||
Assert.Throws<InvalidCastException>(
|
||||
delegate() { testEmployer.Employ(typeof(Unrelated)); }
|
||||
);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
|
|
@ -287,7 +287,7 @@ namespace Nuclex.Support.Scheduling {
|
|||
/// Validates that the operation queue delivers an exception occuring in one of the
|
||||
/// contained operations to the operation queue joiner
|
||||
/// </summary>
|
||||
[Test, ExpectedException(typeof(AbortedException))]
|
||||
[Test]
|
||||
public void TestExceptionPropagation() {
|
||||
TestOperation operation1 = new TestOperation();
|
||||
TestOperation operation2 = new TestOperation();
|
||||
|
@ -307,7 +307,9 @@ namespace Nuclex.Support.Scheduling {
|
|||
Assert.IsFalse(testQueueOperation.Ended);
|
||||
operation2.SetEnded(new AbortedException("Hello World"));
|
||||
|
||||
testQueueOperation.Join();
|
||||
Assert.Throws<AbortedException>(
|
||||
delegate() { testQueueOperation.Join(); }
|
||||
);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
@ -321,7 +323,7 @@ namespace Nuclex.Support.Scheduling {
|
|||
);
|
||||
WeightedTransaction<TestOperation> operation2 = new WeightedTransaction<TestOperation>(
|
||||
new TestOperation()
|
||||
);
|
||||
);
|
||||
|
||||
OperationQueue<TestOperation> testQueueOperation =
|
||||
new OperationQueue<TestOperation>(
|
||||
|
|
|
@ -110,7 +110,7 @@ namespace Nuclex.Support.Scheduling {
|
|||
/// Verifies that the threaded operation forwards an exception that occurred in
|
||||
/// a thread pool thread.
|
||||
/// </summary>
|
||||
[Test, ExpectedException(typeof(AbortedException))]
|
||||
[Test]
|
||||
public void TestForwardExceptionFromThreadPool() {
|
||||
ThreadCallbackOperation test = new ThreadCallbackOperation(
|
||||
new ThreadStart(errorCallback), false
|
||||
|
@ -118,14 +118,16 @@ namespace Nuclex.Support.Scheduling {
|
|||
|
||||
Assert.IsFalse(test.Ended);
|
||||
test.Start();
|
||||
test.Join();
|
||||
Assert.Throws<AbortedException>(
|
||||
delegate() { test.Join(); }
|
||||
);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Verifies that the threaded operation forwards an exception that occurred in
|
||||
/// an explicit thread.
|
||||
/// </summary>
|
||||
[Test, ExpectedException(typeof(AbortedException))]
|
||||
[Test]
|
||||
public void TestForwardExceptionFromExplicitThread() {
|
||||
ThreadCallbackOperation test = new ThreadCallbackOperation(
|
||||
new ThreadStart(errorCallback), false
|
||||
|
@ -133,7 +135,9 @@ namespace Nuclex.Support.Scheduling {
|
|||
|
||||
Assert.IsFalse(test.Ended);
|
||||
test.Start();
|
||||
test.Join();
|
||||
Assert.Throws<AbortedException>(
|
||||
delegate() { test.Join(); }
|
||||
);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
|
|
@ -107,26 +107,30 @@ namespace Nuclex.Support.Scheduling {
|
|||
/// Verifies that the threaded operation forwards an exception that occurred in
|
||||
/// a thread pool thread.
|
||||
/// </summary>
|
||||
[Test, ExpectedException(typeof(AbortedException))]
|
||||
[Test]
|
||||
public void TestForwardExceptionFromThreadPool() {
|
||||
FailingThreadOperation test = new FailingThreadOperation(true);
|
||||
|
||||
Assert.IsFalse(test.Ended);
|
||||
test.Start();
|
||||
test.Join();
|
||||
Assert.Throws<AbortedException>(
|
||||
delegate() { test.Join(); }
|
||||
);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Verifies that the threaded operation forwards an exception that occurred in
|
||||
/// an explicit thread.
|
||||
/// </summary>
|
||||
[Test, ExpectedException(typeof(AbortedException))]
|
||||
[Test]
|
||||
public void TestForwardExceptionFromExplicitThread() {
|
||||
FailingThreadOperation test = new FailingThreadOperation(false);
|
||||
|
||||
Assert.IsFalse(test.Ended);
|
||||
test.Start();
|
||||
test.Join();
|
||||
Assert.Throws<AbortedException>(
|
||||
delegate() { test.Join(); }
|
||||
);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -35,9 +35,11 @@ namespace Nuclex.Support {
|
|||
/// Tests whether the default constructor of the StringSegment class throws the
|
||||
/// right exception when being passed 'null' instead of a string
|
||||
/// </summary>
|
||||
[Test, ExpectedException(typeof(ArgumentNullException))]
|
||||
[Test]
|
||||
public void TestNullStringInSimpleConstructor() {
|
||||
new StringSegment(null);
|
||||
Assert.Throws<ArgumentNullException>(
|
||||
delegate() { new StringSegment(null); }
|
||||
);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
@ -53,9 +55,11 @@ namespace Nuclex.Support {
|
|||
/// Tests whether the full constructor of the StringSegment class throws the
|
||||
/// right exception when being passed 'null' instead of a string
|
||||
/// </summary>
|
||||
[Test, ExpectedException(typeof(ArgumentNullException))]
|
||||
[Test]
|
||||
public void TestNullStringInFullConstructor() {
|
||||
new StringSegment(null, 0, 0);
|
||||
Assert.Throws<ArgumentNullException>(
|
||||
delegate() { new StringSegment(null, 0, 0); }
|
||||
);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
@ -71,27 +75,33 @@ namespace Nuclex.Support {
|
|||
/// Tests whether the full constructor of the StringSegment class throws the
|
||||
/// right exception when being passed an invalid start offset
|
||||
/// </summary>
|
||||
[Test, ExpectedException(typeof(ArgumentOutOfRangeException))]
|
||||
[Test]
|
||||
public void TestInvalidOffsetInConstructor() {
|
||||
new StringSegment(string.Empty, -1, 0);
|
||||
Assert.Throws<ArgumentOutOfRangeException>(
|
||||
delegate() { new StringSegment(string.Empty, -1, 0); }
|
||||
);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Tests whether the full constructor of the StringSegment class throws the
|
||||
/// right exception when being passed an invalid string length
|
||||
/// </summary>
|
||||
[Test, ExpectedException(typeof(ArgumentOutOfRangeException))]
|
||||
[Test]
|
||||
public void TestInvalidLengthInConstructor() {
|
||||
new StringSegment(string.Empty, 0, -1);
|
||||
Assert.Throws<ArgumentOutOfRangeException>(
|
||||
delegate() { new StringSegment(string.Empty, 0, -1); }
|
||||
);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Tests whether the full constructor of the StringSegment class throws the
|
||||
/// right exception when being passed a string length that's too large
|
||||
/// </summary>
|
||||
[Test, ExpectedException(typeof(ArgumentException))]
|
||||
[Test]
|
||||
public void TestExcessiveLengthInConstructor() {
|
||||
new StringSegment("hello", 3, 3);
|
||||
Assert.Throws<ArgumentException>(
|
||||
delegate() { new StringSegment("hello", 3, 3); }
|
||||
);
|
||||
}
|
||||
|
||||
/// <summary>Tests whether the 'Text' property works as expected</summary>
|
||||
|
@ -198,28 +208,31 @@ namespace Nuclex.Support {
|
|||
/// <summary>
|
||||
/// Tests the ToString() method of the string segment with an invalid string
|
||||
/// </summary>
|
||||
[Test, ExpectedException(typeof(ArgumentNullException))]
|
||||
[Test]
|
||||
public void TestToStringWithInvalidString() {
|
||||
StringSegment helloWorldSegment = new StringSegment(null, 4, 3);
|
||||
Assert.IsNotNull(helloWorldSegment.ToString());
|
||||
Assert.Throws<ArgumentNullException>(
|
||||
delegate() { new StringSegment(null, 4, 3); }
|
||||
);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Tests the ToString() method of the string segment with an invalid offset
|
||||
/// </summary>
|
||||
[Test, ExpectedException(typeof(ArgumentOutOfRangeException))]
|
||||
[Test]
|
||||
public void TestToStringWithInvalidOffset() {
|
||||
StringSegment helloWorldSegment = new StringSegment("hello world", -4, 3);
|
||||
Assert.IsNotNull(helloWorldSegment.ToString());
|
||||
Assert.Throws<ArgumentOutOfRangeException>(
|
||||
delegate() { new StringSegment("hello world", -4, 3); }
|
||||
);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Tests the ToString() method of the string segment with an invalid count
|
||||
/// </summary>
|
||||
[Test, ExpectedException(typeof(ArgumentOutOfRangeException))]
|
||||
[Test]
|
||||
public void TestToStringWithInvalidCount() {
|
||||
StringSegment helloWorldSegment = new StringSegment("hello world", 4, -3);
|
||||
Assert.IsNotNull(helloWorldSegment.ToString());
|
||||
Assert.Throws<ArgumentOutOfRangeException>(
|
||||
delegate() { new StringSegment("hello world", 4, -3); }
|
||||
);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -468,12 +468,14 @@ namespace Nuclex.Support.Tracking {
|
|||
/// Verifies that the progress tracker throws an exception if it is instructed
|
||||
/// to untrack a transaction it doesn't know about
|
||||
/// </summary>
|
||||
[Test, ExpectedException(typeof(ArgumentException))]
|
||||
[Test]
|
||||
public void TestThrowOnUntrackNonTrackedTransaction() {
|
||||
using(ProgressTracker tracker = new ProgressTracker()) {
|
||||
TestTransaction test1 = new TestTransaction();
|
||||
|
||||
tracker.Untrack(test1);
|
||||
Assert.Throws<ArgumentException>(
|
||||
delegate() { tracker.Untrack(test1); }
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -71,14 +71,16 @@ namespace Nuclex.Support.Tracking {
|
|||
/// Verifies that the FailedDummy request is in the ended state and throws
|
||||
/// an exception when Join()ing
|
||||
/// </summary>
|
||||
[Test, ExpectedException(typeof(AbortedException))]
|
||||
[Test]
|
||||
public void TestFailedDummy() {
|
||||
Request failedDummy = Request.CreateFailedDummy(
|
||||
new AbortedException("Hello World")
|
||||
);
|
||||
|
||||
Assert.IsTrue(failedDummy.Ended);
|
||||
failedDummy.Join();
|
||||
Assert.Throws<AbortedException>(
|
||||
delegate() { failedDummy.Join(); }
|
||||
);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
@ -114,14 +116,16 @@ namespace Nuclex.Support.Tracking {
|
|||
/// Verifies that the FailedDummy request is in the ended state and throws
|
||||
/// an exception when Join()ing
|
||||
/// </summary>
|
||||
[Test, ExpectedException(typeof(AbortedException))]
|
||||
[Test]
|
||||
public void TestFailedDummy() {
|
||||
Request<int> failedDummy = Request<int>.CreateFailedDummy(
|
||||
new AbortedException("Hello World")
|
||||
);
|
||||
|
||||
Assert.IsTrue(failedDummy.Ended);
|
||||
failedDummy.Join();
|
||||
Assert.Throws<AbortedException>(
|
||||
delegate() { failedDummy.Join(); }
|
||||
);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -111,11 +111,13 @@ namespace Nuclex.Support.Tracking {
|
|||
/// <summary>
|
||||
/// Verifies that the transaction throws an exception when it is ended multiple times
|
||||
/// </summary>
|
||||
[Test, ExpectedException(typeof(InvalidOperationException))]
|
||||
[Test]
|
||||
public void TestThrowOnRepeatedlyEndedTransaction() {
|
||||
TestTransaction test = new TestTransaction();
|
||||
test.End();
|
||||
test.End();
|
||||
Assert.Throws<InvalidOperationException>(
|
||||
delegate() { test.End(); }
|
||||
);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
|
Loading…
Reference in New Issue
Block a user