AddDataAccessorForThread() public method

Adds a data accessor to the collection of data accessors. This data accessor will be used for this thread.
public AddDataAccessorForThread ( IDataAccessor dataAccessor ) : void
dataAccessor IDataAccessor
return void
 public void Test_ClearDeadThreads()
 {
     //---------------Set up test pack-------------------
     const int BarrierTimeout = 10000;
     var dataAccessorMain = new DataAccessorInMemory();
     var dataAccessor = new DataAccessorThreadSplitter(dataAccessorMain);
     var expectedDataAccessorForThread = new DataAccessorInMemory();
     using (var entryBarrier = new Barrier(2))
     using (var exitBarrier = new Barrier(2))
     {
         var thread = new Thread(() =>
         {
             dataAccessor.AddDataAccessorForThread(expectedDataAccessorForThread);
             entryBarrier.SignalAndWait(BarrierTimeout);
             exitBarrier.SignalAndWait(BarrierTimeout);
         });
         thread.Start();
         entryBarrier.SignalAndWait(BarrierTimeout);
         //---------------Assert preconditions---------------
         Assert.AreSame(expectedDataAccessorForThread, dataAccessor.GetDataAccessorForThread(thread));
         //---------------Execute Test ----------------------
         exitBarrier.SignalAndWait(BarrierTimeout);
         thread.Join();
         dataAccessor.ClearDeadThreads();
         //---------------Test Result -----------------------
         var exception = Assert.Throws<HabaneroDeveloperException>(() => dataAccessor.GetDataAccessorForThread(thread));
         StringAssert.Contains("Data accessor for thread does not exist", exception.Message);
     }
 }
 public void Test_WithThread()
 {
     //---------------Set up test pack-------------------
     const int BarrierTimeout = 10000;
     var dataAccessorMain = new DataAccessorInMemory();
     var dataAccessor = new DataAccessorThreadSplitter(dataAccessorMain);
     var expectedDataAccessorForThread = new DataAccessorInMemory();
     using (var entryBarrier = new Barrier(2))
     using (var exitBarrier = new Barrier(2))
     {
         var thread = new Thread(() =>
         {
             dataAccessor.AddDataAccessorForThread(expectedDataAccessorForThread);
             entryBarrier.SignalAndWait(BarrierTimeout);
             exitBarrier.SignalAndWait(BarrierTimeout);
         });
         thread.Start();
         entryBarrier.SignalAndWait(BarrierTimeout);
         //---------------Execute Test ----------------------
         var dataAccessorForThread = dataAccessor.GetDataAccessorForThread(thread);
         exitBarrier.SignalAndWait(BarrierTimeout);
         //---------------Test Result -----------------------
         Assert.AreSame(expectedDataAccessorForThread, dataAccessorForThread);
     }
 }
 public void Test_WithThread()
 {
     //---------------Set up test pack-------------------
     var dataAccessorMain = new DataAccessorInMemory();
     var dataAccessor = new DataAccessorThreadSplitter(dataAccessorMain);
     var expectedDataAccessorForThread = new DataAccessorInMemory();
     var thread = new Thread(() =>
                                 {
                                     dataAccessor.AddDataAccessorForThread(expectedDataAccessorForThread);
                                     Thread.Sleep(1000);
                                 });
     thread.Start();
     Thread.Sleep(500);
     //---------------Execute Test ----------------------
     var dataAccessorForThread = dataAccessor.GetDataAccessorForThread(thread);
     //---------------Test Result -----------------------
     Assert.AreSame(expectedDataAccessorForThread, dataAccessorForThread);
 }
 public void Test_ClearDeadThreads()
 {
     //---------------Set up test pack-------------------
     var dataAccessorMain = new DataAccessorInMemory();
     var dataAccessor = new DataAccessorThreadSplitter(dataAccessorMain);
     var expectedDataAccessorForThread = new DataAccessorInMemory();
     var thread = new Thread(() => dataAccessor.AddDataAccessorForThread(expectedDataAccessorForThread));
     thread.Start();
     thread.Join();
     //---------------Assert preconditions---------------
     Assert.AreSame(expectedDataAccessorForThread, dataAccessor.GetDataAccessorForThread(thread));
     //---------------Execute Test ----------------------
     dataAccessor.ClearDeadThreads();
     //---------------Test Result -----------------------
     try
     {
         Assert.IsNull(dataAccessor.GetDataAccessorForThread(thread));
         Assert.Fail("An exception should be thrown");
     } catch (HabaneroDeveloperException ex)
     {
         StringAssert.Contains("Data accessor for thread does not exist", ex.Message);
     }
 }