//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes: //ORIGINAL LINE: @Test public void shouldStopLockSessionOnFailureWhereThereIsAnActiveLockAcquisition() throws Throwable //JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#: public virtual void ShouldStopLockSessionOnFailureWhereThereIsAnActiveLockAcquisition() { // GIVEN System.Threading.CountdownEvent latch = new System.Threading.CountdownEvent(1); try { Locks_Client client = NewWaitingLocksClient(latch); MasterImpl master = NewMasterWithLocksClient(client); HandshakeResult handshake = master.Handshake(1, newStoreIdForCurrentVersion()).response(); // WHEN RequestContext context = new RequestContext(handshake.Epoch(), 1, 2, 0, 0); master.NewLockSession(context); Future <Void> acquireFuture = OtherThread.execute(state => { master.AcquireExclusiveLock(context, ResourceTypes.NODE, 1L); return(null); }); OtherThread.get().waitUntilWaiting(); master.EndLockSession(context, false); verify(client).stop(); verify(client, never()).close(); latch.Signal(); acquireFuture.get(); // THEN verify(client).close(); } finally { latch.Signal(); } }
public void MultiTread_Test() { SuperLogSingleton sl1 = SuperLogSingleton.Instance; sl1.AddLine("I'm the first line"); var output1 = sl1.Output; var process = new OtherThread(); Thread thread1 = new Thread(new ThreadStart(process.SimpleMethod)); thread1.Start(); //Waits until the thread ends thread1.Join(); Assert.Equal(output1 + "I'm the second line\n", sl1.Output); }