public async Task SetAsyncTest()
        {
            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())
            {
                await Assert.ThrowsExceptionAsync <ArgumentException>(
                    async() =>
                {
                    await d.SetAsync(tx, 1, "One");
                }
                    );

                await d.AddAsync(tx, 2, "Two");

                await tx.CommitAsync();
            }

            using (var tx = _stateManager.CreateTransaction())
            {
                await d.SetAsync(tx, 2, "Three");

                await tx.CommitAsync();

                Assert.AreEqual("Two", change.Removed);
                Assert.AreEqual("Three", change.Added);
            }

            Assert.AreEqual(1, await GetCount(d));
        }
        public async Task SetAsyncTest()
        {
            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())
            {
                await d.SetAsync(tx, 1, "Zero");
            }
            using (var tx = _stateManager.CreateTransaction())
            {
                ConditionalValue <string> value = await d.TryGetValueAsync(tx, 1, LockMode.Default);

                Assert.IsFalse(value.HasValue);
            }

            using (var tx = _stateManager.CreateTransaction())
            {
                await d.SetAsync(tx, 1, "One");

                await tx.CommitAsync();

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

            using (var tx = _stateManager.CreateTransaction())
            {
                await d.SetAsync(tx, 1, "Two");
            }
            using (var tx = _stateManager.CreateTransaction())
            {
                ConditionalValue <string> value = await d.TryGetValueAsync(tx, 1, LockMode.Default);

                Assert.AreEqual("One", value.Value);
            }

            using (var tx = _stateManager.CreateTransaction())
            {
                await d.AddAsync(tx, 2, "Two");

                await tx.CommitAsync();
            }

            using (var tx = _stateManager.CreateTransaction())
            {
                await d.SetAsync(tx, 2, "Three");

                await tx.CommitAsync();

                Assert.AreEqual("Two", change.Removed);
                Assert.AreEqual("Three", change.Added);
            }

            Assert.AreEqual(2, await GetCount(d));
        }