コード例 #1
0
        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();
            }
        }
コード例 #2
0
        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();
            }
        }