public void When_Adding_To_The_Cache_Then_Entry_Is_Added_Correctly(dynamic objectToAdd) { // When value added to the lruCache _lruCache.Add(objectToAdd, objectToAdd); // Value exists in lruCache and added correctly Assert.That(_lruCache.ContainsKey(objectToAdd), Is.True); Assert.That(_lruCache.TryGetValue(objectToAdd, out dynamic result), Is.True); Assert.That(result, Is.EqualTo(objectToAdd)); }
private static void AddCacheEntries(ILruCache <dynamic, dynamic> lruCache, int numAdditions) { for (var i = 0; i < numAdditions; i++) { var ticks = DateTime.Now.Ticks; var key = $"key{ticks}"; var value = $"value{ticks}"; lruCache.Add(key, value); } }
public override void Init() { App.On(ApplicationEvents.ON_APPLICATION_START_COMPLETE, (sender, e) => { ILruBuilder builder = App.Make <ILruBuilder>(); ILruCache <string, string> cache = builder.Create <string, string>(3); cache.Add("key_1", "val_1"); cache.Add("key_2", "val_2"); cache.Add("key_3", "val_3"); foreach (var kv in cache) { Debug.Log(kv.Key + " , " + kv.Value); } var key = cache["key_2"]; Debug.Log("key is :" + key); Debug.Log("*******************"); foreach (var kv in cache) { Debug.Log(kv.Key + " , " + kv.Value); } cache.Add("key_4", "key_4"); Debug.Log("*******************"); foreach (var kv in cache) { Debug.Log(kv.Key + " , " + kv.Value); } }); }