public async Task TryRemoveAsyncTest()
        {
            DictionaryChange change = null;
            TransactedConcurrentDictionary <int, string> d = new TransactedConcurrentDictionary <int, string>(
                new Uri("test://mocks", UriKind.Absolute),
                (c) =>
            {
                change = c;
                return(true);
            }
                );

            using (var tx = _stateManager.CreateTransaction())
            {
                Assert.IsFalse((await d.TryRemoveAsync(tx, 1)).HasValue);
                Assert.IsTrue(await d.TryAddAsync(tx, 1, "One"));

                using (var tx2 = _stateManager.CreateTransaction())
                {
                    await Assert.ThrowsExceptionAsync <TimeoutException>(
                        async() =>
                    {
                        await d.TryRemoveAsync(tx2, 1, timeout: TimeSpan.FromMilliseconds(20));
                    }
                        );
                }
                await tx.CommitAsync();

                Assert.AreEqual("One", change.Added);
            }

            using (var tx = _stateManager.CreateTransaction())
            {
                var result = await d.TryRemoveAsync(tx, 1);

                await tx.CommitAsync();

                Assert.AreEqual(ChangeType.Removed, change.ChangeType);
                Assert.AreEqual("One", change.Removed);
                Assert.AreEqual(0, await GetCount(d));
            }
        }
        public async Task TryUpdateAsyncTest()
        {
            DictionaryChangedEvent <int, string>         change = null;
            TransactedConcurrentDictionary <int, string> d      = new TransactedConcurrentDictionary <int, string>(
                new Uri("test://mocks", UriKind.Absolute),
                (s, e) =>
            {
                change = e;
            }
                );

            using (var tx = _stateManager.CreateTransaction())
            {
                Assert.IsFalse((await d.TryUpdateAsync(tx, 1, "Two", "One")));
                Assert.IsTrue(await d.TryAddAsync(tx, 1, "One"));

                using (var tx2 = _stateManager.CreateTransaction())
                {
                    await Assert.ThrowsExceptionAsync <TimeoutException>(
                        async() =>
                    {
                        await d.TryRemoveAsync(tx2, 1, timeout: TimeSpan.FromMilliseconds(20));
                    }
                        );
                }
                await tx.CommitAsync();

                Assert.AreEqual("One", change.Added);
            }

            using (var tx = _stateManager.CreateTransaction())
            {
                Assert.IsFalse((await d.TryUpdateAsync(tx, 1, "Three", "Two")));

                using (_stateManager.CreateTransaction())
                {
                    Assert.IsTrue((await d.TryUpdateAsync(tx, 1, "Two", "One")));
                }
                await tx.CommitAsync();

                Assert.AreEqual("Two", change.Added);
            }
        }
 public async Task RemoveAsync(ITransaction tx, Uri name, TimeSpan timeout)
 {
     await _store.TryRemoveAsync(tx, name, timeout);
 }