//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes: //ORIGINAL LINE: @Test public void shouldExtendArrayWhenIdsAreWrappingAround() public virtual void ShouldExtendArrayWhenIdsAreWrappingAround() { // GIVEN IdOrderingQueue queue = new SynchronizedArrayIdOrderingQueue(5); for (int i = 0; i < 3; i++) { queue.Offer(i); queue.RemoveChecked(i); } // Now we're at [0,1,2,0,0] // ^-- headIndex and offerIndex for (int i = 3; i < 8; i++) { queue.Offer(i); } // Now we're at [5,6,2,3,4] // ^-- headIndex and offerIndex%length // WHEN offering one more, so that the queue is forced to resize queue.Offer(8); // THEN it should have been offered as well as all the previous ids should be intact for (int i = 3; i <= 8; i++) { assertFalse(queue.Empty); queue.RemoveChecked(i); } assertTrue(queue.Empty); }
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes: //ORIGINAL LINE: @Test public void shouldOfferAwaitAndRemoveRoundAndRound() throws Exception //JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#: public virtual void ShouldOfferAwaitAndRemoveRoundAndRound() { // GIVEN IdOrderingQueue queue = new SynchronizedArrayIdOrderingQueue(5); long offeredId = 0; long awaitedId = 0; queue.Offer(offeredId++); queue.Offer(offeredId++); // WHEN for (int i = 0; i < 20; i++) { queue.WaitFor(awaitedId); queue.RemoveChecked(awaitedId++); queue.Offer(offeredId++); assertFalse(queue.Empty); } // THEN queue.RemoveChecked(awaitedId++); queue.RemoveChecked(awaitedId); assertTrue(queue.Empty); }
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes: //ORIGINAL LINE: @Test public void shouldHaveOneThreadWaitForARemoval() throws Exception //JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#: public virtual void ShouldHaveOneThreadWaitForARemoval() { // GIVEN IdOrderingQueue queue = new SynchronizedArrayIdOrderingQueue(5); queue.Offer(3); queue.Offer(5); // WHEN another thread comes in and awaits 5 OtherThreadExecutor <Void> t2 = Cleanup.add(new OtherThreadExecutor <Void>("T2", null)); Future <object> await5 = t2.ExecuteDontWait(AwaitHead(queue, 5)); t2.WaitUntilWaiting(); // ... and head (3) gets removed queue.RemoveChecked(3); // THEN the other thread should be OK to continue await5.get(); }
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes: //ORIGINAL LINE: @Test public void shouldOfferQueueABunchOfIds() throws Exception //JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#: public virtual void ShouldOfferQueueABunchOfIds() { // GIVEN IdOrderingQueue queue = new SynchronizedArrayIdOrderingQueue(5); // WHEN for (int i = 0; i < 7; i++) { queue.Offer(i); } // THEN for (int i = 0; i < 7; i++) { assertFalse(queue.Empty); queue.WaitFor(i); queue.RemoveChecked(i); } assertTrue(queue.Empty); }