public void CheckSearcherWasDetached() { //arrange string[] searchWords = new string[] { "abc", "def" }; var chunk = new Chunk() { StartIndex = 0, Content = "abc ref" }; Searcher searcher = new Searcher(searchWords, chunk, _intermediateQueue); int expected = 1; //act searcher.FindWordsAndPositions(); //assert Assert.AreEqual(expected, _intermediateQueue.CountDetachedTasks()); }
public void TaskIsDetachedShouldBeCorrectCounter() { //arrange int expected = 2; //act Thread th1 = new Thread(() => intermediateQueue.DetachTask()); Thread th2 = new Thread(() => intermediateQueue.DetachTask()); th1.Start(); th2.Start(); th1.Join(); th2.Join(); int actual = intermediateQueue.CountDetachedTasks(); //assert Assert.AreEqual(expected, actual); }