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); }
public async Task GetAny_DisposeIt_ItMustBeDisposed() { var pool = new DisposableObjectUsingPool(); var dispObjs = new DispoableObject[10]; for (int i = 0; i < dispObjs.Length; i++) { dispObjs[i] = await pool.GetAsync(i); } for (int i = 0; i < dispObjs.Length; i++) { pool.Return(i); Assert.IsTrue(dispObjs[i].IsDisposed, i.ToString()); } }