Ejemplo n.º 1
0
        public void RemoveFromCacheTest()
        {
            //ARRANGE
            var readFromCache = false;
            var context       = new DbContextMock();

            context.Initialise();
            var cache = new CacheProviderMock();

            cache.ReadFrom += (_, __) => { readFromCache = true; };
            var federationPartyContextBuilder = new FederationPartyContextBuilder(context, cache);
            //ACT
            var before                     = cache.Contains("local");
            var federationContext          = federationPartyContextBuilder.BuildContext("local");
            var after                      = cache.Contains("local");
            var federationContextFromCache = federationPartyContextBuilder.BuildContext("local");

            federationPartyContextBuilder.RequestRefresh("local");
            var afterRemove = cache.Contains("local");

            //ASSERT
            Assert.IsFalse(before);
            Assert.IsTrue(after);
            Assert.IsTrue(readFromCache);
            Assert.AreSame(federationContext, federationContextFromCache);
            Assert.IsFalse(afterRemove);
        }
Ejemplo n.º 2
0
        public void PutCacheTest()
        {
            //ARRANGE
            var context = new DbContextMock();

            context.Initialise();
            var cache = new CacheProviderMock();
            var federationPartyContextBuilder = new FederationPartyContextBuilder(context, cache);
            //ACT
            var before            = cache.Contains("local");
            var federationContext = federationPartyContextBuilder.BuildContext("local");
            var after             = cache.Contains("local");

            //ASSERT
            Assert.IsFalse(before);
            Assert.IsTrue(after);
        }
Ejemplo n.º 3
0
        public MetadataContext BuildContext(MetadataGenerateRequest metadataGenerateContext)
        {
            if (metadataGenerateContext == null)
            {
                throw new ArgumentNullException("metadataGenerateContext");
            }

            var federationParty = this._cacheProvider.Get <FederationPartyConfiguration>(metadataGenerateContext.FederationPartyId);

            if (federationParty == null)
            {
                var federationPartyBuilder = new FederationPartyContextBuilder(this._dbContext, this._cacheProvider);
                federationParty = federationPartyBuilder.BuildContext(metadataGenerateContext.FederationPartyId);
            }

            return(federationParty.MetadataContext);
        }