public void BeginTransaction_ThrowsInvalidOperationException_WhenATransactionIsAlreadyOpened()
        {
            //Arrange
            var configuration = fixture.Create <PostgresConfiguration>();
            var unitOfWork    = new PostgresReadModelUnitOfWork(configuration, connectionFactory);

            //Act
            unitOfWork.BeginTransaction();
            Action action = (() => unitOfWork.BeginTransaction());

            //Assert
            Assert.Throws <InvalidOperationException>(action);
        }
        public void BeginTransaction_CreatesATransaction()
        {
            //Arrange
            var configuration = fixture.Create <PostgresConfiguration>();
            var unitOfWork    = new PostgresReadModelUnitOfWork(configuration, connectionFactory);

            //Act
            unitOfWork.BeginTransaction();

            //Assert
            connection.Received(1).BeginTransaction();
        }
        public void Commit_CommitsAndDisposes_Transaction()
        {
            //Arrange
            var configuration = fixture.Create <PostgresConfiguration>();
            var unitOfWork    = new PostgresReadModelUnitOfWork(configuration, connectionFactory);

            //Act
            unitOfWork.BeginTransaction();
            unitOfWork.Commit();

            //Assert
            transaction.Received(1).Commit();
            transaction.Received(1).Dispose();
        }