public void TryFindResult_After_Add_To_Partition_Should_Return_False() { Contact result; var contact = new Contact() { ContactId = 1, Name = "Test User", ContactTypeId = 1 }; var specification = new Specification <Contact>(x => x.ContactTypeId == 1); IQueryOptions <Contact> queryOptions = new SortingOptions <Contact>("Name", true); CachingStrategy.SaveFindResult(specification, queryOptions, null, contact); CachingStrategy.TryFindResult(specification, queryOptions, null, out result).ShouldEqual(true); var contact2 = new Contact() { ContactId = 2, Name = "Test User 2", ContactTypeId = 1 }; CachingStrategy.Add(2, contact2); CachingStrategy.TryFindResult(specification, queryOptions, null, out result).ShouldEqual(false); CachingStrategy.SaveFindResult(specification, queryOptions, null, contact); // after saving the new results in the next generation then it should find it CachingStrategy.TryFindResult(specification, queryOptions, null, out result).ShouldEqual(true); }
public void OnItemAdded(TKey key, T item) { if (CacheEnabled) { _cachingStrategy.Add(key, item); } }
/// <summary> /// Called when an entity has been added /// </summary> public void OnEntityAdded(TIdentity identity, TEntity entity) { if (CacheEnabled) { _cachingStrategy.Add(identity, entity); } }