コード例 #1
0
ファイル: ResultSetCacheTests.cs プロジェクト: bbriggs/wesay
		public void Constructor_IsPassedUnsortedResultSet_GetResultSetReturnsSorted()
		{
			ResultSetCache<TestItem> resultSetCacheUnderTest = new ResultSetCache<TestItem>(_repository, _sortDefinitions, _results, _queryToCache);
			Assert.AreEqual(3, resultSetCacheUnderTest.GetResultSet().Count);
			Assert.AreEqual("Item 0", resultSetCacheUnderTest.GetResultSet()[0]["StoredString"]);
			Assert.AreEqual("Item 2", resultSetCacheUnderTest.GetResultSet()[1]["StoredString"]);
			Assert.AreEqual("Item 3", resultSetCacheUnderTest.GetResultSet()[2]["StoredString"]);
		}
コード例 #2
0
        public void Constructor_IsPassedUnsortedResultSet_GetResultSetReturnsSorted()
        {
            ResultSetCache <PalasoTestItem> resultSetCacheUnderTest = new ResultSetCache <PalasoTestItem>(_dataMapper, _sortDefinitions, _results, _queryToCache);

            Assert.AreEqual(3, resultSetCacheUnderTest.GetResultSet().Count);
            Assert.AreEqual("Item 0", resultSetCacheUnderTest.GetResultSet()[0]["StoredString"]);
            Assert.AreEqual("Item 2", resultSetCacheUnderTest.GetResultSet()[1]["StoredString"]);
            Assert.AreEqual("Item 3", resultSetCacheUnderTest.GetResultSet()[2]["StoredString"]);
        }
コード例 #3
0
        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"]);
        }
コード例 #4
0
        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"]);
        }
コード例 #5
0
        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"]);
        }
コード例 #6
0
        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"]);
        }
コード例 #7
0
        public void DeleteAllItemsFromCache_AllItemsAreDeleted()
        {
            ResultSetCache <PalasoTestItem> resultSetCacheUnderTest = new ResultSetCache <PalasoTestItem>(dataMapper, _sortDefinitions, _results, _queryToCache);

            resultSetCacheUnderTest.DeleteAllItemsFromCache();
            Assert.AreEqual(0, resultSetCacheUnderTest.GetResultSet().Count);
        }
コード例 #8
0
        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"]);
        }
コード例 #9
0
        public void DeleteItemFromCacheById_Id_ItemIsNoLongerInResultSet()
        {
            PalasoTestItem itemToDelete = dataMapper.CreateItem();

            itemToDelete.StoredString = "Item 6";
            dataMapper.SaveItem(itemToDelete);

            //_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.DeleteItemFromCache(itemToDelete);

            //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]["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"]);
        }
コード例 #10
0
ファイル: ResultSetCacheTests.cs プロジェクト: bbriggs/wesay
		public void Constructor_SortDefinitionNull_SortedByRepositoryId()
		{
			ResultSetCache<TestItem> resultSetCacheUnderTest = new ResultSetCache<TestItem>(_repository, null, _results, _queryToCache);
			ResultSet<TestItem> resultSet = resultSetCacheUnderTest.GetResultSet();
			Assert.AreEqual(3, resultSet.Count);
			for (int recordTokenNum = 0; recordTokenNum < (resultSet.Count - 1); recordTokenNum++)
			{
				Assert.IsTrue(resultSet[recordTokenNum].Id.CompareTo(resultSet[recordTokenNum + 1].Id) < 0);
			}
		}
コード例 #11
0
        public void Constructor_SortDefinitionNull_SortedByRepositoryId()
        {
            ResultSetCache <PalasoTestItem> resultSetCacheUnderTest = new ResultSetCache <PalasoTestItem>(_dataMapper, null, _results, _queryToCache);
            ResultSet <PalasoTestItem>      resultSet = resultSetCacheUnderTest.GetResultSet();

            Assert.AreEqual(3, resultSet.Count);
            for (int recordTokenNum = 0; recordTokenNum < (resultSet.Count - 1); recordTokenNum++)
            {
                Assert.IsTrue(resultSet[recordTokenNum].Id.CompareTo(resultSet[recordTokenNum + 1].Id) < 0);
            }
        }
