public void TestSerialization()
        {
            _target.AddKeyAsync(_models[0].Key).Wait();
            _target.AddKeyAsync(_models[1].Key).Wait();
            Assert.IsTrue(_target.IsDirty, "Dirty flag not set.");
            _target.FlushAsync().Wait();
            Assert.IsFalse(_target.IsDirty, "Dirty flag not reset on flush.");

            var secondTarget = new KeyCollection <TestModel, int>(_driver,
                                                                  _GetTestModelByKey);

            // are we able to grab things?
            Assert.AreEqual(2, secondTarget.Query.Count(), "Key count is incorrect.");
            Assert.AreEqual(0, _testAccessCount, "Lazy loader was accessed prematurely.");
            var testKey = (from k in secondTarget.Query where k.Key.Equals(_models[1].Key) select k).FirstOrDefault();

            Assert.IsNotNull(testKey, "Test key not retrieved.");
            Assert.AreEqual(_models[1].Key, testKey.Key, "Key mismatch.");
            Assert.AreEqual(0, _testAccessCount, "Lazy loader was accessed prematurely.");
            var testModel = testKey.LazyValue.Value;

            Assert.AreSame(_models[1], testModel, "Model does not match.");
            Assert.AreEqual(1, _testAccessCount, "Lazy loader access count is incorrect.");

            // now let's test refresh
            secondTarget.AddKeyAsync(_models[2].Key).Wait();
            secondTarget.FlushAsync().Wait();

            Assert.AreEqual(2, _target.Query.Count(), "Unexpected key count in original collection.");
            _target.RefreshAsync().Wait();
            Assert.AreEqual(3, _target.Query.Count(), "Refresh failed.");
        }
        public void TestSerialization()
        {
            _target.AddKeyAsync(_models[0].Key).Wait();
            _target.AddKeyAsync(_models[1].Key).Wait();
            Assert.IsTrue(_target.IsDirty, "Dirty flag not set.");
            _target.FlushAsync().Wait();
            Assert.IsFalse(_target.IsDirty, "Dirty flag not reset on flush.");

            var secondTarget = new KeyCollection<TestModel, int>(_driver,
                                                                 _GetTestModelByKey);

            // are we able to grab things?
            Assert.AreEqual(2, secondTarget.Query.Count(), "Key count is incorrect.");
            Assert.AreEqual(0, _testAccessCount, "Lazy loader was accessed prematurely.");
            var testKey = (from k in secondTarget.Query where k.Key.Equals(_models[1].Key) select k).FirstOrDefault();
            Assert.IsNotNull(testKey, "Test key not retrieved.");
            Assert.AreEqual(_models[1].Key, testKey.Key, "Key mismatch.");
            Assert.AreEqual(0, _testAccessCount, "Lazy loader was accessed prematurely.");
            var testModel = testKey.LazyValue.Value;
            Assert.AreSame(_models[1], testModel, "Model does not match.");
            Assert.AreEqual(1, _testAccessCount, "Lazy loader access count is incorrect.");

            // now let's test refresh
            secondTarget.AddKeyAsync(_models[2].Key).Wait();
            secondTarget.FlushAsync().Wait();

            Assert.AreEqual(2, _target.Query.Count(), "Unexpected key count in original collection.");
            _target.RefreshAsync().Wait();
            Assert.AreEqual(3, _target.Query.Count(), "Refresh failed.");
            
        }