/// <summary>
        /// <see cref="ITransaction.Begin"/>.
        /// </summary>
        public virtual void Begin()
        {
            _Sem.AtomWrite(() =>
            {
                AssertState(TransactionStatus.NoTransaction);
                Status = TransactionStatus.Active;
            });

            _Logger.TryLogFail(InnerBegin)
            .Exception(e => { _CanCommit = false; throw new TransactionException("Could not begin transaction.", e); })
            .Success(() =>
                     _CanCommit = true);

            _Sem.AtomRead(() =>
            {
                foreach (var r in _Resources)
                {
                    try { r.Start(); }
                    catch (Exception e)
                    {
                        SetRollbackOnly();
                        throw new CommitResourceException("Transaction could not commit because of a failed resource.",
                                                          e, r);
                    }
                }
            });
        }
        public void AtomRead_Test()
        {
            ReaderWriterLockSlim readerWriterLockSlim = null;

            Assert.Throws <ArgumentNullException>(() =>
            {
                readerWriterLockSlim.AtomRead(() => { });
            });

            Assert.Throws <ArgumentNullException>(() =>
            {
                readerWriterLockSlim.AtomRead <int>(() => 1);
            });


            readerWriterLockSlim = new ReaderWriterLockSlim();
            Assert.Throws <ArgumentNullException>(() =>
            {
                readerWriterLockSlim.AtomRead(null);
            });

            Func <int> func1 = null;

            Assert.Throws <ArgumentNullException>(() =>
            {
                readerWriterLockSlim.AtomRead(func1);
            });

            readerWriterLockSlim.AtomRead(_mockAction.Object);
            _mockAction.Verify(x => x.Invoke(), Times.Once);

            readerWriterLockSlim.AtomRead(_mockFunc.Object);
            _mockFunc.Verify(x => x.Invoke(), Times.Once);
        }