Exemplo n.º 1
0
 public void TestAddDuplicateIndex()
 {
     Assert.False(_target.IsDirty); //Dirty flag set prematurely");
     _target.AddIndexAsync(_testModels[0], _testModels[0].Key).Wait();
     Assert.True(_target.IsDirty); //Dirty flag not set on add.");
     Assert.Single(_target.Query); //Index count is incorrect.");
     _target.AddIndexAsync(_testModels[0], _testModels[0].Key).Wait();
     Assert.Single(_target.Query); //Index count is incorrect.");            
 }
Exemplo n.º 2
0
        public void TestSerialization()
        {
            _target.AddIndexAsync(_testModels[0], _testModels[0].Key).Wait();
            _target.AddIndexAsync(_testModels[1], _testModels[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 IndexCollection <TestModel, string, int>("TestIndex", _driver,
                                                                            tm => tm.Data,
                                                                            _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 testIndex = (from k in secondTarget.Query where k.Index.Equals(_testModels[1].Data) select k).FirstOrDefault();

            Assert.IsNotNull(testIndex, "Test index not retrieved.");
            Assert.AreEqual(_testModels[1].Key, testIndex.Key, "Key mismatch.");
            Assert.AreEqual(0, _testAccessCount, "Lazy loader was accessed prematurely.");
            var testModel = testIndex.Value.Result;

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

            // now let's test refresh
            secondTarget.AddIndexAsync(_testModels[2], _testModels[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.");
        }
Exemplo n.º 3
0
        public void TestSerialization()
        {
            _target.AddIndexAsync(_testModels[0], _testModels[0].Key).Wait();
            _target.AddIndexAsync(_testModels[1], _testModels[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 IndexCollection<TestModel, string, int>("TestIndex", _driver,
                                                                 tm => tm.Data,
                                                                 _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 testIndex = (from k in secondTarget.Query where k.Index.Equals(_testModels[1].Data) select k).FirstOrDefault();
            Assert.IsNotNull(testIndex, "Test index not retrieved.");
            Assert.AreEqual(_testModels[1].Key, testIndex.Key, "Key mismatch.");
            Assert.AreEqual(0, _testAccessCount, "Lazy loader was accessed prematurely.");
            var testModel = testIndex.Value.Result;
            Assert.AreSame(_testModels[1], testModel, "Model does not match.");
            Assert.AreEqual(1, _testAccessCount, "Lazy loader access count is incorrect.");

            // now let's test refresh
            secondTarget.AddIndexAsync(_testModels[2],_testModels[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.");

        }
Exemplo n.º 4
0
 public void TestAddIndex()
 {
     Assert.IsFalse(_target.IsDirty, "Dirty flag set prematurely");
     _target.AddIndexAsync(_testModels[0], _testModels[0].Key).Wait();
     Assert.IsTrue(_target.IsDirty, "Dirty flag not set on add.");
 }