public void Parse_Error(string input)
 {
     Assert.Throws <FormatException>(() =>
     {
         QosUrlTemplate.Parse(input);
     });
 }
        public void Parse_Success(string input, string expectedMethod, string expectedUrl)
        {
            var template = QosUrlTemplate.Parse(input);

            if (expectedMethod == null)
            {
                Assert.Null(template.HttpMethod);
            }
            else
            {
                Assert.Equal(expectedMethod, template.HttpMethod);
            }
            Assert.Equal(expectedUrl, template.Url);
        }
Example #3
0
        private IEnumerable <QosPolicy> BuildPolicies(
            QosQuotaOptions options,
            IEnumerable <IQosPolicyKeyEvaluatorProvider> keyEvaluatorProviders,
            IServiceProvider serviceProvider)
        {
            if (options?.Policies != null)
            {
                foreach (var option in options.Policies)
                {
                    var policy = new QosPolicy(option.Key)
                    {
                        Order        = -1100,
                        UrlTemplates = option.Value.UrlTemplates?.Select(u => QosUrlTemplate.Parse(u)),
                        Key          = keyEvaluatorProviders.Create(option.Value.Key),
                        Gate         = CreateGate(option.Value.Period, option.Value.MaxCount * 1024, option.Value.Distributed, serviceProvider)
                    };

                    yield return(policy);
                }
            }
        }