Пример #1
0
        public IEnumerable <string> Validate()
        {
            if (Transport == null)
            {
                yield return("Transport implementation is not set. It is a required part of configuration.");
            }

            if (ClusterProvider == null)
            {
                yield return("Cluster provider implementation is not set. It is a required part of configuration.");
            }

            if (ResponseCriteria?.Count > 0)
            {
                var lastCriterion = ResponseCriteria.Last();
                if (!(lastCriterion is AlwaysRejectCriterion) && !(lastCriterion is AlwaysAcceptCriterion))
                {
                    yield return($"Last response criterion must always be either an '{typeof (AlwaysRejectCriterion).Name}' or '{typeof (AlwaysAcceptCriterion).Name}'.");
                }
            }

            if (ResponseCriteria != null && ResponseCriteria.Any(criterion => criterion == null))
            {
                yield return("One of provided response criteria is null");
            }

            if (RequestTransforms != null && RequestTransforms.Any(transform => transform == null))
            {
                yield return("One of provided request transforms is null");
            }

            if (ResponseTransforms != null && ResponseTransforms.Any(transform => transform == null))
            {
                yield return("One of provided response transforms is null");
            }

            if (Modules != null && Modules.Any(module => module == null))
            {
                yield return("One of provided request modules is null");
            }

            if (DefaultTimeout <= TimeSpan.Zero)
            {
                yield return($"Default timeout must be positive, but was '{DefaultTimeout}'");
            }

            if (MaxReplicasUsedPerRequest <= 0)
            {
                yield return($"Maximum replicas per request must be > 0, but was {MaxReplicasUsedPerRequest}");
            }
        }
Пример #2
0
        public IEnumerable<string> Validate()
        {
            if (Transport == null)
                yield return "Transport implementation is not set. It is a required part of configuration.";

            if (ClusterProvider == null)
                yield return "Cluster provider implementation is not set. It is a required part of configuration.";

            if (ResponseCriteria?.Count > 0)
            {
                var lastCriterion = ResponseCriteria.Last();
                if (!(lastCriterion is AlwaysRejectCriterion) && !(lastCriterion is AlwaysAcceptCriterion))
                    yield return $"Last response criterion must always be either an '{typeof(AlwaysRejectCriterion).Name}' or '{typeof(AlwaysAcceptCriterion).Name}'.";
            }

            if (ResponseCriteria != null && ResponseCriteria.Any(criterion => criterion == null))
                yield return "One of provided response criteria is null";

            if (RequestTransforms != null && RequestTransforms.Any(transform => transform == null))
                yield return "One of provided request transforms is null";

            if (ResponseTransforms != null && ResponseTransforms.Any(transform => transform == null))
                yield return "One of provided response transforms is null";

            if (Modules != null && Modules.SelectMany(x => x.Value.After.Concat(x.Value.Before)).Any(module => module == null))
                yield return "One of provided request modules is null";

            if (DefaultTimeout <= TimeSpan.Zero)
                yield return $"Default timeout must be positive, but was '{DefaultTimeout}'";

            if (DefaultConnectionTimeout.HasValue && DefaultConnectionTimeout <= TimeSpan.Zero)
                yield return $"Default connection timeout must be positive, but was '{DefaultConnectionTimeout}'";

            if (MaxReplicasUsedPerRequest <= 0)
                yield return $"Maximum replicas per request must be > 0, but was {MaxReplicasUsedPerRequest}";

            if (ConnectionAttempts <= 0)
                yield return $"Connection attempts per replica must be > 0, but was {ConnectionAttempts}";
        }