public void Do_Generic_WhenBlockThrowsException_ShouldNotUnlockAndShouldRollback( ALock lck, DbTransaction transaction) { dbManager.GetThreadTransaction(Arg.Any <bool>()).Returns(transaction); Action act = () => { locker.Lock(new[] { lck }).Do <string>(() => { throw new Exception("Test"); }); }; act.ShouldThrow <Exception>().WithMessage("Test"); transaction.Received(1).Rollback(); transaction.Received(1).Dispose(); exitObjects.Should().BeEmpty(); }
public void Do_Generic_CommitsTransactionAndUnlocksAll( ALock lck, DbTransaction transaction) { dbManager.GetThreadTransaction(Arg.Any <bool>()).Returns(transaction); locker.Lock(new[] { lck }).Do(() => "Hello"); transaction.Received(1).Dispose(); exitObjects.Should().Equal(lck.Lock); }