예제 #1
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test public void acquireBothSharedAndExclusiveLockThenReleaseExclusive()
        public virtual void AcquireBothSharedAndExclusiveLockThenReleaseExclusive()
        {
            // GIVEN
            TestLocks           actualLocks  = new TestLocks();
            TestLocksClient     actualClient = actualLocks.NewClient();
            DeferringLockClient client       = new DeferringLockClient(actualClient);

            client.AcquireShared(LockTracer.NONE, ResourceTypes.Node, 1);
            client.AcquireExclusive(LockTracer.NONE, ResourceTypes.Node, 1);
            client.ReleaseExclusive(ResourceTypes.Node, 1);

            // WHEN
            client.AcquireDeferredLocks(LockTracer.NONE);

            // THEN
            actualClient.AssertRegisteredLocks(Collections.singleton(new LockUnit(ResourceTypes.Node, 1, false)));
        }
예제 #2
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test public void exclusiveLockAcquiredMultipleTimesCanNotBeReleasedAtOnce()
        public virtual void ExclusiveLockAcquiredMultipleTimesCanNotBeReleasedAtOnce()
        {
            // GIVEN
            TestLocks           actualLocks  = new TestLocks();
            TestLocksClient     actualClient = actualLocks.NewClient();
            DeferringLockClient client       = new DeferringLockClient(actualClient);

            client.AcquireExclusive(LockTracer.NONE, ResourceTypes.Node, 1);
            client.AcquireExclusive(LockTracer.NONE, ResourceTypes.Node, 1);
            client.ReleaseExclusive(ResourceTypes.Node, 1);

            // WHEN
            client.AcquireDeferredLocks(LockTracer.NONE);

            // THEN
            actualClient.AssertRegisteredLocks(Collections.singleton(new LockUnit(ResourceTypes.Node, 1, true)));
        }
예제 #3
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test public void shouldThrowWhenReleaseNotYetAcquiredExclusive()
        public virtual void ShouldThrowWhenReleaseNotYetAcquiredExclusive()
        {
            // GIVEN
            Locks_Client        actualClient = mock(typeof(Locks_Client));
            DeferringLockClient client       = new DeferringLockClient(actualClient);

            try
            {
                // WHEN
                client.ReleaseExclusive(ResourceTypes.Node, 1);
                fail("Expected exception");
            }
            catch (System.InvalidOperationException)
            {
                // THEN
            }
        }
예제 #4
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test public void releaseOfNotHeldExclusiveLockThrows()
        public virtual void ReleaseOfNotHeldExclusiveLockThrows()
        {
            // GIVEN
            TestLocks           actualLocks  = new TestLocks();
            TestLocksClient     actualClient = actualLocks.NewClient();
            DeferringLockClient client       = new DeferringLockClient(actualClient);

            try
            {
                // WHEN
                client.ReleaseExclusive(ResourceTypes.Node, 42);
                fail("Exception expected");
            }
            catch (Exception e)
            {
                // THEN
                assertThat(e, instanceOf(typeof(System.InvalidOperationException)));
            }
        }
예제 #5
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test public void shouldThrowWhenReleasingLockMultipleTimes()
        public virtual void ShouldThrowWhenReleasingLockMultipleTimes()
        {
            // GIVEN
            Locks_Client        actualClient = mock(typeof(Locks_Client));
            DeferringLockClient client       = new DeferringLockClient(actualClient);

            client.AcquireExclusive(LockTracer.NONE, ResourceTypes.Node, 1);
            client.ReleaseExclusive(ResourceTypes.Node, 1);

            try
            {
                // WHEN
                client.ReleaseShared(ResourceTypes.Node, 1);
                fail("Expected exception");
            }
            catch (System.InvalidOperationException)
            {
                // THEN
            }
        }