コード例 #12
0
        public void DeleteItemFromCacheById_Id_ItemIsNoLongerInResultSet()
        {
            PalasoTestItem itemToDelete = _dataMapper.CreateItem();

            itemToDelete.StoredString = "Item 1";
            _dataMapper.SaveItem(itemToDelete);

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

            resultSetCacheUnderTest.DeleteItemFromCache(itemToDelete);

            //Would be a better test but ResultSets don't support equality checks
            //Assert.AreEqual(resultsBeforeUpdate, resultsAfterUpdate);

            Assert.AreEqual(3, resultSetCacheUnderTest.GetResultSet().Count);
            Assert.AreEqual("Item 0", resultSetCacheUnderTest.GetResultSet()[0]["StoredString"]);
            Assert.AreEqual("Item 2", resultSetCacheUnderTest.GetResultSet()[1]["StoredString"]);
            Assert.AreEqual("Item 3", resultSetCacheUnderTest.GetResultSet()[2]["StoredString"]);
        }
コード例 #13
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"]);
        }
コード例 #14
0
        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"]);
        }
コード例 #15
0
        public void DeleteAllItemsFromCache_AllItemsAreDeleted()
        {
            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.DeleteAllItemsFromCache();
            Assert.AreEqual(0, resultSetCacheUnderTest.GetResultSet().Count);
        }
コード例 #16
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"]);
        }
コード例 #17
0
ファイル: ResultSetCacheTests.cs プロジェクト: bbriggs/wesay
		public void DeleteItemFromCacheById_Id_ItemIsNoLongerInResultSet()
		{
			TestItem itemToDelete = _repository.CreateItem();
			itemToDelete.StoredString = "Item 6";
			_repository.SaveItem(itemToDelete);

			//_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.DeleteItemFromCache(itemToDelete);

			//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]["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"]);
		}
コード例 #18
0
ファイル: ResultSetCacheTests.cs プロジェクト: bbriggs/wesay
		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"]);
		}
コード例 #19
0
ファイル: ResultSetCacheTests.cs プロジェクト: bbriggs/wesay
		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"]);
		}
コード例 #20
0
ファイル: ResultSetCacheTests.cs プロジェクト: bbriggs/wesay
		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"]);
		}
コード例 #21
0
ファイル: ResultSetCacheTests.cs プロジェクト: bbriggs/wesay
		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"]);
		}
コード例 #22
0
ファイル: ResultSetCacheTests.cs プロジェクト: bbriggs/wesay
		public void DeleteAllItemsFromCache_AllItemsAreDeleted()
		{
			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.DeleteAllItemsFromCache();
			Assert.AreEqual(0, resultSetCacheUnderTest.GetResultSet().Count);
		}
コード例 #23
0
ファイル: ResultSetCacheTests.cs プロジェクト: bbriggs/wesay
		public void DeleteAllItemsFromCache_AllItemsAreDeleted()
		{
			ResultSetCache<TestItem> resultSetCacheUnderTest = new ResultSetCache<TestItem>(_repository, _sortDefinitions, _results, _queryToCache);
			resultSetCacheUnderTest.DeleteAllItemsFromCache();
			Assert.AreEqual(0, resultSetCacheUnderTest.GetResultSet().Count);
		}
コード例 #24
0
ファイル: ResultSetCacheTests.cs プロジェクト: bbriggs/wesay
		public void DeleteItemFromCacheById_Item_ItemIsNoLongerInResultSet()
		{
			TestItem itemToDelete = _repository.CreateItem();
			itemToDelete.StoredList = PopulateListWith("Item 5", "Item 4");
			_repository.SaveItem(itemToDelete);

			_results = _repository.GetItemsMatching(_queryToCache);
			ResultSetCache<TestItem> resultSetCacheUnderTest = new ResultSetCache<TestItem>(_repository, _sortDefinitions, _results, _queryToCache);
			resultSetCacheUnderTest.DeleteItemFromCache(_repository.GetId(itemToDelete));

			//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]["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"]);
		}
コード例 #25
0
ファイル: ResultSetCacheTests.cs プロジェクト: bbriggs/wesay
		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"]);
		}
コード例 #26
0
ファイル: ResultSetCacheTests.cs プロジェクト: bbriggs/wesay
		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"]);
		}
コード例 #27
0
ファイル: ResultSetCacheTests.cs プロジェクト: bbriggs/wesay
		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"]);
		}
コード例 #28
0
ファイル: ResultSetCacheTests.cs プロジェクト: bbriggs/wesay
		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"]);
		}