public void ExistingObject_IncrementByOneAndSetExpirationDate()
{
// Arrange
var key = new SimpleThrottleKey("test", "key");
var limiter = new Limiter()
.Limit(1)
.Over(100);
var cache = new MemoryCache("testing_cache");
var repository = new MemoryThrottleRepository(cache);
string id = repository.CreateThrottleKey(key, limiter);
var cacheItem = new MemoryThrottleRepository.ThrottleCacheItem()
{
Count = 1,
Expiration = new DateTime(2030, 1, 1)
};
cache
.Set(id, cacheItem, cacheItem.Expiration);
// Act
repository.AddOrIncrementWithExpiration(key, limiter);
// Assert
var item = (MemoryThrottleRepository.ThrottleCacheItem)cache.Get(id);
Assert.Equal(2L, item.Count);
Assert.Equal(new DateTime(2030, 1, 1), item.Expiration);
}