Added another unit test for the transaction group

git-svn-id: file:///srv/devel/repo-conversion/nusu@124 d2e56fa2-650e-0410-a79f-9358c0239efd
This commit is contained in:
Markus Ewald 2009-03-30 20:08:12 +00:00
parent 889a47db6d
commit 96061c688c

View File

@ -260,10 +260,11 @@ namespace Nuclex.Support.Tracking {
}
/// <summary>
/// Validates that the ended event is triggered when the last transaction ends
/// Validates that the ended event is triggered when the last transaction out of
/// multiple transactions in the group ends.
/// </summary>
[Test]
public void TestEndedEvent() {
public void TestEndedEventWithTwoTransactions() {
using(
TransactionGroup<TestTransaction> testTransactionGroup =
new TransactionGroup<TestTransaction>(
@ -287,6 +288,34 @@ namespace Nuclex.Support.Tracking {
}
}
/// <summary>
/// Validates that the ended event is triggered when a single transaction contained
/// in the group ends.
/// </summary>
[Test]
public void TestEndedEventWithSingleTransaction() {
using(
TransactionGroup<TestTransaction> testTransactionGroup =
new TransactionGroup<TestTransaction>(
new TestTransaction[] { new TestTransaction() }
)
) {
ITransactionGroupSubscriber mockedSubscriber = mockSubscriber(testTransactionGroup);
Expect.Once.On(mockedSubscriber).
Method("ProgressChanged").
WithAnyArguments();
Expect.Once.On(mockedSubscriber).
Method("Ended").
WithAnyArguments();
testTransactionGroup.Children[0].Transaction.End();
this.mockery.VerifyAllExpectationsHaveBeenMet();
}
}
/// <summary>
/// Verifies that the transaction group immediately enters the ended state when
/// the contained transactions have already ended before the constructor