public void MarkForRemoval_FailOnNonUTCDate() { ITRexSpatialMemoryCacheContext context = new TRexSpatialMemoryCacheContext(new TRexSpatialMemoryCache(100, 1000000, 0.5), new TRexSpatialMemoryCacheStorage <ITRexMemoryCacheItem>(100, 50)); Action act = () => context.MarkForRemoval(DateTime.Now); act.Should().Throw <TRexException>().WithMessage("MarkForRemoval is not a UTC date"); }
public void Test_TRexSpatialMemoryCacheContext_MarkForRemovalDirect() { ITRexSpatialMemoryCacheContext context = new TRexSpatialMemoryCacheContext(new TRexSpatialMemoryCache(100, 1000000, 0.5), new TRexSpatialMemoryCacheStorage <ITRexMemoryCacheItem>(100, 50)); Assert.False(context.MarkedForRemoval); var currentDate = DateTime.UtcNow; context.MarkForRemoval(DateTime.UtcNow); Assert.True(context.MarkedForRemoval, "Marking context for removal did not set state"); Assert.True(context.MarkedForRemovalAtUtc >= currentDate && context.MarkedForRemovalAtUtc <= DateTime.UtcNow, "Marking context for removal did not set state"); }
public void Test_TRexSpatialMemoryCacheContext_ReanimateViaItemAddition() { ITRexSpatialMemoryCacheContext context = new TRexSpatialMemoryCacheContext(new TRexSpatialMemoryCache(100, 1000000, 0.5), new TRexSpatialMemoryCacheStorage <ITRexMemoryCacheItem>(100, 50)); var element = new TRexSpatialMemoryCacheContextTests_Element { SizeInBytes = 1000, CacheOriginX = 2000, CacheOriginY = 3000 }; context.MarkForRemoval(DateTime.UtcNow); Assert.True(context.MarkedForRemoval, "Marking context for removal did not set state"); // Reanimate by adding an element Assert.True(context.OwnerMemoryCache.Add(context, element, context.InvalidationVersion) == CacheContextAdditionResult.Added, "Result is false on addition of first element"); Assert.False(context.MarkedForRemoval, "Marking context for removal did not set state"); Assert.True(context.MarkedForRemovalAtUtc == TRex.Common.Consts.MIN_DATETIME_AS_UTC, "Marking context for removal did not set date"); }