Progress Telerik JustMock

Mock Threadpool

  • With JustMock, you could mock every required member with ease and test your code in isolation from its dependencies.
  • This feature is a part of the fastest, most flexible and complete mocking tool for crafting unit tests.
  • Our award-winning support team is dedicated to assisting you with any questions and issues you may have during your application development.
Mock everything
Nasa, Visa, Microsoft Fox, Samsung, IBM World Bank Group, Volvo
  • Mocking Threadpool Overview

    Threadpool is a class that provides a pool of threads that can be used to execute tasks, post work items, process asynchronous I/O, wait on behalf of other threads and process timers.

    With JustMock, you could mock every required member with ease and test your code in isolation from its dependencies.

    [TestMethod]
    public void ShouldInvokeMockInsideAChildThreadFromThreadPool()
    {
        var mockable = Mock.Create<Mockable>();
        Mock.Arrange(() => mockable.IsMocked).Returns(true);
      
        bool mocked = false;
      
        var latch = new WaitLatch();
      
        ThreadPool.QueueUserWorkItem((cookie) =>
        {
            try
            {
                mocked = mockable.IsMocked;
            }
            finally
            {
                latch.Signal();
            }
        });
      
        latch.Wait();
      
        Assert.IsTrue(mocked);
    }

    Mock Threadpool documentation
Background-NextSteps

Next Steps

See Plans & Pricing

Purchase individual products or any of the bundles

Download Free Trial

With dedicated technical support.