Beispiel #1
0
        public void AsyncProxyCache_AddToCache_WaitRemovedCallback_ExpiredData()
        {
            var cache = new AsyncProxyCache(TimeSpan.FromMilliseconds(200));
            var ev    = new InnerData(new Transaction("123", ""))
            {
                Transaction = { UserSupportCallback = new TaskCompletionSource <UserTransaction>() }
            };
            Task <UserTransaction> wait = ev.Transaction.UserSupportCallback.Task;

            cache.AddToCache("123", ev.Transaction);

            try
            {
                wait.Wait();
            }
            catch (Exception e)
            {
                Assert.Fail(e.Message);
            }
            Assert.IsTrue(wait.Result.IsError);
        }
Beispiel #2
0
 private void SomeAsyncWork(Transaction transaction)
 {
     transaction.UserSupportCallback = new TaskCompletionSource <UserTransaction>();
     _asyncProxyCache.AddToCache(transaction.CacheKey, transaction);
 }