Example #1
0
        public async Task GetOne_ReturnInRunning_AfterMustBeDisposed()
        {
            var pool = new DisposableObjectUsingPool();

            pool.WaitTime = TimeSpan.FromSeconds(4);
            var a = pool.GetAsync(1);

            pool.Return(1);
            var obj = await a;
            await Task.Delay(1000);

            Assert.IsTrue(obj.IsDisposed);
            Assert.AreEqual(0, pool.Count);
        }
Example #2
0
        public async Task GetAny_DisposeAll_AllMustBeDisposed()
        {
            var pool     = new DisposableObjectUsingPool();
            var dispObjs = new DispoableObject[10];

            for (int i = 0; i < dispObjs.Length; i++)
            {
                dispObjs[i] = await pool.GetAsync(i);
            }
            pool.Dispose();
            for (int i = 0; i < dispObjs.Length; i++)
            {
                Assert.IsTrue(dispObjs[i].IsDisposed, i.ToString());
            }
        }