private void PopulateRepositoryWithItemsForQuerying(MemoryDataMapper <PalasoTestItem> dataMapper) { PalasoTestItem[] items = new PalasoTestItem[2]; items[0] = dataMapper.CreateItem(); items[0].StoredList = PopulateListWith("Item 1", "Item 3"); dataMapper.SaveItem(items[0]); items[1] = dataMapper.CreateItem(); items[1].StoredList = PopulateListWith("Item 2", "Item 0"); dataMapper.SaveItem(items[1]); }
private void PopulateRepositoryWithItemsForQuerying(MemoryDataMapper <PalasoTestItem> dataMapper) { var items = new PalasoTestItem[3]; items[0] = dataMapper.CreateItem(); items[0].StoredString = "Item 3"; dataMapper.SaveItem(items[0]); items[1] = dataMapper.CreateItem(); items[1].StoredString = "Item 0"; dataMapper.SaveItem(items[1]); items[2] = dataMapper.CreateItem(); items[2].StoredString = "Item 2"; dataMapper.SaveItem(items[2]); }
public void MultipleQueries_QueriedFieldsAreIdentical_ReturnsOnlyOneRecordToken() { 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); resultSetCacheUnderTest.Add(results, secondQueryToCache); PalasoTestItem itemCreatedAfterCache = dataMapper.CreateItem(); itemCreatedAfterCache.StoredString = "Item 6"; itemCreatedAfterCache.Child.StoredString = "Item 6"; dataMapper.SaveItem(itemCreatedAfterCache); resultSetCacheUnderTest.UpdateItemInCache(itemCreatedAfterCache); Assert.AreEqual(7, 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"]); Assert.AreEqual("Item 4", resultSetCacheUnderTest.GetResultSet()[4]["StoredString"]); Assert.AreEqual("Item 5", resultSetCacheUnderTest.GetResultSet()[5]["StoredString"]); Assert.AreEqual("Item 6", resultSetCacheUnderTest.GetResultSet()[6]["StoredString"]); }
public void EntryWithIncomingUnspecifiedModTimeNotPruned() { Guid g = Guid.NewGuid(); Extensible eInfo = CreateFullextensibleInfo(g); LexEntry item = _dataMapper.CreateItem(); item.Guid = eInfo.Guid; item.Id = eInfo.Id; item.ModificationTime = eInfo.ModificationTime; item.CreationTime = eInfo.CreationTime; _dataMapper.SaveItem(item); //strip out the time eInfo.ModificationTime = Extensible.ParseDateTimeCorrectly("2005-01-01"); Assert.AreEqual(DateTimeKind.Utc, eInfo.ModificationTime.Kind); LexEntry found = _builder.GetOrMakeEntry(eInfo, 0); Assert.IsNotNull(found); }
public void UpdateItemInCache_ItemDoesNotExistInCacheButDoesInRepository_ItemIsAddedToResultSetAndSortedCorrectly() { ResultSetCache <PalasoTestItem> resultSetCacheUnderTest = new ResultSetCache <PalasoTestItem>(_dataMapper, _sortDefinitions, _results, _queryToCache); PalasoTestItem itemCreatedAfterCache = _dataMapper.CreateItem(); itemCreatedAfterCache.StoredString = "Item 1"; _dataMapper.SaveItem(itemCreatedAfterCache); resultSetCacheUnderTest.UpdateItemInCache(itemCreatedAfterCache); 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"]); }
public void SaveItem(T item) { _backend.SaveItem(item); UpdateLiftFileWithModified(item); }