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 LexEntry GetOrMakeEntry(Extensible eInfo, int order) { LexEntry entry = null; if (eInfo.CreationTime == default(DateTime)) { eInfo.CreationTime = PreciseDateTime.UtcNow; } if (eInfo.ModificationTime == default(DateTime)) { eInfo.ModificationTime = PreciseDateTime.UtcNow; } entry = _dataMapper.CreateItem(); entry.Id = eInfo.Id; entry.Guid = eInfo.Guid; entry.CreationTime = eInfo.CreationTime; entry.ModificationTime = eInfo.ModificationTime; if (_dataMapper.LastModified < entry.ModificationTime) { _dataMapper.LastModified = entry.ModificationTime; } entry.ModifiedTimeIsLocked = true; //while we build it up entry.OrderForRoundTripping = order; return(entry); }
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 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 T CreateItem() { T item = _backend.CreateItem(); return(item); }