Upgraded unit tests to NMock 3.0

git-svn-id: file:///srv/devel/repo-conversion/nusu@214 d2e56fa2-650e-0410-a79f-9358c0239efd
This commit is contained in:
Markus Ewald 2011-03-08 20:36:43 +00:00
parent da61476a80
commit aa5e4d12cc
24 changed files with 284 additions and 320 deletions

View File

@ -40,8 +40,8 @@
<AssemblyOriginatorKeyFile>..\Foundation.snk</AssemblyOriginatorKeyFile>
</PropertyGroup>
<ItemGroup>
<Reference Include="NMock2">
<HintPath>..\References\nmock\net-4.0\NMock2.dll</HintPath>
<Reference Include="NMock.StrongNamed">
<HintPath>..\References\nmock\net-4.0\NMock.StrongNamed.dll</HintPath>
</Reference>
<Reference Include="nunit.framework, Version=2.5.5.10112, Culture=neutral, PublicKeyToken=96d09a1eb7f44a77, processorArchitecture=MSIL">
<SpecificVersion>False</SpecificVersion>

View File

@ -25,7 +25,6 @@ using System.Collections;
using System.Collections.Generic;
using NUnit.Framework;
using NMock2;
namespace Nuclex.Support.Collections {

View File

@ -24,7 +24,6 @@ using System;
using System.Collections.Generic;
using NUnit.Framework;
using NMock2;
namespace Nuclex.Support.Collections {

View File

@ -24,7 +24,7 @@ using System.Collections.Generic;
#if UNITTEST
using NUnit.Framework;
using NMock2;
using NMock;
namespace Nuclex.Support.Collections {
@ -64,30 +64,30 @@ namespace Nuclex.Support.Collections {
/// <summary>Initialization routine executed before each test is run</summary>
[SetUp]
public void Setup() {
this.mockery = new Mockery();
this.mockery = new MockFactory();
this.mockedSubscriber = this.mockery.NewMock<IObservableCollectionSubscriber>();
this.mockedSubscriber = this.mockery.CreateMock<IObservableCollectionSubscriber>();
this.observedCollection = new ObservableCollection<int>();
this.observedCollection.Clearing +=
new EventHandler(this.mockedSubscriber.Clearing);
this.observedCollection.Cleared +=
new EventHandler(this.mockedSubscriber.Cleared);
this.observedCollection.ItemAdded +=
new EventHandler<ItemEventArgs<int>>(
this.mockedSubscriber.ItemAdded
);
this.observedCollection.ItemRemoved +=
new EventHandler<ItemEventArgs<int>>(
this.mockedSubscriber.ItemRemoved
);
this.observedCollection.Clearing += new EventHandler(
this.mockedSubscriber.MockObject.Clearing
);
this.observedCollection.Cleared += new EventHandler(
this.mockedSubscriber.MockObject.Cleared
);
this.observedCollection.ItemAdded += new EventHandler<ItemEventArgs<int>>(
this.mockedSubscriber.MockObject.ItemAdded
);
this.observedCollection.ItemRemoved += new EventHandler<ItemEventArgs<int>>(
this.mockedSubscriber.MockObject.ItemRemoved
);
}
/// <summary>Tests whether the Clearing event is fired</summary>
[Test]
public void TestClearingEvent() {
Expect.Once.On(this.mockedSubscriber).Method("Clearing").WithAnyArguments();
Expect.Once.On(this.mockedSubscriber).Method("Cleared").WithAnyArguments();
this.mockedSubscriber.Expects.One.Method(m => m.Clearing(null, null)).WithAnyArguments();
this.mockedSubscriber.Expects.One.Method(m => m.Cleared(null, null)).WithAnyArguments();
this.observedCollection.Clear();
this.mockery.VerifyAllExpectationsHaveBeenMet();
@ -96,7 +96,7 @@ namespace Nuclex.Support.Collections {
/// <summary>Tests whether the ItemAdded event is fired</summary>
[Test]
public void TestItemAddedEvent() {
Expect.Once.On(this.mockedSubscriber).Method("ItemAdded").WithAnyArguments();
this.mockedSubscriber.Expects.One.Method(m => m.ItemAdded(null, null)).WithAnyArguments();
this.observedCollection.Add(123);
@ -106,11 +106,11 @@ namespace Nuclex.Support.Collections {
/// <summary>Tests whether the ItemRemoved event is fired</summary>
[Test]
public void TestItemRemovedEvent() {
Expect.Once.On(this.mockedSubscriber).Method("ItemAdded").WithAnyArguments();
this.mockedSubscriber.Expects.One.Method(m => m.ItemAdded(null, null)).WithAnyArguments();
this.observedCollection.Add(123);
Expect.Once.On(this.mockedSubscriber).Method("ItemRemoved").WithAnyArguments();
this.mockedSubscriber.Expects.One.Method(m => m.ItemRemoved(null, null)).WithAnyArguments();
this.observedCollection.Remove(123);
@ -120,14 +120,16 @@ namespace Nuclex.Support.Collections {
/// <summary>Tests whether items in the collection can be replaced</summary>
[Test]
public void TestItemReplacement() {
Expect.Exactly(3).On(this.mockedSubscriber).Method("ItemAdded").WithAnyArguments();
this.mockedSubscriber.Expects.Exactly(3).Method(
m => m.ItemAdded(null, null)
).WithAnyArguments();
this.observedCollection.Add(1);
this.observedCollection.Add(2);
this.observedCollection.Add(3);
Expect.Once.On(this.mockedSubscriber).Method("ItemRemoved").WithAnyArguments();
Expect.Once.On(this.mockedSubscriber).Method("ItemAdded").WithAnyArguments();
this.mockedSubscriber.Expects.One.Method(m => m.ItemRemoved(null, null)).WithAnyArguments();
this.mockedSubscriber.Expects.One.Method(m => m.ItemAdded(null, null)).WithAnyArguments();
// Replace the middle item with something else
this.observedCollection[1] = 4;
@ -150,9 +152,9 @@ namespace Nuclex.Support.Collections {
}
/// <summary>Mock object factory</summary>
private Mockery mockery;
private MockFactory mockery;
/// <summary>The mocked observable collection subscriber</summary>
private IObservableCollectionSubscriber mockedSubscriber;
private Mock<IObservableCollectionSubscriber> mockedSubscriber;
/// <summary>An observable collection to which a mock will be subscribed</summary>
private ObservableCollection<int> observedCollection;

View File

@ -27,7 +27,7 @@ using System.IO;
using System.Runtime.Serialization.Formatters.Binary;
using NUnit.Framework;
using NMock2;
using NMock;
namespace Nuclex.Support.Collections {
@ -67,9 +67,9 @@ namespace Nuclex.Support.Collections {
/// <summary>Initialization routine executed before each test is run</summary>
[SetUp]
public void Setup() {
this.mockery = new Mockery();
this.mockery = new MockFactory();
this.mockedSubscriber = this.mockery.NewMock<IObservableDictionarySubscriber>();
this.mockedSubscriber = this.mockery.CreateMock<IObservableDictionarySubscriber>();
this.observedDictionary = new ObservableDictionary<int, string>();
this.observedDictionary.Add(1, "one");
@ -78,16 +78,16 @@ namespace Nuclex.Support.Collections {
this.observedDictionary.Add(42, "forty-two");
this.observedDictionary.Clearing +=
new EventHandler(this.mockedSubscriber.Clearing);
new EventHandler(this.mockedSubscriber.MockObject.Clearing);
this.observedDictionary.Cleared +=
new EventHandler(this.mockedSubscriber.Cleared);
new EventHandler(this.mockedSubscriber.MockObject.Cleared);
this.observedDictionary.ItemAdded +=
new EventHandler<ItemEventArgs<KeyValuePair<int, string>>>(
this.mockedSubscriber.ItemAdded
this.mockedSubscriber.MockObject.ItemAdded
);
this.observedDictionary.ItemRemoved +=
new EventHandler<ItemEventArgs<KeyValuePair<int, string>>>(
this.mockedSubscriber.ItemRemoved
this.mockedSubscriber.MockObject.ItemRemoved
);
}
@ -249,7 +249,7 @@ namespace Nuclex.Support.Collections {
/// </summary>
[Test]
public void TestAddViaGenericIDictionary() {
Expect.Once.On(this.mockedSubscriber).Method("ItemAdded").WithAnyArguments();
this.mockedSubscriber.Expects.One.Method(m => m.ItemAdded(null, null)).WithAnyArguments();
(this.observedDictionary as IDictionary<int, string>).Add(10, "ten");
this.mockery.VerifyAllExpectationsHaveBeenMet();
@ -264,7 +264,7 @@ namespace Nuclex.Support.Collections {
/// </summary>
[Test]
public void TestRemoveViaGenericIDictionary() {
Expect.Once.On(this.mockedSubscriber).Method("ItemRemoved").WithAnyArguments();
this.mockedSubscriber.Expects.One.Method(m => m.ItemRemoved(null, null)).WithAnyArguments();
(this.observedDictionary as IDictionary<int, string>).Remove(3);
this.mockery.VerifyAllExpectationsHaveBeenMet();
@ -287,8 +287,12 @@ namespace Nuclex.Support.Collections {
/// </summary>
[Test]
public void TestReplaceByIndexerViaGenericIDictionary() {
Expect.Once.On(this.mockedSubscriber).Method("ItemRemoved").WithAnyArguments();
Expect.Once.On(this.mockedSubscriber).Method("ItemAdded").WithAnyArguments();
this.mockedSubscriber.Expects.One.Method(
m => m.ItemRemoved(null, null)
).WithAnyArguments();
this.mockedSubscriber.Expects.One.Method(
m => m.ItemAdded(null, null)
).WithAnyArguments();
(this.observedDictionary as IDictionary<int, string>)[42] = "two and fourty";
this.mockery.VerifyAllExpectationsHaveBeenMet();
@ -300,8 +304,12 @@ namespace Nuclex.Support.Collections {
/// </summary>
[Test]
public void TestClearViaIDictionary() {
Expect.Once.On(this.mockedSubscriber).Method("Clearing").WithAnyArguments();
Expect.Once.On(this.mockedSubscriber).Method("Cleared").WithAnyArguments();
this.mockedSubscriber.Expects.One.Method(
m => m.Clearing(null, null)
).WithAnyArguments();
this.mockedSubscriber.Expects.One.Method(
m => m.Cleared(null, null)
).WithAnyArguments();
(this.observedDictionary as IDictionary).Clear();
this.mockery.VerifyAllExpectationsHaveBeenMet();
@ -313,7 +321,9 @@ namespace Nuclex.Support.Collections {
/// </summary>
[Test]
public void TestAddViaIDictionary() {
Expect.Once.On(this.mockedSubscriber).Method("ItemAdded").WithAnyArguments();
this.mockedSubscriber.Expects.One.Method(
m => m.ItemAdded(null, null)
).WithAnyArguments();
(this.observedDictionary as IDictionary).Add(24, "twenty-four");
this.mockery.VerifyAllExpectationsHaveBeenMet();
@ -380,7 +390,7 @@ namespace Nuclex.Support.Collections {
/// </summary>
[Test]
public void TestRemoveViaIDictionary() {
Expect.Once.On(this.mockedSubscriber).Method("ItemRemoved").WithAnyArguments();
this.mockedSubscriber.Expects.One.Method(m => m.ItemRemoved(null, null)).WithAnyArguments();
(this.observedDictionary as IDictionary).Remove(3);
this.mockery.VerifyAllExpectationsHaveBeenMet();
@ -401,8 +411,13 @@ namespace Nuclex.Support.Collections {
/// </summary>
[Test]
public void TestReplaceByIndexerViaIDictionary() {
Expect.Once.On(this.mockedSubscriber).Method("ItemRemoved").WithAnyArguments();
Expect.Once.On(this.mockedSubscriber).Method("ItemAdded").WithAnyArguments();
this.mockedSubscriber.Expects.One.Method(
m => m.ItemRemoved(null, null)
).WithAnyArguments();
this.mockedSubscriber.Expects.One.Method(
m => m.ItemAdded(null, null)
).WithAnyArguments();
(this.observedDictionary as IDictionary)[42] = "two and fourty";
this.mockery.VerifyAllExpectationsHaveBeenMet();
@ -415,7 +430,10 @@ namespace Nuclex.Support.Collections {
/// </summary>
[Test]
public void TestAddViaGenericICollection() {
Expect.Once.On(this.mockedSubscriber).Method("ItemAdded").WithAnyArguments();
this.mockedSubscriber.Expects.One.Method(
m => m.ItemAdded(null, null)
).WithAnyArguments();
(this.observedDictionary as ICollection<KeyValuePair<int, string>>).Add(
new KeyValuePair<int, string>(24, "twenty-four")
);
@ -432,8 +450,13 @@ namespace Nuclex.Support.Collections {
/// </summary>
[Test]
public void TestClearViaGenericICollection() {
Expect.Once.On(this.mockedSubscriber).Method("Clearing").WithAnyArguments();
Expect.Once.On(this.mockedSubscriber).Method("Cleared").WithAnyArguments();
this.mockedSubscriber.Expects.One.Method(
m => m.Clearing(null, null)
).WithAnyArguments();
this.mockedSubscriber.Expects.One.Method(
m => m.Cleared(null, null)
).WithAnyArguments();
(this.observedDictionary as ICollection<KeyValuePair<int, string>>).Clear();
this.mockery.VerifyAllExpectationsHaveBeenMet();
@ -449,7 +472,11 @@ namespace Nuclex.Support.Collections {
IEnumerator<KeyValuePair<int, string>> enumerator =
(this.observedDictionary as ICollection<KeyValuePair<int, string>>).GetEnumerator();
enumerator.MoveNext();
Expect.Once.On(this.mockedSubscriber).Method("ItemRemoved").WithAnyArguments();
this.mockedSubscriber.Expects.One.Method(
m => m.ItemRemoved(null, null)
).WithAnyArguments();
(this.observedDictionary as ICollection<KeyValuePair<int, string>>).Remove(
enumerator.Current
);
@ -537,9 +564,9 @@ namespace Nuclex.Support.Collections {
}
/// <summary>Mock object factory</summary>
private Mockery mockery;
private MockFactory mockery;
/// <summary>The mocked observable collection subscriber</summary>
private IObservableDictionarySubscriber mockedSubscriber;
private Mock<IObservableDictionarySubscriber> mockedSubscriber;
/// <summary>An observable dictionary to which a mock will be subscribed</summary>
private ObservableDictionary<int, string> observedDictionary;

View File

@ -24,7 +24,6 @@ using System.Collections.Generic;
#if UNITTEST
using NUnit.Framework;
using NMock2;
namespace Nuclex.Support.Collections {

View File

@ -24,7 +24,6 @@ using System.Collections.Generic;
#if UNITTEST
using NUnit.Framework;
using NMock2;
namespace Nuclex.Support.Collections {

View File

@ -24,7 +24,6 @@ using System;
using System.Collections.Generic;
using NUnit.Framework;
using NMock2;
namespace Nuclex.Support.Collections {

View File

@ -24,7 +24,6 @@ using System;
using System.Collections.Generic;
using NUnit.Framework;
using NMock2;
namespace Nuclex.Support.Collections {

View File

@ -24,7 +24,6 @@ using System.Collections.Generic;
#if UNITTEST
using NUnit.Framework;
using NMock2;
namespace Nuclex.Support.Collections {

View File

@ -25,7 +25,7 @@ using System.Collections.Generic;
#if UNITTEST
using NUnit.Framework;
using NMock2;
using NMock;
namespace Nuclex.Support.Collections {
@ -477,13 +477,13 @@ namespace Nuclex.Support.Collections {
/// </summary>
[Test]
public void TestSynchronizationOfIListWithoutICollection() {
Mockery mockery = new Mockery();
IList<int> mockedIList = mockery.NewMock<IList<int>>();
StringTransformer testCollection = new StringTransformer(mockedIList);
MockFactory mockery = new MockFactory();
Mock<IList<int>> mockedIList = mockery.CreateMock<IList<int>>();
StringTransformer testCollection = new StringTransformer(mockedIList.MockObject);
if(!(testCollection as ICollection).IsSynchronized) {
lock((testCollection as ICollection).SyncRoot) {
Expect.Once.On(mockedIList).GetProperty("Count").Will(Return.Value(12345));
mockedIList.Expects.One.GetProperty(p => p.Count).WillReturn(12345);
int count = testCollection.Count;
Assert.AreEqual(12345, count); // ;-)
}

View File

@ -25,7 +25,6 @@ using System.Collections.Generic;
#if UNITTEST
using NUnit.Framework;
using NMock2;
namespace Nuclex.Support.Collections {
@ -76,6 +75,35 @@ namespace Nuclex.Support.Collections {
#endregion // class Dummy
#region class ListWithoutICollection
private class ListWithoutICollection : IList<WeakReference<Dummy>> {
public int IndexOf(WeakReference<Dummy> item) { throw new NotImplementedException(); }
public void Insert(int index, WeakReference<Dummy> item) {
throw new NotImplementedException();
}
public void RemoveAt(int index) { throw new NotImplementedException(); }
public WeakReference<Dummy> this[int index] {
get { throw new NotImplementedException(); }
set { throw new NotImplementedException(); }
}
public void Add(WeakReference<Dummy> item) { throw new NotImplementedException(); }
public void Clear() { throw new NotImplementedException(); }
public bool Contains(WeakReference<Dummy> item) { throw new NotImplementedException(); }
public void CopyTo(WeakReference<Dummy>[] array, int arrayIndex) {
throw new NotImplementedException();
}
public int Count { get { return 12345; } }
public bool IsReadOnly { get { throw new NotImplementedException(); } }
public bool Remove(WeakReference<Dummy> item) { throw new NotImplementedException(); }
public IEnumerator<WeakReference<Dummy>> GetEnumerator() {
throw new NotImplementedException();
}
IEnumerator IEnumerable.GetEnumerator() { throw new NotImplementedException(); }
}
#endregion // class ListWithoutICollection
/// <summary>Verifies that the constructor of the weak collection is working</summary>
[Test]
public void TestConstructor() {
@ -592,31 +620,6 @@ namespace Nuclex.Support.Collections {
}
}
private class ListWithoutICollection : IList<WeakReference<Dummy>> {
public int IndexOf(WeakReference<Dummy> item) { throw new NotImplementedException(); }
public void Insert(int index, WeakReference<Dummy> item) {
throw new NotImplementedException();
}
public void RemoveAt(int index) { throw new NotImplementedException(); }
public WeakReference<Dummy> this[int index] {
get { throw new NotImplementedException(); }
set { throw new NotImplementedException(); }
}
public void Add(WeakReference<Dummy> item) { throw new NotImplementedException(); }
public void Clear() { throw new NotImplementedException(); }
public bool Contains(WeakReference<Dummy> item) { throw new NotImplementedException(); }
public void CopyTo(WeakReference<Dummy>[] array, int arrayIndex) {
throw new NotImplementedException();
}
public int Count { get { return 12345; } }
public bool IsReadOnly { get { throw new NotImplementedException(); } }
public bool Remove(WeakReference<Dummy> item) { throw new NotImplementedException(); }
public IEnumerator<WeakReference<Dummy>> GetEnumerator() {
throw new NotImplementedException();
}
IEnumerator IEnumerable.GetEnumerator() { throw new NotImplementedException(); }
}
/// <summary>
/// Verifies that the IsSynchronized property and the SyncRoot property are working
/// on transforming read only collections based on IList&lt;&gt;s that do not

View File

@ -26,7 +26,7 @@ using System.Reflection;
#if UNITTEST
using NUnit.Framework;
using NMock2;
using NMock;
namespace Nuclex.Support.Plugins {
@ -141,12 +141,12 @@ namespace Nuclex.Support.Plugins {
/// </summary>
[Test]
public void TestAssemblyLoadedEvent() {
Mockery mockery = new Mockery();
MockFactory mockery = new MockFactory();
PluginRepository testRepository = new PluginRepository();
IAssemblyLoadedSubscriber subscriber = mockSubscriber(mockery, testRepository);
Mock<IAssemblyLoadedSubscriber> subscriber = mockSubscriber(mockery, testRepository);
Expect.Once.On(subscriber).Method("AssemblyLoaded").WithAnyArguments();
subscriber.Expects.One.Method(m => m.AssemblyLoaded(null, null)).WithAnyArguments();
Assembly self = Assembly.GetAssembly(GetType());
testRepository.AddAssembly(self);
@ -202,14 +202,14 @@ namespace Nuclex.Support.Plugins {
/// <param name="mockery">Mockery to create an event subscriber in</param>
/// <param name="repository">Repository to subscribe the mocked subscriber to</param>
/// <returns>The mocked event subscriber</returns>
private static IAssemblyLoadedSubscriber mockSubscriber(
Mockery mockery, PluginRepository repository
private static Mock<IAssemblyLoadedSubscriber> mockSubscriber(
MockFactory mockery, PluginRepository repository
) {
IAssemblyLoadedSubscriber mockedSubscriber =
mockery.NewMock<IAssemblyLoadedSubscriber>();
Mock<IAssemblyLoadedSubscriber> mockedSubscriber =
mockery.CreateMock<IAssemblyLoadedSubscriber>();
repository.AssemblyLoaded += new AssemblyLoadEventHandler(
mockedSubscriber.AssemblyLoaded
mockedSubscriber.MockObject.AssemblyLoaded
);
return mockedSubscriber;

View File

@ -26,7 +26,6 @@ using System.IO;
using System.Runtime.Serialization.Formatters.Binary;
using NUnit.Framework;
using NMock2;
namespace Nuclex.Support.Scheduling {
@ -58,7 +57,6 @@ namespace Nuclex.Support.Scheduling {
Assert.AreSame(inner, testException.InnerException);
}
/// <summary>
/// Test whether the exception can be serialized
/// </summary>

View File

@ -25,9 +25,7 @@ using System.Collections.Generic;
using System.IO;
using System.Runtime.Serialization.Formatters.Binary;
using NUnit.Framework;
using NMock2;
namespace Nuclex.Support.Scheduling {

View File

@ -25,7 +25,7 @@ using System.Collections.Generic;
using System.IO;
using NUnit.Framework;
using NMock2;
using NMock;
using Nuclex.Support.Tracking;
@ -166,7 +166,7 @@ namespace Nuclex.Support.Scheduling {
/// <summary>Initialization routine executed before each test is run</summary>
[SetUp]
public void Setup() {
this.mockery = new Mockery();
this.mockery = new MockFactory();
}
/// <summary>Validates that the queue executes operations sequentially</summary>
@ -180,29 +180,25 @@ namespace Nuclex.Support.Scheduling {
new TestOperation[] { operation1, operation2 }
);
IOperationQueueSubscriber mockedSubscriber = mockSubscriber(testQueueOperation);
Mock<IOperationQueueSubscriber> mockedSubscriber = mockSubscriber(testQueueOperation);
testQueueOperation.Start();
Expect.Once.On(mockedSubscriber).
Method("ProgressChanged").
With(
new Matcher[] {
new NMock2.Matchers.TypeMatcher(typeof(OperationQueue<TestOperation>)),
new ProgressUpdateEventArgsMatcher(new ProgressReportEventArgs(0.25f))
}
);
mockedSubscriber.Expects.One.Method(m => m.ProgressChanged(null, null)).With(
new Matcher[] {
new NMock.Matchers.TypeMatcher(typeof(OperationQueue<TestOperation>)),
new ProgressUpdateEventArgsMatcher(new ProgressReportEventArgs(0.25f))
}
);
operation1.ChangeProgress(0.5f);
Expect.Once.On(mockedSubscriber).
Method("ProgressChanged").
With(
new Matcher[] {
new NMock2.Matchers.TypeMatcher(typeof(OperationQueue<TestOperation>)),
new ProgressUpdateEventArgsMatcher(new ProgressReportEventArgs(0.5f))
}
);
mockedSubscriber.Expects.One.Method(m => m.ProgressChanged(null, null)).With(
new Matcher[] {
new NMock.Matchers.TypeMatcher(typeof(OperationQueue<TestOperation>)),
new ProgressUpdateEventArgsMatcher(new ProgressReportEventArgs(0.5f))
}
);
operation1.SetEnded();
@ -226,29 +222,21 @@ namespace Nuclex.Support.Scheduling {
}
);
IOperationQueueSubscriber mockedSubscriber = mockSubscriber(testQueueOperation);
Mock<IOperationQueueSubscriber> mockedSubscriber = mockSubscriber(testQueueOperation);
testQueueOperation.Start();
Expect.Once.On(mockedSubscriber).
Method("ProgressChanged").
With(
new Matcher[] {
new NMock2.Matchers.TypeMatcher(typeof(OperationQueue<TestOperation>)),
new ProgressUpdateEventArgsMatcher(new ProgressReportEventArgs(0.1f))
}
);
mockedSubscriber.Expects.One.Method(m => m.ProgressChanged(null, null)).With(
new NMock.Matchers.TypeMatcher(typeof(OperationQueue<TestOperation>)),
new ProgressUpdateEventArgsMatcher(new ProgressReportEventArgs(0.1f))
);
operation1.ChangeProgress(0.5f);
Expect.Once.On(mockedSubscriber).
Method("ProgressChanged").
With(
new Matcher[] {
new NMock2.Matchers.TypeMatcher(typeof(OperationQueue<TestOperation>)),
new ProgressUpdateEventArgsMatcher(new ProgressReportEventArgs(0.2f))
}
);
mockedSubscriber.Expects.One.Method(m => m.ProgressChanged(null, null)).With(
new NMock.Matchers.TypeMatcher(typeof(OperationQueue<TestOperation>)),
new ProgressUpdateEventArgsMatcher(new ProgressReportEventArgs(0.2f))
);
operation1.SetEnded();
@ -341,19 +329,19 @@ namespace Nuclex.Support.Scheduling {
/// <summary>Mocks a subscriber for the events of an operation</summary>
/// <param name="operation">Operation to mock an event subscriber for</param>
/// <returns>The mocked event subscriber</returns>
private IOperationQueueSubscriber mockSubscriber(Operation operation) {
IOperationQueueSubscriber mockedSubscriber =
this.mockery.NewMock<IOperationQueueSubscriber>();
private Mock<IOperationQueueSubscriber> mockSubscriber(Operation operation) {
Mock<IOperationQueueSubscriber> mockedSubscriber =
this.mockery.CreateMock<IOperationQueueSubscriber>();
operation.AsyncEnded += new EventHandler(mockedSubscriber.Ended);
operation.AsyncEnded += new EventHandler(mockedSubscriber.MockObject.Ended);
(operation as IProgressReporter).AsyncProgressChanged +=
new EventHandler<ProgressReportEventArgs>(mockedSubscriber.ProgressChanged);
new EventHandler<ProgressReportEventArgs>(mockedSubscriber.MockObject.ProgressChanged);
return mockedSubscriber;
}
/// <summary>Mock object factory</summary>
private Mockery mockery;
private MockFactory mockery;
}

View File

@ -27,7 +27,6 @@ using System.Runtime.Serialization.Formatters.Binary;
using System.Threading;
using NUnit.Framework;
using NMock2;
namespace Nuclex.Support.Scheduling {

View File

@ -27,7 +27,6 @@ using System.Runtime.Serialization.Formatters.Binary;
using NUnit.Framework;
using NMock2;
namespace Nuclex.Support.Scheduling {

View File

@ -25,7 +25,7 @@ using System.Threading;
#if UNITTEST
using NUnit.Framework;
using NMock2;
using NMock;
namespace Nuclex.Support.Tracking {
@ -85,7 +85,7 @@ namespace Nuclex.Support.Tracking {
/// <summary>Initialization routine executed before each test is run</summary>
[SetUp]
public void Setup() {
this.mockery = new Mockery();
this.mockery = new MockFactory();
}
/// <summary>Verifies that the constructor of the observation wrapper works</summary>
@ -95,23 +95,23 @@ namespace Nuclex.Support.Tracking {
Transaction.EndedDummy
);
IObservationSubscriber subscriber = this.mockery.NewMock<IObservationSubscriber>();
Mock<IObservationSubscriber> subscriber = this.mockery.CreateMock<IObservationSubscriber>();
Expect.AtLeast(0).On(subscriber).Method("ProgressUpdated");
subscriber.Expects.AtLeast(0).Method(m => m.ProgressUpdated());
// This should no be called because otherwise, the 'Ended' event would be raised
// to the transaction group before all transactions have been added into
// the internal list, leading to an early ending or even multiple endings.
Expect.Never.On(subscriber).Method("Ended");
subscriber.Expects.No.Method(m => m.Ended());
using(
ObservedWeightedTransaction<Transaction> test =
new ObservedWeightedTransaction<Transaction>(
testTransaction,
new ObservedWeightedTransaction<Transaction>.ReportDelegate(
subscriber.ProgressUpdated
subscriber.MockObject.ProgressUpdated
),
new ObservedWeightedTransaction<Transaction>.ReportDelegate(
subscriber.Ended
subscriber.MockObject.Ended
)
)
) {
@ -129,20 +129,20 @@ namespace Nuclex.Support.Tracking {
new FunkyTransaction()
);
IObservationSubscriber subscriber = this.mockery.NewMock<IObservationSubscriber>();
Mock<IObservationSubscriber> subscriber = this.mockery.CreateMock<IObservationSubscriber>();
Expect.AtLeast(0).On(subscriber).Method("ProgressUpdated");
Expect.Once.On(subscriber).Method("Ended");
subscriber.Expects.AtLeast(0).Method(m => m.ProgressUpdated());
subscriber.Expects.One.Method(m => m.Ended());
using(
ObservedWeightedTransaction<Transaction> test =
new ObservedWeightedTransaction<Transaction>(
testTransaction,
new ObservedWeightedTransaction<Transaction>.ReportDelegate(
subscriber.ProgressUpdated
subscriber.MockObject.ProgressUpdated
),
new ObservedWeightedTransaction<Transaction>.ReportDelegate(
subscriber.Ended
subscriber.MockObject.Ended
)
)
) {
@ -151,7 +151,7 @@ namespace Nuclex.Support.Tracking {
}
/// <summary>Mock object factory</summary>
private Mockery mockery;
private MockFactory mockery;
}

View File

@ -25,7 +25,6 @@ using System.Threading;
#if UNITTEST
using NUnit.Framework;
using NMock2;
namespace Nuclex.Support.Tracking {

View File

@ -25,7 +25,7 @@ using System.Collections.Generic;
using System.IO;
using NUnit.Framework;
using NMock2;
using NMock;
namespace Nuclex.Support.Tracking {
@ -161,28 +161,28 @@ namespace Nuclex.Support.Tracking {
/// <summary>Initialization routine executed before each test is run</summary>
[SetUp]
public void Setup() {
this.mockery = new Mockery();
this.mockery = new MockFactory();
}
/// <summary>Validates that the tracker properly sums the progress</summary>
[Test]
public void TestSummedProgress() {
using(ProgressTracker tracker = new ProgressTracker()) {
IProgressTrackerSubscriber mockedSubscriber = mockSubscriber(tracker);
Mock<IProgressTrackerSubscriber> mockedSubscriber = mockSubscriber(tracker);
TestTransaction test1 = new TestTransaction();
TestTransaction test2 = new TestTransaction();
// Step 1
{
Expect.Once.On(mockedSubscriber).Method("IdleStateChanged").WithAnyArguments();
mockedSubscriber.Expects.One.Method(
m => m.IdleStateChanged(null, null)
).WithAnyArguments();
// Since the progress is already at 0, these redundant reports are optional
Expect.Between(0, 2).On(mockedSubscriber).Method("ProgressChanged").With(
new Matcher[] {
new NMock2.Matchers.TypeMatcher(typeof(ProgressTracker)),
new ProgressReportEventArgsMatcher(new ProgressReportEventArgs(0.0f))
}
mockedSubscriber.Expects.Between(0, 2).Method(m => m.ProgressChanged(null, null)).With(
new NMock.Matchers.TypeMatcher(typeof(ProgressTracker)),
new ProgressReportEventArgsMatcher(new ProgressReportEventArgs(0.0f))
);
tracker.Track(test1);
@ -191,11 +191,9 @@ namespace Nuclex.Support.Tracking {
// Step 2
{
Expect.Once.On(mockedSubscriber).Method("ProgressChanged").With(
new Matcher[] {
new NMock2.Matchers.TypeMatcher(typeof(ProgressTracker)),
new ProgressReportEventArgsMatcher(new ProgressReportEventArgs(0.25f))
}
mockedSubscriber.Expects.One.Method(m => m.ProgressChanged(null, null)).With(
new NMock.Matchers.TypeMatcher(typeof(ProgressTracker)),
new ProgressReportEventArgsMatcher(new ProgressReportEventArgs(0.25f))
);
test1.ChangeProgress(0.5f);
@ -216,27 +214,23 @@ namespace Nuclex.Support.Tracking {
[Test]
public void TestDelayedRemoval() {
using(ProgressTracker tracker = new ProgressTracker()) {
IProgressTrackerSubscriber mockedSubscriber = mockSubscriber(tracker);
Mock<IProgressTrackerSubscriber> mockedSubscriber = mockSubscriber(tracker);
TestTransaction test1 = new TestTransaction();
TestTransaction test2 = new TestTransaction();
// Step 1
{
Expect.Once.On(mockedSubscriber).
Method("IdleStateChanged").
WithAnyArguments();
mockedSubscriber.Expects.One.Method(
m => m.IdleStateChanged(null, null)
).WithAnyArguments();
// This is optional. The tracker's progress is currently 0, so there's no need
// to send out superfluous progress reports.
Expect.Between(0, 2).On(mockedSubscriber).
Method("ProgressChanged").
With(
new Matcher[] {
new NMock2.Matchers.TypeMatcher(typeof(ProgressTracker)),
new ProgressReportEventArgsMatcher(new ProgressReportEventArgs(0.0f))
}
);
mockedSubscriber.Expects.Between(0, 2).Method(m => m.ProgressChanged(null, null)).With(
new NMock.Matchers.TypeMatcher(typeof(ProgressTracker)),
new ProgressReportEventArgsMatcher(new ProgressReportEventArgs(0.0f))
);
tracker.Track(test1);
tracker.Track(test2);
@ -244,14 +238,10 @@ namespace Nuclex.Support.Tracking {
// Step 2
{
Expect.Once.On(mockedSubscriber).
Method("ProgressChanged").
With(
new Matcher[] {
new NMock2.Matchers.TypeMatcher(typeof(ProgressTracker)),
new ProgressReportEventArgsMatcher(new ProgressReportEventArgs(0.25f))
}
);
mockedSubscriber.Expects.One.Method(m => m.ProgressChanged(null, null)).With(
new NMock.Matchers.TypeMatcher(typeof(ProgressTracker)),
new ProgressReportEventArgsMatcher(new ProgressReportEventArgs(0.25f))
);
// Total progress should be 0.25 after this call (two transactions, one with
// 0% progress and one with 50% progress)
@ -260,14 +250,10 @@ namespace Nuclex.Support.Tracking {
// Step 3
{
Expect.Once.On(mockedSubscriber).
Method("ProgressChanged").
With(
new Matcher[] {
new NMock2.Matchers.TypeMatcher(typeof(ProgressTracker)),
new ProgressReportEventArgsMatcher(new ProgressReportEventArgs(0.75f))
}
);
mockedSubscriber.Expects.One.Method(m => m.ProgressChanged(null, null)).With(
new NMock.Matchers.TypeMatcher(typeof(ProgressTracker)),
new ProgressReportEventArgsMatcher(new ProgressReportEventArgs(0.75f))
);
// Total progress should be 0.75 after this call (one transaction at 100%,
// the other one at 50%). If the second transaction would be removed by the tracker,
@ -277,18 +263,14 @@ namespace Nuclex.Support.Tracking {
// Step 4
{
Expect.Once.On(mockedSubscriber).
Method("ProgressChanged").
With(
new Matcher[] {
new NMock2.Matchers.TypeMatcher(typeof(ProgressTracker)),
new ProgressReportEventArgsMatcher(new ProgressReportEventArgs(1.0f))
}
);
mockedSubscriber.Expects.One.Method(m => m.ProgressChanged(null, null)).With(
new NMock.Matchers.TypeMatcher(typeof(ProgressTracker)),
new ProgressReportEventArgsMatcher(new ProgressReportEventArgs(1.0f))
);
Expect.Once.On(mockedSubscriber).
Method("IdleStateChanged").
WithAnyArguments();
mockedSubscriber.Expects.One.Method(
m => m.IdleStateChanged(null, null)
).WithAnyArguments();
test1.End();
}
@ -304,10 +286,14 @@ namespace Nuclex.Support.Tracking {
[Test]
public void TestSoleEndedTransaction() {
using(ProgressTracker tracker = new ProgressTracker()) {
IProgressTrackerSubscriber mockedSubscriber = mockSubscriber(tracker);
Mock<IProgressTrackerSubscriber> mockedSubscriber = mockSubscriber(tracker);
Expect.Never.On(mockedSubscriber).Method("IdleStateChanged").WithAnyArguments();
Expect.Never.On(mockedSubscriber).Method("ProgressChanged").WithAnyArguments();
mockedSubscriber.Expects.No.Method(
m => m.IdleStateChanged(null, null)
).WithAnyArguments();
mockedSubscriber.Expects.No.Method(
m => m.ProgressChanged(null, null)
).WithAnyArguments();
tracker.Track(Transaction.EndedDummy);
}
@ -322,56 +308,44 @@ namespace Nuclex.Support.Tracking {
[Test]
public void TestEndedTransaction() {
using(ProgressTracker tracker = new ProgressTracker()) {
IProgressTrackerSubscriber mockedSubscriber = mockSubscriber(tracker);
Mock<IProgressTrackerSubscriber> mockedSubscriber = mockSubscriber(tracker);
TestTransaction test1 = new TestTransaction();
// Step 1
{
Expect.Once.On(mockedSubscriber).
Method("IdleStateChanged").
WithAnyArguments();
mockedSubscriber.Expects.One.Method(
m => m.IdleStateChanged(null, null)
).WithAnyArguments();
Expect.Between(0, 1).On(mockedSubscriber).
Method("ProgressChanged").
With(
new Matcher[] {
new NMock2.Matchers.TypeMatcher(typeof(ProgressTracker)),
new ProgressReportEventArgsMatcher(new ProgressReportEventArgs(0.0f))
}
);
mockedSubscriber.Expects.AtMost(1).Method(m => m.ProgressChanged(null, null)).With(
new NMock.Matchers.TypeMatcher(typeof(ProgressTracker)),
new ProgressReportEventArgsMatcher(new ProgressReportEventArgs(0.0f))
);
tracker.Track(test1);
}
// Step 2
{
Expect.Once.On(mockedSubscriber).
Method("ProgressChanged").
With(
new Matcher[] {
new NMock2.Matchers.TypeMatcher(typeof(ProgressTracker)),
new ProgressReportEventArgsMatcher(new ProgressReportEventArgs(0.5f))
}
);
mockedSubscriber.Expects.One.Method(m => m.ProgressChanged(null, null)).With(
new NMock.Matchers.TypeMatcher(typeof(ProgressTracker)),
new ProgressReportEventArgsMatcher(new ProgressReportEventArgs(0.5f))
);
tracker.Track(Transaction.EndedDummy);
}
// Step 3
{
Expect.Once.On(mockedSubscriber).
Method("ProgressChanged").
With(
new Matcher[] {
new NMock2.Matchers.TypeMatcher(typeof(ProgressTracker)),
new ProgressReportEventArgsMatcher(new ProgressReportEventArgs(1.0f))
}
);
mockedSubscriber.Expects.One.Method(m => m.ProgressChanged(null, null)).With(
new NMock.Matchers.TypeMatcher(typeof(ProgressTracker)),
new ProgressReportEventArgsMatcher(new ProgressReportEventArgs(1.0f))
);
Expect.Once.On(mockedSubscriber).
Method("IdleStateChanged").
WithAnyArguments();
mockedSubscriber.Expects.One.Method(
m => m.IdleStateChanged(null, null)
).WithAnyArguments();
test1.End();
}
@ -512,21 +486,21 @@ namespace Nuclex.Support.Tracking {
/// <summary>Mocks a subscriber for the events of a tracker</summary>
/// <param name="tracker">Tracker to mock an event subscriber for</param>
/// <returns>The mocked event subscriber</returns>
private IProgressTrackerSubscriber mockSubscriber(ProgressTracker tracker) {
IProgressTrackerSubscriber mockedSubscriber =
this.mockery.NewMock<IProgressTrackerSubscriber>();
private Mock<IProgressTrackerSubscriber> mockSubscriber(ProgressTracker tracker) {
Mock<IProgressTrackerSubscriber> mockedSubscriber =
this.mockery.CreateMock<IProgressTrackerSubscriber>();
tracker.AsyncIdleStateChanged +=
new EventHandler<IdleStateEventArgs>(mockedSubscriber.IdleStateChanged);
new EventHandler<IdleStateEventArgs>(mockedSubscriber.MockObject.IdleStateChanged);
tracker.AsyncProgressChanged +=
new EventHandler<ProgressReportEventArgs>(mockedSubscriber.ProgressChanged);
new EventHandler<ProgressReportEventArgs>(mockedSubscriber.MockObject.ProgressChanged);
return mockedSubscriber;
}
/// <summary>Mock object factory</summary>
private Mockery mockery;
private MockFactory mockery;
}

View File

@ -27,7 +27,6 @@ using System.IO;
using Nuclex.Support.Scheduling;
using NUnit.Framework;
using NMock2;
namespace Nuclex.Support.Tracking {

View File

@ -26,7 +26,7 @@ using System.IO;
using System.Threading;
using NUnit.Framework;
using NMock2;
using NMock;
namespace Nuclex.Support.Tracking {
@ -105,7 +105,7 @@ namespace Nuclex.Support.Tracking {
/// <summary>Initialization routine executed before each test is run</summary>
[SetUp]
public void Setup() {
this.mockery = new Mockery();
this.mockery = new MockFactory();
}
/// <summary>
@ -128,10 +128,8 @@ namespace Nuclex.Support.Tracking {
public void TestEndedEventAfterSubscription() {
TestTransaction test = new TestTransaction();
ITransactionSubscriber mockedSubscriber = mockSubscriber(test);
Expect.Once.On(mockedSubscriber).
Method("Ended").
WithAnyArguments();
Mock<ITransactionSubscriber> mockedSubscriber = mockSubscriber(test);
mockedSubscriber.Expects.One.Method(m => m.Ended(null, null)).WithAnyArguments();
test.End();
@ -147,14 +145,12 @@ namespace Nuclex.Support.Tracking {
TestTransaction test = new TestTransaction();
test.End();
ITransactionSubscriber mockedSubscriber =
this.mockery.NewMock<ITransactionSubscriber>();
Mock<ITransactionSubscriber> mockedSubscriber =
this.mockery.CreateMock<ITransactionSubscriber>();
Expect.Once.On(mockedSubscriber).
Method("Ended").
WithAnyArguments();
mockedSubscriber.Expects.One.Method(m => m.Ended(null, null)).WithAnyArguments();
test.AsyncEnded += new EventHandler(mockedSubscriber.Ended);
test.AsyncEnded += new EventHandler(mockedSubscriber.MockObject.Ended);
this.mockery.VerifyAllExpectationsHaveBeenMet();
}
@ -221,10 +217,10 @@ namespace Nuclex.Support.Tracking {
TestTransaction monitored = new TestTransaction();
UnsubscribingTransaction test = new UnsubscribingTransaction(monitored);
ITransactionSubscriber mockedSubscriber = mockSubscriber(monitored);
Mock<ITransactionSubscriber> mockedSubscriber = mockSubscriber(monitored);
try {
Expect.Once.On(mockedSubscriber).Method("Ended").WithAnyArguments();
mockedSubscriber.Expects.One.Method(m => m.Ended(null, null)).WithAnyArguments();
monitored.End();
this.mockery.VerifyAllExpectationsHaveBeenMet();
}
@ -236,17 +232,17 @@ namespace Nuclex.Support.Tracking {
/// <summary>Mocks a subscriber for the events of a transaction</summary>
/// <param name="transaction">Transaction to mock an event subscriber for</param>
/// <returns>The mocked event subscriber</returns>
private ITransactionSubscriber mockSubscriber(Transaction transaction) {
ITransactionSubscriber mockedSubscriber =
this.mockery.NewMock<ITransactionSubscriber>();
private Mock<ITransactionSubscriber> mockSubscriber(Transaction transaction) {
Mock<ITransactionSubscriber> mockedSubscriber =
this.mockery.CreateMock<ITransactionSubscriber>();
transaction.AsyncEnded += new EventHandler(mockedSubscriber.Ended);
transaction.AsyncEnded += new EventHandler(mockedSubscriber.MockObject.Ended);
return mockedSubscriber;
}
/// <summary>Mock object factory</summary>
private Mockery mockery;
private MockFactory mockery;
}

View File

@ -26,7 +26,7 @@ using System.Threading;
#if UNITTEST
using NUnit.Framework;
using NMock2;
using NMock;
namespace Nuclex.Support.Tracking {
@ -190,7 +190,7 @@ namespace Nuclex.Support.Tracking {
/// <summary>Initialization routine executed before each test is run</summary>
[SetUp]
public void Setup() {
this.mockery = new Mockery();
this.mockery = new MockFactory();
}
/// <summary>Validates that the transaction group correctly sums the progress</summary>
@ -202,16 +202,12 @@ namespace Nuclex.Support.Tracking {
new TestTransaction[] { new TestTransaction(), new TestTransaction() }
)
) {
ITransactionGroupSubscriber mockedSubscriber = mockSubscriber(testTransactionGroup);
Mock<ITransactionGroupSubscriber> mockedSubscriber = mockSubscriber(testTransactionGroup);
Expect.Once.On(mockedSubscriber).
Method("ProgressChanged").
With(
new Matcher[] {
new NMock2.Matchers.TypeMatcher(typeof(TransactionGroup<TestTransaction>)),
new ProgressUpdateEventArgsMatcher(new ProgressReportEventArgs(0.25f))
}
);
mockedSubscriber.Expects.One.Method(m => m.ProgressChanged(null, null)).With(
new NMock.Matchers.TypeMatcher(typeof(TransactionGroup<TestTransaction>)),
new ProgressUpdateEventArgsMatcher(new ProgressReportEventArgs(0.25f))
);
testTransactionGroup.Children[0].Transaction.ChangeProgress(0.5f);
@ -231,27 +227,19 @@ namespace Nuclex.Support.Tracking {
}
)
) {
ITransactionGroupSubscriber mockedSubscriber = mockSubscriber(testTransactionGroup);
Mock<ITransactionGroupSubscriber> mockedSubscriber = mockSubscriber(testTransactionGroup);
Expect.Once.On(mockedSubscriber).
Method("ProgressChanged").
With(
new Matcher[] {
new NMock2.Matchers.TypeMatcher(typeof(TransactionGroup<TestTransaction>)),
new ProgressUpdateEventArgsMatcher(new ProgressReportEventArgs(0.5f / 3.0f))
}
);
mockedSubscriber.Expects.One.Method(m => m.ProgressChanged(null, null)).With(
new NMock.Matchers.TypeMatcher(typeof(TransactionGroup<TestTransaction>)),
new ProgressUpdateEventArgsMatcher(new ProgressReportEventArgs(0.5f / 3.0f))
);
testTransactionGroup.Children[0].Transaction.ChangeProgress(0.5f);
Expect.Once.On(mockedSubscriber).
Method("ProgressChanged").
With(
new Matcher[] {
new NMock2.Matchers.TypeMatcher(typeof(TransactionGroup<TestTransaction>)),
new ProgressUpdateEventArgsMatcher(new ProgressReportEventArgs(0.5f))
}
);
mockedSubscriber.Expects.One.Method(m => m.ProgressChanged(null, null)).With(
new NMock.Matchers.TypeMatcher(typeof(TransactionGroup<TestTransaction>)),
new ProgressUpdateEventArgsMatcher(new ProgressReportEventArgs(0.5f))
);
testTransactionGroup.Children[1].Transaction.ChangeProgress(0.5f);
@ -271,15 +259,15 @@ namespace Nuclex.Support.Tracking {
new TestTransaction[] { new TestTransaction(), new TestTransaction() }
)
) {
ITransactionGroupSubscriber mockedSubscriber = mockSubscriber(testTransactionGroup);
Mock<ITransactionGroupSubscriber> mockedSubscriber = mockSubscriber(testTransactionGroup);
Expect.Exactly(2).On(mockedSubscriber).
Method("ProgressChanged").
WithAnyArguments();
mockedSubscriber.Expects.Exactly(2).Method(
m => m.ProgressChanged(null, null)
).WithAnyArguments();
Expect.Once.On(mockedSubscriber).
Method("Ended").
WithAnyArguments();
mockedSubscriber.Expects.One.Method(
m => m.Ended(null, null)
).WithAnyArguments();
testTransactionGroup.Children[0].Transaction.End();
testTransactionGroup.Children[1].Transaction.End();
@ -300,15 +288,16 @@ namespace Nuclex.Support.Tracking {
new TestTransaction[] { new TestTransaction() }
)
) {
ITransactionGroupSubscriber mockedSubscriber = mockSubscriber(testTransactionGroup);
Mock<ITransactionGroupSubscriber> mockedSubscriber = mockSubscriber(testTransactionGroup);
Expect.Once.On(mockedSubscriber).
Method("ProgressChanged").
WithAnyArguments();
mockedSubscriber.Expects.One.Method(
m => m.ProgressChanged(null, null)
).WithAnyArguments();
mockedSubscriber.Expects.One.Method(
m => m.Ended(null, null)
).WithAnyArguments();
Expect.Once.On(mockedSubscriber).
Method("Ended").
WithAnyArguments();
testTransactionGroup.Children[0].Transaction.End();
@ -376,19 +365,19 @@ namespace Nuclex.Support.Tracking {
/// <summary>Mocks a subscriber for the events of a transaction</summary>
/// <param name="transaction">Transaction to mock an event subscriber for</param>
/// <returns>The mocked event subscriber</returns>
private ITransactionGroupSubscriber mockSubscriber(Transaction transaction) {
ITransactionGroupSubscriber mockedSubscriber =
this.mockery.NewMock<ITransactionGroupSubscriber>();
private Mock<ITransactionGroupSubscriber> mockSubscriber(Transaction transaction) {
Mock<ITransactionGroupSubscriber> mockedSubscriber =
this.mockery.CreateMock<ITransactionGroupSubscriber>();
transaction.AsyncEnded += new EventHandler(mockedSubscriber.Ended);
transaction.AsyncEnded += new EventHandler(mockedSubscriber.MockObject.Ended);
(transaction as IProgressReporter).AsyncProgressChanged +=
new EventHandler<ProgressReportEventArgs>(mockedSubscriber.ProgressChanged);
new EventHandler<ProgressReportEventArgs>(mockedSubscriber.MockObject.ProgressChanged);
return mockedSubscriber;
}
/// <summary>Mock object factory</summary>
private Mockery mockery;
private MockFactory mockery;
}