Esempio n. 1
0
        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();
        }
Esempio n. 2
0
        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 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();
    }