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