public void TestWeightedSequentialExecution() { TestOperation operation1 = new TestOperation(); TestOperation operation2 = new TestOperation(); OperationQueue <TestOperation> testQueueOperation = new OperationQueue <TestOperation>( new WeightedTransaction <TestOperation>[] { new WeightedTransaction <TestOperation>(operation1, 0.5f), new WeightedTransaction <TestOperation>(operation2, 2.0f) } ); Mock <IOperationQueueSubscriber> mockedSubscriber = mockSubscriber(testQueueOperation); testQueueOperation.Start(); 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); 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(); this.mockery.VerifyAllExpectationsHaveBeenMet(); }
public void TestSequentialExecution() { TestOperation operation1 = new TestOperation(); TestOperation operation2 = new TestOperation(); OperationQueue <TestOperation> testQueueOperation = new OperationQueue <TestOperation>( new TestOperation[] { operation1, operation2 } ); 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)) } ); 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)) } ); operation1.SetEnded(); this.mockery.VerifyAllExpectationsHaveBeenMet(); }
public void TestEndPropagation() { TestOperation operation1 = new TestOperation(); TestOperation operation2 = new TestOperation(); OperationQueue <TestOperation> testQueueOperation = new OperationQueue <TestOperation>( new TestOperation[] { operation1, operation2 } ); testQueueOperation.Start(); Assert.IsFalse(testQueueOperation.Ended); operation1.SetEnded(); Assert.IsFalse(testQueueOperation.Ended); operation2.SetEnded(); Assert.IsTrue(testQueueOperation.Ended); testQueueOperation.Join(); }
public void TestExceptionPropagation() { TestOperation operation1 = new TestOperation(); TestOperation operation2 = new TestOperation(); OperationQueue <TestOperation> testQueueOperation = new OperationQueue <TestOperation>( new TestOperation[] { operation1, operation2 } ); testQueueOperation.Start(); Assert.IsFalse(testQueueOperation.Ended); operation1.SetEnded(); Assert.IsFalse(testQueueOperation.Ended); operation2.SetEnded(new AbortedException("Hello World")); Assert.Throws <AbortedException>( delegate() { testQueueOperation.Join(); } ); }
public void TestExceptionPropagation() { TestOperation operation1 = new TestOperation(); TestOperation operation2 = new TestOperation(); OperationQueue<TestOperation> testQueueOperation = new OperationQueue<TestOperation>( new TestOperation[] { operation1, operation2 } ); testQueueOperation.Start(); Assert.IsFalse(testQueueOperation.Ended); operation1.SetEnded(); Assert.IsFalse(testQueueOperation.Ended); operation2.SetEnded(new AbortedException("Hello World")); Assert.Throws<AbortedException>( delegate() { testQueueOperation.Join(); } ); }
public void TestEndPropagation() { TestOperation operation1 = new TestOperation(); TestOperation operation2 = new TestOperation(); OperationQueue<TestOperation> testQueueOperation = new OperationQueue<TestOperation>( new TestOperation[] { operation1, operation2 } ); testQueueOperation.Start(); Assert.IsFalse(testQueueOperation.Ended); operation1.SetEnded(); Assert.IsFalse(testQueueOperation.Ended); operation2.SetEnded(); Assert.IsTrue(testQueueOperation.Ended); testQueueOperation.Join(); }
public void TestWeightedSequentialExecution() { TestOperation operation1 = new TestOperation(); TestOperation operation2 = new TestOperation(); OperationQueue<TestOperation> testQueueOperation = new OperationQueue<TestOperation>( new WeightedTransaction<TestOperation>[] { new WeightedTransaction<TestOperation>(operation1, 0.5f), new WeightedTransaction<TestOperation>(operation2, 2.0f) } ); 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)) } ); 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)) } ); operation1.SetEnded(); this.mockery.VerifyAllExpectationsHaveBeenMet(); }