public void TestWeightStorage() {
      TestTransaction transaction = new TestTransaction();
      WeightedTransaction<Transaction> testWrapper = new WeightedTransaction<Transaction>(
        transaction, 12.0f
      );

      Assert.AreEqual(12.0f, testWrapper.Weight);
    }
    public void TestDefaultWeight() {
      TestTransaction transaction = new TestTransaction();
      WeightedTransaction<Transaction> testWrapper = new WeightedTransaction<Transaction>(
        transaction
      );

      Assert.AreEqual(1.0f, testWrapper.Weight);
    }
    public void TestTransactionStorage() {
      TestTransaction transaction = new TestTransaction();
      WeightedTransaction<Transaction> testWrapper = new WeightedTransaction<Transaction>(
        transaction
      );

      Assert.AreSame(transaction, testWrapper.Transaction);
    }
    public void TestWrapperCollection() {
      WeightedTransaction<Transaction> transaction = new WeightedTransaction<Transaction>(
        Transaction.EndedDummy
      );

      ObservedWeightedTransaction<Transaction> observed =
        new ObservedWeightedTransaction<Transaction>(
          transaction,
          endedCallback,
          progressUpdatedCallback
        );

      WeightedTransactionWrapperCollection<Transaction> wrapper =
        new WeightedTransactionWrapperCollection<Transaction>(
          new ObservedWeightedTransaction<Transaction>[] { observed }
        );

      Assert.AreSame(transaction, wrapper[0]);
    }
Ejemplo n.º 5
0
        public void TestTransparentWrapping()
        {
            WeightedTransaction <TestOperation> operation1 = new WeightedTransaction <TestOperation>(
                new TestOperation()
                );
            WeightedTransaction <TestOperation> operation2 = new WeightedTransaction <TestOperation>(
                new TestOperation()
                );

            OperationQueue <TestOperation> testQueueOperation =
                new OperationQueue <TestOperation>(
                    new WeightedTransaction <TestOperation>[] {
                operation1,
                operation2
            }
                    );

            // Order is important due to sequential execution!
            Assert.AreSame(operation1, testQueueOperation.Children[0]);
            Assert.AreSame(operation2, testQueueOperation.Children[1]);
        }
    public void TestConstructorWithAlreadyEndedTransaction() {
      WeightedTransaction<Transaction> testTransaction = new WeightedTransaction<Transaction>(
        Transaction.EndedDummy
      );

      IObservationSubscriber subscriber = this.mockery.NewMock<IObservationSubscriber>();

      Expect.AtLeast(0).On(subscriber).Method("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");

      using(
        ObservedWeightedTransaction<Transaction> test =
          new ObservedWeightedTransaction<Transaction>(
            testTransaction,
            new ObservedWeightedTransaction<Transaction>.ReportDelegate(
              subscriber.ProgressUpdated
            ),
            new ObservedWeightedTransaction<Transaction>.ReportDelegate(
              subscriber.Ended
            )
          )
      ) {
        this.mockery.VerifyAllExpectationsHaveBeenMet();
      }
    }
    public void TestConstructorWithEndingTransaction() {
      WeightedTransaction<Transaction> testTransaction = new WeightedTransaction<Transaction>(
        new FunkyTransaction()
      );

      IObservationSubscriber subscriber = this.mockery.NewMock<IObservationSubscriber>();

      Expect.AtLeast(0).On(subscriber).Method("ProgressUpdated");
      Expect.Once.On(subscriber).Method("Ended");

      using(
        ObservedWeightedTransaction<Transaction> test =
          new ObservedWeightedTransaction<Transaction>(
            testTransaction,
            new ObservedWeightedTransaction<Transaction>.ReportDelegate(
              subscriber.ProgressUpdated
            ),
            new ObservedWeightedTransaction<Transaction>.ReportDelegate(
              subscriber.Ended
            )
        )
      ) {
        this.mockery.VerifyAllExpectationsHaveBeenMet();
      }
    }
Ejemplo n.º 8
0
    public void TestTransparentWrapping() {
      WeightedTransaction<TestOperation> operation1 = new WeightedTransaction<TestOperation>(
        new TestOperation()
      );
      WeightedTransaction<TestOperation> operation2 = new WeightedTransaction<TestOperation>(
        new TestOperation()
      );

      OperationQueue<TestOperation> testQueueOperation =
        new OperationQueue<TestOperation>(
          new WeightedTransaction<TestOperation>[] {
            operation1,
            operation2
          }
        );

      // Order is important due to sequential execution!
      Assert.AreSame(operation1, testQueueOperation.Children[0]);
      Assert.AreSame(operation2, testQueueOperation.Children[1]);
    }