public virtual void Register(IEvent @event, IMetaInfo metaInfo) { V data; //Synchronization is left here mostly in consistency with cache and process, but factories are usually not thread safe anyway. lock (factory) { data = factory.Create(@event, metaInfo); } if (data != null) { lock (cache) { cache.Put(data); } TryProcessNextAsync(); } }
private static void TestCache(IEventDataCache <String, DataCacheTest.SimpleData> cache, IList <DataCacheTest.SimpleData > input, IList <DataCacheTest.SimpleData> expectedOutput) { foreach (DataCacheTest.SimpleData @event in input) { cache.Put(@event); } foreach (DataCacheTest.SimpleData expected in expectedOutput) { DataCacheTest.SimpleData actual = cache.RetrieveNext(); NUnit.Framework.Assert.AreEqual(expected.GetSignature(), actual.GetSignature()); NUnit.Framework.Assert.AreEqual(expected.GetCount(), actual.GetCount()); } }