Beispiel #1
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test public void acquireBothSharedAndExclusiveLockThenReleaseShared()
        public virtual void AcquireBothSharedAndExclusiveLockThenReleaseShared()
        {
            // 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.ReleaseShared(ResourceTypes.Node, 1);

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

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

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

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

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

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

            try
            {
                // WHEN
                client.ReleaseShared(ResourceTypes.Node, 42);
                fail("Exception expected");
            }
            catch (Exception e)
            {
                // THEN
                assertThat(e, instanceOf(typeof(System.InvalidOperationException)));
            }
        }
Beispiel #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
            }
        }