//[Fact] public void SecondProcessToGainAccessShouldWaitForTheFirstProcess() { var connectionLock = new Mock <IConnectedBindingQueue>(); using (DatabaseLocksManager databaseLocksManager = CreateManager()) { databaseLocksManager.GainFullAccessToDatabase(server1, database1); bool secondTimeGettingAccessFails = false; try { databaseLocksManager.GainFullAccessToDatabase(server1, database1); } catch (DatabaseFullAccessException) { secondTimeGettingAccessFails = true; } Assert.Equal(secondTimeGettingAccessFails, true); databaseLocksManager.ReleaseAccess(server1, database1); Assert.Equal(databaseLocksManager.GainFullAccessToDatabase(server1, database1), true); databaseLocksManager.ReleaseAccess(server1, database1); } }
public void GainFullAccessShouldDisconnectTheConnections() { var connectionLock = new Mock <IConnectedBindingQueue>(); connectionLock.Setup(x => x.CloseConnections(server1, database1, DatabaseLocksManager.DefaultWaitToGetFullAccess)); using (DatabaseLocksManager databaseLocksManager = CreateManager()) { databaseLocksManager.ConnectionService.RegisterConnectedQueue("test", connectionLock.Object); databaseLocksManager.GainFullAccessToDatabase(server1, database1); connectionLock.Verify(x => x.CloseConnections(server1, database1, DatabaseLocksManager.DefaultWaitToGetFullAccess)); } }