コード例 #1
0
        // GET: api/TestConfiguration/5
        public IHttpActionResult Get(int id)
        {
            IService <TestConfiguration> service = new TestConfigurationService();
            var item = service.Get(id);

            return(Ok(item));
        }
コード例 #2
0
        // DELETE: api/TestConfiguration/5
        public IHttpActionResult Delete(int id)
        {
            if (id <= 0)
            {
                return(BadRequest("Not a valid id"));
            }
            IService <TestConfiguration> service = new TestConfigurationService();

            service.Delete(id);
            return(Ok());
        }
コード例 #3
0
        // POST: api/TestConfiguration
        public IHttpActionResult Post([FromBody] TestConfiguration value)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest("Invalid data."));
            }

            IService <TestConfiguration> service = new TestConfigurationService();

            service.Update(value);
            return(Ok());
        }
コード例 #4
0
        public void TestCacheConfigurationDocument()
        {
            var cache = new TestCacheClient();

            cache.ClearCache();

            var documentKey = new ConfigurationDocumentKey("Test", new Version(1, 0), null, "");
            var cacheKey    = ((IDefinesCacheKey)documentKey).GetCacheKey();

            var    service    = new TestConfigurationService();
            object request    = new GetConfigurationDocumentRequest(documentKey);
            object response   = new GetConfigurationDocumentResponse(documentKey, DateTime.Now, DateTime.Now, "Test");
            var    invocation = new TestInvocation
            {
                Target     = service,
                Method     = typeof(IApplicationConfigurationReadService).GetMethod("GetConfigurationDocument", BindingFlags.FlattenHierarchy | BindingFlags.Instance | BindingFlags.NonPublic | BindingFlags.Public),
                TargetType = typeof(IApplicationConfigurationReadService),
                Request    = request,
                Response   = response
            };

            var directive = new ResponseCachingDirective(true, TimeSpan.FromMinutes(1), ResponseCachingSite.Server);
            var advice    = new ConcreteResponseCachingAdvice(directive);

            advice.Intercept(invocation);

            var cacheEntry = cache.Get(cacheKey, new CacheGetOptions(""));

            Assert.IsNotNull(cacheEntry);
            Assert.AreEqual(response, cacheEntry);

            request  = new SetConfigurationDocumentRequest(documentKey, "Test");
            response = new SetConfigurationDocumentResponse();

            invocation = new TestInvocation
            {
                Target     = service,
                Method     = typeof(IConfigurationService).GetMethod("SetConfigurationDocument", BindingFlags.FlattenHierarchy | BindingFlags.Instance | BindingFlags.NonPublic | BindingFlags.Public),
                TargetType = typeof(IConfigurationService),
                Request    = request,
                Response   = response
            };

            advice = new ConcreteResponseCachingAdvice(null);
            advice.Intercept(invocation);

            cacheEntry = cache.Get(cacheKey, new CacheGetOptions(""));
            Assert.IsNull(cacheEntry);
        }
コード例 #5
0
        public void TestCacheListSettingsGroups()
        {
            var cache = new TestCacheClient();

            cache.ClearCache();

            var    service    = new TestConfigurationService();
            object request    = new ListSettingsGroupsRequest();
            object response   = new ListSettingsGroupsResponse(new List <SettingsGroupDescriptor>());
            var    invocation = new TestInvocation
            {
                Target     = service,
                Method     = typeof(IApplicationConfigurationReadService).GetMethod("ListSettingsGroups", BindingFlags.FlattenHierarchy | BindingFlags.Instance | BindingFlags.NonPublic | BindingFlags.Public),
                TargetType = typeof(IApplicationConfigurationReadService),
                Request    = request,
                Response   = response
            };

            var directive = new ResponseCachingDirective(true, TimeSpan.FromMinutes(1), ResponseCachingSite.Server);
            var advice    = new ConcreteResponseCachingAdvice(directive);

            advice.Intercept(invocation);

            var cacheEntry = cache.Get("ListSettingsGroups", new CacheGetOptions(""));

            Assert.IsNotNull(cacheEntry);

            request = new ImportSettingsGroupRequest(
                new SettingsGroupDescriptor("Test", new Version(1, 0), "Test", "Test", true),
                new List <SettingsPropertyDescriptor>(new[] { new SettingsPropertyDescriptor("Test", "Test", "Test", SettingScope.User, "Test") }));
            response = new ImportSettingsGroupResponse();

            invocation = new TestInvocation
            {
                Target     = service,
                Method     = typeof(IConfigurationService).GetMethod("ImportSettingsGroup", BindingFlags.FlattenHierarchy | BindingFlags.Instance | BindingFlags.NonPublic | BindingFlags.Public),
                TargetType = typeof(IConfigurationService),
                Request    = request,
                Response   = response
            };

            advice = new ConcreteResponseCachingAdvice(null);
            advice.Intercept(invocation);

            cacheEntry = cache.Get("ListSettingsGroups", new CacheGetOptions(""));
            Assert.IsNull(cacheEntry);
        }
