Esempio n. 1
0
        public void AcquireThread_GivenNoAvailableThreads_ShouldReturnNull()
        {
            // Arrange.
            var testObject = new ThreadPool(maxThreadCount: 1);

            testObject.AcquireThread();

            // Act.
            Thread thread = testObject.AcquireThread();

            // Assert.
            Assert.Null(thread);
        }
Esempio n. 2
0
        public void ReleaseThread_GivenNoAvailableThreads_ShouldMakeReleasedThreadAvailableForAcquire()
        {
            // Arrange.
            var testObject = new ThreadPool(maxThreadCount: 3);

            var acquiredThread = testObject.AcquireThread();

            testObject.AcquireThread();
            testObject.AcquireThread();

            Assert.Null(testObject.AcquireThread());

            // Act.
            testObject.ReleaseThread(acquiredThread);

            Thread thread = testObject.AcquireThread();

            // Assert.
            Assert.NotNull(thread);
        }