public void op_Clear() { var obj = new MemoryCacheCollection { { AlphaDecimal.Random(), new object() } }; Assert.Equal(1, obj.Count); obj.Clear(); Assert.Equal(0, obj.Count); }
public void prop_Count_get() { var obj = new MemoryCacheCollection(); try { Assert.Equal(0, obj.Count); obj.Add(AlphaDecimal.Random(), new object()); Assert.Equal(1, obj.Count); } finally { obj.Clear(); } }
public void op_ContainsKey_string_whenFalse() { var obj = new MemoryCacheCollection(); try { obj[AlphaDecimal.Random()] = new object(); Assert.False(obj.ContainsKey(AlphaDecimal.Random())); } finally { obj.Clear(); } }
public void op_ContainsKey_string_whenTrue() { var obj = new MemoryCacheCollection(); try { var key = AlphaDecimal.Random(); obj[key] = new object(); Assert.True(obj.ContainsKey(key)); } finally { obj.Clear(); } }
public void op_Get_string_FuncObject_whenMissing() { var obj = new MemoryCacheCollection(); try { var key = AlphaDecimal.Random(); var actual = obj.Get(key, AddObject); Assert.NotNull(actual); } finally { obj.Clear(); } }
public void op_Get_string_FuncICacheCollectionT_whenMissing() { var obj = new MemoryCacheCollection(); try { var key = AlphaDecimal.Random(); var actual = obj.Get <DateTime>(key, AddToCacheOfT <DateTime>); Assert.NotNull(actual); } finally { obj.Clear(); } }
public void op_Add_string_object_DateTime_whenExpired() { var obj = new MemoryCacheCollection(); try { var key = AlphaDecimal.Random(); obj.Add(key, new object(), DateTime.UtcNow.AddDays(-1)); Assert.Null(obj[key]); } finally { obj.Clear(); } }
public void op_Set_string_object_TimeSpan() { var obj = new MemoryCacheCollection(); try { var key = AlphaDecimal.Random(); obj.Set(key, new object(), new TimeSpan(123456)); Assert.True(obj.ContainsKey(key)); } finally { obj.Clear(); } }
public void op_Set_string_object_DateTime() { var obj = new MemoryCacheCollection(); try { var key = AlphaDecimal.Random(); obj.Set(key, new object(), DateTime.UtcNow.AddDays(1)); Assert.True(obj.ContainsKey(key)); } finally { obj.Clear(); } }
public void op_Get_string_FuncT_whenMissing() { var obj = new MemoryCacheCollection(); try { var key = AlphaDecimal.Random(); var expected = default(DateTime); var actual = obj.Get <DateTime>(key, AddOfT <DateTime>); Assert.Equal(expected, actual); } finally { obj.Clear(); } }
public void op_Add_string_object_TimeSpan() { var obj = new MemoryCacheCollection(); try { var key = AlphaDecimal.Random(); var expected = new object(); obj.Add(key, expected, new TimeSpan(12345)); var actual = obj[key]; Assert.Same(expected, actual); } finally { obj.Clear(); } }
public void op_GetEnumerator() { var obj = new MemoryCacheCollection(); try { var key = AlphaDecimal.Random(); var expected = new object(); obj[key] = expected; var actual = obj.First(); Assert.Same(expected, actual); } finally { obj.Clear(); } }
public void op_Add_string_object_DateTime() { var obj = new MemoryCacheCollection(); try { var key = AlphaDecimal.Random(); var expected = new object(); obj.Add(key, expected, DateTime.UtcNow.AddDays(1)); var actual = obj[key]; Assert.Same(expected, actual); } finally { obj.Clear(); } }
public void op_GetOfT_string() { var obj = new MemoryCacheCollection(); try { var key = AlphaDecimal.Random(); const int expected = 123; obj[key] = expected; var actual = obj.Get <int>(key); Assert.Equal(expected, actual); } finally { obj.Clear(); } }
public void indexer_string() { var obj = new MemoryCacheCollection(); try { var key = AlphaDecimal.Random(); var expected = new object(); obj[key] = expected; var actual = obj[key]; Assert.Same(expected, actual); } finally { obj.Clear(); } }
public void op_Remove_string() { var obj = new MemoryCacheCollection(); try { var key = AlphaDecimal.Random(); var expected = new object(); obj[key] = expected; var actual = obj.Remove(key); Assert.False(obj.ContainsKey(key)); Assert.Same(expected, actual); } finally { obj.Clear(); } }
public void op_Get_string_FuncObject() { var obj = new MemoryCacheCollection(); try { var key = AlphaDecimal.Random(); var expected = new object(); obj[key] = expected; var actual = obj.Get(key, AddObject); Assert.Equal(expected, actual); } finally { obj.Clear(); } }