public void ShouldRetrieveFromCacheIfClientRequestByNexusIdMapping()
        {
            const string CacheKey = "MDM.SourceSystem";

            // Given
            var mockMdmEntityService = new Mock<IMdmEntityService<SourceSystem>>();
            var mockConfigManager = new Mock<IConfigurationManager>();
            var inmemoryCacheRepo = new DefaultMdmClientCacheRepository(new InMemoryCacheRepository());
            mockConfigManager.Setup(x => x.AppSettings).Returns(new NameValueCollection { { "CacheItemPolicy.Expiration." + CacheKey, "3500" } });
            var cachePolicyFactory = new AbsoluteCacheItemPolicyFactory(CacheKey, mockConfigManager.Object);
            var locationEntityService = new CachePolicyMdmEntityService<SourceSystem>(mockMdmEntityService.Object, cachePolicyFactory,inmemoryCacheRepo);
            var nexusId = new MdmId { SystemName = "Nexus", Identifier = "1", IsMdmId = true };
            var location = new SourceSystem
            {
                Identifiers = new MdmIdList { nexusId },
                Details = new SourceSystemDetails { Name = "Blah" }
            };

            //Setup a context, i.e. calling once to retrieve location should cache an entity..
            mockMdmEntityService.Setup(x => x.Get(1, It.IsAny<DateTime?>())).Returns(
                new WebResponse<SourceSystem> { Code = HttpStatusCode.OK, IsValid = true, Message = location });

            var response = locationEntityService.Get(nexusId);

            response.Code.Should().Be(HttpStatusCode.OK);
            response.Message.ToMdmId().Identifier.Should().Be(nexusId.Identifier);

            // When , we call second time..
            response = locationEntityService.Get(nexusId);

            // Then
            // It should not call mdm service again... should retrive form cache, so that verify...
            mockMdmEntityService.Verify(x => x.Get(1, It.IsAny<DateTime?>()), Times.Once());
            mockMdmEntityService.Verify(x => x.Get(It.IsAny<MdmId>(), It.IsAny<DateTime?>()), Times.Never());
            response.Code.Should().Be(HttpStatusCode.OK);
            response.Message.ToMdmId().Identifier.Should().Be(nexusId.Identifier);
        }
        public void Setup()
        {
            this.mdmService = new Mock<IMdmEntityService<SourceSystem>>();
            this.policyFactory = new Mock<ICacheItemPolicyFactory>();
            this.policy = new CacheItemPolicy();
            var inmemoryCacheRepo =new DefaultMdmClientCacheRepository(new InMemoryCacheRepository());
            this.policyFactory.Setup(x => x.CreatePolicy()).Returns(this.policy);

            this.cacheService = new CachePolicyMdmEntityService<SourceSystem>(this.mdmService.Object, this.policyFactory.Object,inmemoryCacheRepo);
        }