コード例 #6
0
        public void TestSetup()
        {
            context = new XrmFakedContext();
            configurationService = new TestConfigurationService();
            crmService           = new TestCrmService(context);

            brandBucket        = new CacheBuckets.BrandBucket(crmService);
            countryBucket      = new CacheBuckets.CountryBucket(crmService);
            currencyBucket     = new CacheBuckets.CurrencyBucket(crmService);
            gatewayBucket      = new CacheBuckets.GatewayBucket(crmService);
            sourceMarketBucket = new CacheBuckets.SourceMarketBucket(crmService);
            tourOperatorBucket = new CacheBuckets.TourOperatorBucket(crmService);
            hotelBucket        = new CacheBuckets.HotelBucket(crmService);

            cachingService = new CachingService(brandBucket
                                                , countryBucket
                                                , currencyBucket
                                                , gatewayBucket
                                                , sourceMarketBucket
                                                , tourOperatorBucket
                                                , hotelBucket);

            controller = new CacheController(cachingService, configurationService);
        }
コード例 #7
0
		public void TestCacheListSettingsGroups()
		{
			var cache = new TestCacheClient();
			cache.ClearCache();

			var service = new TestConfigurationService();
			object request = new ListSettingsGroupsRequest();
			object response = new ListSettingsGroupsResponse(new List<SettingsGroupDescriptor>());
			var invocation = new TestInvocation
			{
				Target = service,
				Method = typeof(IApplicationConfigurationReadService).GetMethod("ListSettingsGroups", BindingFlags.FlattenHierarchy | BindingFlags.Instance | BindingFlags.NonPublic | BindingFlags.Public),
				TargetType = typeof(IApplicationConfigurationReadService),
				Request = request,
				Response = response
			};

			var directive = new ResponseCachingDirective(true, TimeSpan.FromMinutes(1), ResponseCachingSite.Server);
			var advice = new ConcreteResponseCachingAdvice(directive);
			advice.Intercept(invocation);

			var cacheEntry = cache.Get("ListSettingsGroups", new CacheGetOptions(""));
			Assert.IsNotNull(cacheEntry);

			request = new ImportSettingsGroupRequest(
				new SettingsGroupDescriptor("Test", new Version(1,0), "Test", "Test", true), 
				new List<SettingsPropertyDescriptor>(new[]{new SettingsPropertyDescriptor("Test", "Test", "Test", SettingScope.User, "Test") }));
			response = new ImportSettingsGroupResponse();

			invocation = new TestInvocation
			{
				Target = service,
				Method = typeof(IConfigurationService).GetMethod("ImportSettingsGroup", BindingFlags.FlattenHierarchy | BindingFlags.Instance | BindingFlags.NonPublic | BindingFlags.Public),
				TargetType = typeof(IConfigurationService),
				Request = request,
				Response = response
			};

			advice = new ConcreteResponseCachingAdvice(null);
			advice.Intercept(invocation);

			cacheEntry = cache.Get("ListSettingsGroups", new CacheGetOptions(""));
			Assert.IsNull(cacheEntry);
		}
コード例 #8
0
		public void TestCacheConfigurationDocument()
		{
			var cache = new TestCacheClient();
			cache.ClearCache();

			var documentKey = new ConfigurationDocumentKey("Test", new Version(1, 0), null, "");
			var cacheKey = ((IDefinesCacheKey) documentKey).GetCacheKey();

			var service = new TestConfigurationService();
			object request = new GetConfigurationDocumentRequest(documentKey);
			object response = new GetConfigurationDocumentResponse(documentKey, DateTime.Now, DateTime.Now, "Test");
			var invocation = new TestInvocation
			{
				Target = service,
				Method = typeof(IApplicationConfigurationReadService).GetMethod("GetConfigurationDocument", BindingFlags.FlattenHierarchy | BindingFlags.Instance | BindingFlags.NonPublic | BindingFlags.Public),
				TargetType = typeof(IApplicationConfigurationReadService),
				Request = request,
				Response = response
			};

			var directive = new ResponseCachingDirective(true, TimeSpan.FromMinutes(1), ResponseCachingSite.Server);
			var advice = new ConcreteResponseCachingAdvice(directive);
			advice.Intercept(invocation);

			var cacheEntry = cache.Get(cacheKey, new CacheGetOptions(""));
			Assert.IsNotNull(cacheEntry);
			Assert.AreEqual(response, cacheEntry);

			request = new SetConfigurationDocumentRequest(documentKey, "Test");
			response = new SetConfigurationDocumentResponse();

			invocation = new TestInvocation
			{
				Target = service,
				Method = typeof(IConfigurationService).GetMethod("SetConfigurationDocument", BindingFlags.FlattenHierarchy | BindingFlags.Instance | BindingFlags.NonPublic | BindingFlags.Public),
				TargetType = typeof(IConfigurationService),
				Request = request,
				Response = response
			};

			advice = new ConcreteResponseCachingAdvice(null);
			advice.Intercept(invocation);

			cacheEntry = cache.Get(cacheKey, new CacheGetOptions(""));
			Assert.IsNull(cacheEntry);
		}
コード例 #9
0
 public void TestSetup()
 {
     configurationService = new TestConfigurationService();
     helper = new JsonWebTokenHelper(configurationService, Api.Booking);
 }