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 UpdateItemInCache_ItemExists_ResultSetIsUpdatedAndSorted() { PalasoTestItem itemToModify = dataMapper.CreateItem(); itemToModify.StoredString = "Item 6"; dataMapper.SaveItem(itemToModify); 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); itemToModify.StoredString = "Item 7"; dataMapper.SaveItem(itemToModify); resultSetCacheUnderTest.UpdateItemInCache(itemToModify); Assert.AreEqual(8, resultSetCacheUnderTest.GetResultSet().Count); Assert.AreEqual(null, resultSetCacheUnderTest.GetResultSet()[0]["StoredString"]); Assert.AreEqual("Item 0", resultSetCacheUnderTest.GetResultSet()[1]["StoredString"]); Assert.AreEqual("Item 1", resultSetCacheUnderTest.GetResultSet()[2]["StoredString"]); Assert.AreEqual("Item 2", resultSetCacheUnderTest.GetResultSet()[3]["StoredString"]); Assert.AreEqual("Item 3", resultSetCacheUnderTest.GetResultSet()[4]["StoredString"]); Assert.AreEqual("Item 4", resultSetCacheUnderTest.GetResultSet()[5]["StoredString"]); Assert.AreEqual("Item 5", resultSetCacheUnderTest.GetResultSet()[6]["StoredString"]); Assert.AreEqual("Item 7", resultSetCacheUnderTest.GetResultSet()[7]["StoredString"]); }
public void UpdateItemInCache_ItemDoesNotExistInCacheButDoesInRepository_ItemIsAddedToResultSetAndSortedCorrectly() { 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"; dataMapper.SaveItem(itemCreatedAfterCache); resultSetCacheUnderTest.UpdateItemInCache(itemCreatedAfterCache); Assert.AreEqual(8, resultSetCacheUnderTest.GetResultSet().Count); Assert.AreEqual(null, resultSetCacheUnderTest.GetResultSet()[0]["StoredString"]); Assert.AreEqual("Item 0", resultSetCacheUnderTest.GetResultSet()[1]["StoredString"]); Assert.AreEqual("Item 1", resultSetCacheUnderTest.GetResultSet()[2]["StoredString"]); Assert.AreEqual("Item 2", resultSetCacheUnderTest.GetResultSet()[3]["StoredString"]); Assert.AreEqual("Item 3", resultSetCacheUnderTest.GetResultSet()[4]["StoredString"]); Assert.AreEqual("Item 4", resultSetCacheUnderTest.GetResultSet()[5]["StoredString"]); Assert.AreEqual("Item 5", resultSetCacheUnderTest.GetResultSet()[6]["StoredString"]); Assert.AreEqual("Item 6", resultSetCacheUnderTest.GetResultSet()[7]["StoredString"]); }
public void UpdateItemInCache_ItemHasNotChanged_ResultSetIsNotChanged() { PalasoTestItem unmodifiedItem = dataMapper.CreateItem(); unmodifiedItem.StoredString = "Item 6"; dataMapper.SaveItem(unmodifiedItem); //_results = dataMapper.GetItemsMatching(_queryToCache); 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); resultSetCacheUnderTest.UpdateItemInCache(unmodifiedItem); //Would be a better test but ResultSets don't support equality checks //Assert.AreEqual(resultsBeforeUpdate, resultsAfterUpdate); Assert.AreEqual(8, resultSetCacheUnderTest.GetResultSet().Count); Assert.AreEqual(null, resultSetCacheUnderTest.GetResultSet()[0]["StoredString"]); Assert.AreEqual("Item 0", resultSetCacheUnderTest.GetResultSet()[1]["StoredString"]); Assert.AreEqual("Item 1", resultSetCacheUnderTest.GetResultSet()[2]["StoredString"]); Assert.AreEqual("Item 2", resultSetCacheUnderTest.GetResultSet()[3]["StoredString"]); Assert.AreEqual("Item 3", resultSetCacheUnderTest.GetResultSet()[4]["StoredString"]); Assert.AreEqual("Item 4", resultSetCacheUnderTest.GetResultSet()[5]["StoredString"]); Assert.AreEqual("Item 5", resultSetCacheUnderTest.GetResultSet()[6]["StoredString"]); Assert.AreEqual("Item 6", resultSetCacheUnderTest.GetResultSet()[7]["StoredString"]); }
public void UpdateItemInCache_ItemDoesNotExistInRepository_Throws() { ResultSetCache <PalasoTestItem> resultSetCacheUnderTest = new ResultSetCache <PalasoTestItem>(_dataMapper, _sortDefinitions, _results, _queryToCache); PalasoTestItem itemNotInRepository = new PalasoTestItem(); Assert.Throws <ArgumentOutOfRangeException>(() => resultSetCacheUnderTest.UpdateItemInCache(itemNotInRepository)); }
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 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"]); }
public void UpdateItemInCache_ItemHasNotChanged_ResultSetIsNotChanged() { PalasoTestItem unmodifiedItem = _dataMapper.CreateItem(); unmodifiedItem.StoredString = "Item 1"; _dataMapper.SaveItem(unmodifiedItem); _results = _dataMapper.GetItemsMatching(_queryToCache); ResultSetCache <PalasoTestItem> resultSetCacheUnderTest = new ResultSetCache <PalasoTestItem>(_dataMapper, _sortDefinitions, _results, _queryToCache); resultSetCacheUnderTest.UpdateItemInCache(unmodifiedItem); //Would be a better test but ResultSets don't support equality checks //Assert.AreEqual(resultsBeforeUpdate, resultsAfterUpdate); 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 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"]); }
public void UpdateItemInCache_Null_Throws() { ResultSetCache<TestItem> resultSetCacheUnderTest = new ResultSetCache<TestItem>(_repository, _sortDefinitions, _results, _queryToCache); resultSetCacheUnderTest.UpdateItemInCache(null); }
public void UpdateItemInCache_ItemHasNotChanged_ResultSetIsNotChanged() { TestItem unmodifiedItem = _repository.CreateItem(); unmodifiedItem.StoredString = "Item 6"; _repository.SaveItem(unmodifiedItem); //_results = _repository.GetItemsMatching(_queryToCache); ResultSetCache<TestItem> resultSetCacheUnderTest = new ResultSetCache<TestItem>(_repository, _sortDefinitions, _results, _queryToCache); QueryAdapter<TestItem> secondQueryToCache = new QueryAdapter<TestItem>(); secondQueryToCache.In("Child").Show("StoredString"); ResultSet<TestItem> results = _repository.GetItemsMatching(secondQueryToCache); resultSetCacheUnderTest.Add(results, secondQueryToCache); resultSetCacheUnderTest.UpdateItemInCache(unmodifiedItem); //Would be a better test but ResultSets don't support equality checks //Assert.AreEqual(resultsBeforeUpdate, resultsAfterUpdate); Assert.AreEqual(8, resultSetCacheUnderTest.GetResultSet().Count); Assert.AreEqual(null, resultSetCacheUnderTest.GetResultSet()[0]["StoredString"]); Assert.AreEqual("Item 0", resultSetCacheUnderTest.GetResultSet()[1]["StoredString"]); Assert.AreEqual("Item 1", resultSetCacheUnderTest.GetResultSet()[2]["StoredString"]); Assert.AreEqual("Item 2", resultSetCacheUnderTest.GetResultSet()[3]["StoredString"]); Assert.AreEqual("Item 3", resultSetCacheUnderTest.GetResultSet()[4]["StoredString"]); Assert.AreEqual("Item 4", resultSetCacheUnderTest.GetResultSet()[5]["StoredString"]); Assert.AreEqual("Item 5", resultSetCacheUnderTest.GetResultSet()[6]["StoredString"]); Assert.AreEqual("Item 6", resultSetCacheUnderTest.GetResultSet()[7]["StoredString"]); }
public void UpdateItemInCache_ItemExists_ResultSetIsUpdatedAndSorted() { TestItem itemToModify = _repository.CreateItem(); itemToModify.StoredString = "Item 6"; _repository.SaveItem(itemToModify); ResultSetCache<TestItem> resultSetCacheUnderTest = new ResultSetCache<TestItem>(_repository, _sortDefinitions, _results, _queryToCache); QueryAdapter<TestItem> secondQueryToCache = new QueryAdapter<TestItem>(); secondQueryToCache.In("Child").Show("StoredString"); ResultSet<TestItem> results = _repository.GetItemsMatching(secondQueryToCache); resultSetCacheUnderTest.Add(results, secondQueryToCache); itemToModify.StoredString = "Item 7"; _repository.SaveItem(itemToModify); resultSetCacheUnderTest.UpdateItemInCache(itemToModify); Assert.AreEqual(8, resultSetCacheUnderTest.GetResultSet().Count); Assert.AreEqual(null, resultSetCacheUnderTest.GetResultSet()[0]["StoredString"]); Assert.AreEqual("Item 0", resultSetCacheUnderTest.GetResultSet()[1]["StoredString"]); Assert.AreEqual("Item 1", resultSetCacheUnderTest.GetResultSet()[2]["StoredString"]); Assert.AreEqual("Item 2", resultSetCacheUnderTest.GetResultSet()[3]["StoredString"]); Assert.AreEqual("Item 3", resultSetCacheUnderTest.GetResultSet()[4]["StoredString"]); Assert.AreEqual("Item 4", resultSetCacheUnderTest.GetResultSet()[5]["StoredString"]); Assert.AreEqual("Item 5", resultSetCacheUnderTest.GetResultSet()[6]["StoredString"]); Assert.AreEqual("Item 7", resultSetCacheUnderTest.GetResultSet()[7]["StoredString"]); }
public void UpdateItemInCache_ItemDoesNotExistInCacheButDoesInRepository_ItemIsAddedToResultSetAndSortedCorrectly() { ResultSetCache<TestItem> resultSetCacheUnderTest = new ResultSetCache<TestItem>(_repository, _sortDefinitions, _results, _queryToCache); QueryAdapter<TestItem> secondQueryToCache = new QueryAdapter<TestItem>(); secondQueryToCache.In("Child").Show("StoredString"); ResultSet<TestItem> results = _repository.GetItemsMatching(secondQueryToCache); resultSetCacheUnderTest.Add(results, secondQueryToCache); TestItem itemCreatedAfterCache = _repository.CreateItem(); itemCreatedAfterCache.StoredString = "Item 6"; _repository.SaveItem(itemCreatedAfterCache); resultSetCacheUnderTest.UpdateItemInCache(itemCreatedAfterCache); Assert.AreEqual(8, resultSetCacheUnderTest.GetResultSet().Count); Assert.AreEqual(null, resultSetCacheUnderTest.GetResultSet()[0]["StoredString"]); Assert.AreEqual("Item 0", resultSetCacheUnderTest.GetResultSet()[1]["StoredString"]); Assert.AreEqual("Item 1", resultSetCacheUnderTest.GetResultSet()[2]["StoredString"]); Assert.AreEqual("Item 2", resultSetCacheUnderTest.GetResultSet()[3]["StoredString"]); Assert.AreEqual("Item 3", resultSetCacheUnderTest.GetResultSet()[4]["StoredString"]); Assert.AreEqual("Item 4", resultSetCacheUnderTest.GetResultSet()[5]["StoredString"]); Assert.AreEqual("Item 5", resultSetCacheUnderTest.GetResultSet()[6]["StoredString"]); Assert.AreEqual("Item 6", resultSetCacheUnderTest.GetResultSet()[7]["StoredString"]); }
public void MultipleQueries_QueriedFieldsAreIdentical_ReturnsOnlyOneRecordToken() { ResultSetCache<TestItem> resultSetCacheUnderTest = new ResultSetCache<TestItem>(_repository, _sortDefinitions, _results, _queryToCache); QueryAdapter<TestItem> secondQueryToCache = new QueryAdapter<TestItem>(); secondQueryToCache.In("Child").Show("StoredString"); ResultSet<TestItem> results = _repository.GetItemsMatching(secondQueryToCache); resultSetCacheUnderTest.Add(results, secondQueryToCache); TestItem itemCreatedAfterCache = _repository.CreateItem(); itemCreatedAfterCache.StoredString = "Item 6"; itemCreatedAfterCache.Child.StoredString = "Item 6"; _repository.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 UpdateItemInCache_ItemHasNotChanged_ResultSetIsNotChanged() { TestItem unmodifiedItem = _repository.CreateItem(); unmodifiedItem.StoredList = PopulateListWith("Item 5", "Item 4"); _repository.SaveItem(unmodifiedItem); _results = _repository.GetItemsMatching(_queryToCache); ResultSetCache<TestItem> resultSetCacheUnderTest = new ResultSetCache<TestItem>(_repository, _sortDefinitions, _results, _queryToCache); resultSetCacheUnderTest.UpdateItemInCache(unmodifiedItem); //Would be a better test but ResultSets don't support equality checks //Assert.AreEqual(resultsBeforeUpdate, resultsAfterUpdate); 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"]); }
public void UpdateItemInCache_ItemExists_ResultSetIsUpdatedAndSorted() { TestItem itemToModify = _repository.CreateItem(); itemToModify.StoredList = PopulateListWith("Change Me!", "Me 2!"); _repository.SaveItem(itemToModify); _results = _repository.GetItemsMatching(_queryToCache); ResultSetCache<TestItem> resultSetCacheUnderTest = new ResultSetCache<TestItem>(_repository, _sortDefinitions, _results, _queryToCache); itemToModify.StoredList = PopulateListWith("Item 5", "Item 4"); _repository.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"]); }
public void UpdateItemInCache_ItemDoesNotExistInRepository_Throws() { ResultSetCache<TestItem> resultSetCacheUnderTest = new ResultSetCache<TestItem>(_repository, _sortDefinitions, _results, _queryToCache); TestItem itemNotInRepository = new TestItem(); resultSetCacheUnderTest.UpdateItemInCache(itemNotInRepository); }
public void UpdateItemInCache_Null_Throws() { ResultSetCache <PalasoTestItem> resultSetCacheUnderTest = new ResultSetCache <PalasoTestItem>(_dataMapper, _sortDefinitions, _results, _queryToCache); Assert.Throws <ArgumentNullException>(() => resultSetCacheUnderTest.UpdateItemInCache(null)); }
public void UpdateItemInCache_ItemDoesNotExistInCacheButDoesInRepository_ItemIsAddedToResultSetAndSortedCorrectly() { ResultSetCache<TestItem> resultSetCacheUnderTest = new ResultSetCache<TestItem>(_repository, _sortDefinitions, _results, _queryToCache); TestItem itemCreatedAfterCache = _repository.CreateItem(); itemCreatedAfterCache.StoredString = "Item 1"; _repository.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 UpdateItemInCache_ItemExists_ResultSetIsUpdatedAndSorted() { TestItem itemToModify = _repository.CreateItem(); itemToModify.StoredString = "Item 5"; _repository.SaveItem(itemToModify); _results = _repository.GetItemsMatching(_queryToCache); ResultSetCache<TestItem> resultSetCacheUnderTest = new ResultSetCache<TestItem>(_repository, _sortDefinitions, _results, _queryToCache); itemToModify.StoredString = "Item 1"; _repository.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"]); }