Example #1
0
        public void When_Key_Removed_Then_Nothing_Happens()
        {
            // Arrange
            var cache = new NoCacheProvider();

            cache.Add("My Key", "My Value", CacheOptions.Absolute(CacheItemPriority.Medium, TimeSpan.FromDays(1)));

            // Act
            cache.Remove("My Key");

            // Assert
            Assert.Pass("Test was successful, should be able to always successfully call Remove");
        }
Example #2
0
        public void When_Item_Added_Then_ContainsKey_Is_False()
        {
            // Arrange
            var cache = new NoCacheProvider();

            cache.Add("My Key", "My Value", CacheOptions.Absolute(CacheItemPriority.Medium, TimeSpan.FromDays(1)));

            // Act
            var result = cache.ContainsKey("My Key");

            // Assert
            result.Should().BeFalse();
        }
Example #3
0
        public void When_Item_Added_Then_GetValue_Returns_Default_Value()
        {
            // Arrange
            var cache = new NoCacheProvider();

            cache.Add("My Key", "My Value", CacheOptions.Absolute(CacheItemPriority.Medium, TimeSpan.FromDays(1)));

            // Act
            var result = cache.GetValue("My Key");

            // Assert
            result.Should().BeNull();
        }
Example #4
0
 /// <summary>
 /// Gets the options for the specified value, which will be an absolute cache
 /// options instance.
 /// </summary>
 /// <returns>
 /// The cache options to use when storing the specified value.
 /// </returns>
 /// <seealso cref="CacheOptions.Absolute"/>
 public override CacheOptions GetOptions()
 {
     return(CacheOptions.Absolute(this.ItemPriority, this.TimeSpan));
 }