コード例 #1
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test public void shouldBeAbleToResetAndReuseClientState()
        public virtual void ShouldBeAbleToResetAndReuseClientState()
        {
            // given
            LockClientStateHolder lockClientStateHolder = new LockClientStateHolder();

            // when
            lockClientStateHolder.incrementActiveClients(new NoOpClient());
            lockClientStateHolder.incrementActiveClients(new NoOpClient());
            lockClientStateHolder.DecrementActiveClients();

            // expect
            assertTrue(lockClientStateHolder.HasActiveClients());

            // and when
            lockClientStateHolder.StopClient();

            // expect
            assertTrue(lockClientStateHolder.HasActiveClients());
            assertTrue(lockClientStateHolder.Stopped);

            // and when
            lockClientStateHolder.Reset();

            // expect
            assertFalse(lockClientStateHolder.HasActiveClients());
            assertFalse(lockClientStateHolder.Stopped);

            // when
            lockClientStateHolder.incrementActiveClients(new NoOpClient());
            assertTrue(lockClientStateHolder.HasActiveClients());
            assertFalse(lockClientStateHolder.Stopped);
        }
コード例 #2
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test public void shouldAllowIncrementDecrementClientsWhileNotClosed()
        public virtual void ShouldAllowIncrementDecrementClientsWhileNotClosed()
        {
            // given
            LockClientStateHolder lockClientStateHolder = new LockClientStateHolder();

            // expect
            assertFalse(lockClientStateHolder.HasActiveClients());
            lockClientStateHolder.incrementActiveClients(new NoOpClient());
            assertTrue(lockClientStateHolder.HasActiveClients());
            lockClientStateHolder.incrementActiveClients(new NoOpClient());
            lockClientStateHolder.incrementActiveClients(new NoOpClient());
            lockClientStateHolder.DecrementActiveClients();
            lockClientStateHolder.DecrementActiveClients();
            lockClientStateHolder.DecrementActiveClients();
            assertFalse(lockClientStateHolder.HasActiveClients());
        }
コード例 #3
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test public void shouldBeAbleToDecrementActiveItemAndDetectWhenFree()
        public virtual void ShouldBeAbleToDecrementActiveItemAndDetectWhenFree()
        {
            // given
            LockClientStateHolder lockClientStateHolder = new LockClientStateHolder();

            // when
            lockClientStateHolder.incrementActiveClients(new NoOpClient());
            lockClientStateHolder.incrementActiveClients(new NoOpClient());
            lockClientStateHolder.DecrementActiveClients();
            lockClientStateHolder.incrementActiveClients(new NoOpClient());

            // expect
            assertTrue(lockClientStateHolder.HasActiveClients());

            // and when
            lockClientStateHolder.StopClient();

            // expect
            assertTrue(lockClientStateHolder.HasActiveClients());
            lockClientStateHolder.DecrementActiveClients();
            assertTrue(lockClientStateHolder.HasActiveClients());
            lockClientStateHolder.DecrementActiveClients();
            assertFalse(lockClientStateHolder.HasActiveClients());
        }
コード例 #4
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test public void shouldNotAllowNewClientsWhenClosed()
        public virtual void ShouldNotAllowNewClientsWhenClosed()
        {
            // given
            LockClientStateHolder lockClientStateHolder = new LockClientStateHolder();

            // when
            lockClientStateHolder.StopClient();

            // then
            assertFalse(lockClientStateHolder.HasActiveClients());
            try
            {
                lockClientStateHolder.incrementActiveClients(new NoOpClient());
                fail("Exception expected");
            }
            catch (Exception e)
            {
                assertThat(e, instanceOf(typeof(LockClientStoppedException)));
            }
        }