Exemple #1
0
        public void ThrowsAnExceptionWhenAfterDispose()
        {
            var target = new TestableWorkerPool(cache.Object, cacheMonitor.Object);

            target.Dispose();

            Assert.Throws <ObjectDisposedException>(() => target.Get(OnRun, OnCompleted));
        }
Exemple #2
0
        public void ThrowsAnExceptionWhenTheWorkerIsNull()
        {
            cache.Setup(o => o.Get()).Returns(worker.Object);

            using var target = new TestableWorkerPool(cache.Object, cacheMonitor.Object)
                  {
                      OnBaseCreatePooledWorkerCallback = o => null
                  };

            Assert.Throws <ArgumentNullException>(() => target.Get(OnRun, OnCompleted));
            cache.Verify(o => o.Release(worker.Object), Times.Once);
        }