Beispiel #1
0
 public void Setup()
 {
     dataMapper = new MemoryDataMapper <PalasoTestItem>();
     PopulateRepositoryWithItemsForQuerying(dataMapper);
     _queryToCache = new QueryAdapter <PalasoTestItem>();
     _queryToCache.ShowEach("StoredList");
     _results            = dataMapper.GetItemsMatching(_queryToCache);
     _sortDefinitions    = new SortDefinition[1];
     _sortDefinitions[0] = new SortDefinition("StoredList", Comparer <string> .Default);
 }
Beispiel #2
0
        public void UpdateItemInCache_ItemExists_ResultSetIsUpdatedAndSorted()
        {
            PalasoTestItem itemToModify = _dataMapper.CreateItem();

            itemToModify.StoredString = "Item 5";
            _dataMapper.SaveItem(itemToModify);

            _results = _dataMapper.GetItemsMatching(_queryToCache);
            ResultSetCache <PalasoTestItem> resultSetCacheUnderTest = new ResultSetCache <PalasoTestItem>(_dataMapper, _sortDefinitions, _results, _queryToCache);

            itemToModify.StoredString = "Item 1";
            _dataMapper.SaveItem(itemToModify);
            resultSetCacheUnderTest.UpdateItemInCache(itemToModify);

            Assert.AreEqual(4, resultSetCacheUnderTest.GetResultSet().Count);
            Assert.AreEqual("Item 0", resultSetCacheUnderTest.GetResultSet()[0]["StoredString"]);
            Assert.AreEqual("Item 1", resultSetCacheUnderTest.GetResultSet()[1]["StoredString"]);
            Assert.AreEqual("Item 2", resultSetCacheUnderTest.GetResultSet()[2]["StoredString"]);
            Assert.AreEqual("Item 3", resultSetCacheUnderTest.GetResultSet()[3]["StoredString"]);
        }
Beispiel #3
0
        public void UpdateItemInCache_ItemExists_ResultSetIsUpdatedAndSorted()
        {
            PalasoTestItem itemToModify = dataMapper.CreateItem();

            itemToModify.StoredList = PopulateListWith("Change Me!", "Me 2!");
            dataMapper.SaveItem(itemToModify);

            _results = dataMapper.GetItemsMatching(_queryToCache);
            ResultSetCache <PalasoTestItem> resultSetCacheUnderTest = new ResultSetCache <PalasoTestItem>(dataMapper, _sortDefinitions, _results, _queryToCache);

            itemToModify.StoredList = PopulateListWith("Item 5", "Item 4");
            dataMapper.SaveItem(itemToModify);
            resultSetCacheUnderTest.UpdateItemInCache(itemToModify);

            Assert.AreEqual(6, resultSetCacheUnderTest.GetResultSet().Count);
            Assert.AreEqual("Item 0", resultSetCacheUnderTest.GetResultSet()[0]["StoredList"]);
            Assert.AreEqual("Item 1", resultSetCacheUnderTest.GetResultSet()[1]["StoredList"]);
            Assert.AreEqual("Item 2", resultSetCacheUnderTest.GetResultSet()[2]["StoredList"]);
            Assert.AreEqual("Item 3", resultSetCacheUnderTest.GetResultSet()[3]["StoredList"]);
            Assert.AreEqual("Item 4", resultSetCacheUnderTest.GetResultSet()[4]["StoredList"]);
            Assert.AreEqual("Item 5", resultSetCacheUnderTest.GetResultSet()[5]["StoredList"]);
        }
Beispiel #4
0
        public void Add_ResultsSetNull_Throws()
        {
            ResultSetCache <PalasoTestItem> resultSetCacheUnderTest = new ResultSetCache <PalasoTestItem>(dataMapper, _sortDefinitions, _results, _queryToCache);

            QueryAdapter <PalasoTestItem> secondQueryToCache = new QueryAdapter <PalasoTestItem>();

            secondQueryToCache.In("Child").Show("StoredString");
            ResultSet <PalasoTestItem> results = dataMapper.GetItemsMatching(secondQueryToCache);

            Assert.Throws <ArgumentNullException>(() => resultSetCacheUnderTest.Add(null, secondQueryToCache));
        }
Beispiel #5
0
 public ResultSet <T> GetItemsMatching(IQuery <T> query)
 {
     return(_backend.GetItemsMatching(query));
 }