public void InvalidateOnTypeWorks()
        {
            var obj   = factory.Create <IObjectWithParametersOnCachedMethod>();
            var value = obj.CachedMethod("hej");

            factory.Invalidate <IObjectWithParametersOnCachedMethod>();
            Assert.AreNotEqual(value, obj.CachedMethod("hej"));
        }
        public void InvalidateByInstance()
        {
            var value1 = obj1.CachedMethod();
            var value2 = obj2.CachedMethod();

            factory.Invalidate(obj1);

            value1.Should().Not.Be.EqualTo(obj1.CachedMethod());
            value2.Should().Be.EqualTo(obj2.CachedMethod());
        }
Exemplo n.º 3
0
        public void VerifyInvalidateByType()
        {
            var obj    = factory.Create <IObjectReturningNewGuids>();
            var value1 = obj.CachedMethod();
            var value2 = obj.CachedMethod2();

            Assert.AreEqual(value1, obj.CachedMethod());
            Assert.AreEqual(value2, obj.CachedMethod2());
            Assert.AreNotEqual(value1, value2);
            factory.Invalidate <IObjectReturningNewGuids>();
            Assert.AreNotEqual(value1, obj.CachedMethod());
            Assert.AreNotEqual(value2, obj.CachedMethod2());
        }
Exemplo n.º 4
0
        public void InvalidateAll()
        {
            var instance = factory.Create <ObjectWithMultipleParameters>();

            CacheKeyWithScope.CurrentScope = "FirstScope";
            var result = instance.Calculate(0, "", 0);

            CacheKeyWithScope.CurrentScope = "SecondScope";
            factory.Invalidate();
            CacheKeyWithScope.CurrentScope = "FirstScope";
            instance.Calculate(0, "", 0)
            .Should().Not.Be.EqualTo(result);
        }
Exemplo n.º 5
0
        public void CanInvalidate()
        {
            var obj    = factory.Create <ObjectReturningNewGuidsNoInterface>();
            var value1 = obj.CachedMethod();

            factory.Invalidate <ObjectReturningNewGuidsNoInterface>();
            obj.CachedMethod().Should().Not.Be.EqualTo(value1);
        }
 public void ShouldNotGetDuplicatesInList_InvalidateOnType([Range(1, 10)] int attempt)
 {
     runInParallell(() => factory.Invalidate <ObjectWithMutableList>());
 }
 public void ShouldNotGetDuplicatesInList_InvalidateAll()
 {
     runInParallell(() => factory.Invalidate());
 }