Beispiel #1
0
        public void TestShutdown()
        {
            LocalTransactionId id = new LocalTransactionId();

            id.Value = 42;
            TransactionState state = new TransactionState(id);

            state.AddCommand(new Message());
            state.AddCommand(new Message());
            state.AddCommand(new Message());
            state.AddCommand(new Message());

            state.AddProducer(new ProducerState(CreateProducerInfo(1)));
            state.AddProducer(new ProducerState(CreateProducerInfo(2)));

            Assert.AreEqual(4, state.Commands.Count);
            Assert.AreEqual(2, state.ProducerStates.Count);

            state.Shutdown();

            Assert.AreEqual(0, state.Commands.Count);
            Assert.AreEqual(0, state.ProducerStates.Count);

            try
            {
                state.AddCommand(new Message());
                Assert.Fail("Should have thrown an exception");
            }
            catch
            {
            }

            try
            {
                state.AddProducer(new ProducerState(CreateProducerInfo(2)));
                Assert.Fail("Should have thrown an exception");
            }
            catch
            {
            }
        }