Beispiel #1
0
        public Antecedent(Array <IFeatureTest> featureTests)
        {
            if (featureTests.IsEmpty)
            {
                throw new ArgumentException(nameof(featureTests) + " can't be empty.");
            }

            var storage = new IFeatureTest[featureTests.Length];
            var hash    = new HashCode();

            // Checking nulls and indices are precomputing the hashcode
            for (int i = 0; i < storage.Length; i++)
            {
                var ft = featureTests[i];

                if (ft is null)
                {
                    throw new ArgumentException(nameof(featureTests) + " can't contain nulls.");
                }

                if (ft.FeatureIndex != i)
                {
                    throw new ArgumentException($"There is a mis-indexed {nameof(IFeatureTest)}." +
                                                $" Expected index {i}, actual {ft.FeatureIndex}.");
                }

                storage[i] = ft;
                hash.Add(ft);
            }

            FeatureTests = Array <IFeatureTest> .Wrap(storage);

            _precomputedHashCode = hash.ToHashCode();
        }
        public IInterval FromFeatureTest(IFeatureTest test)
        {
            return(test switch
            {
                ContinuousFeatureTest cft => FromContinuousFeatureTest(cft),

                _ => throw CommonExceptions.UnknownFeatureTestImplementation
            });
Beispiel #3
0
        public IFeatureTest[] FromHyperRectangle(HyperRectangle hyperRectangle)
        {
            var tests = new IFeatureTest[hyperRectangle.DimensionCount];

            for (int i = 0; i < tests.Length; i++)
            {
                var interval = hyperRectangle.GetDimensionInterval(i);
                var test     = _testIntervalConverter.FromDimensionInterval(interval);
                tests[i] = test;
            }

            return(tests);
        }
        internal async static System.Threading.Tasks.Task <bool> HasPassed(string apiBaseUrl, IFeatureTest test, WebServiceReader webServiceReader)
        {
            bool      result    = false;
            Paginator paginator = new Paginator();

            try
            {
                await paginator.PaginateServices(apiBaseUrl, string.Empty, async delegate(dynamic serviceList, int totalPages, int hash)
                {
                    if (serviceList == null)
                    {
                        result = false;
                    }
                    foreach (dynamic s in serviceList.content)
                    {
                        if (s != null && Convert.ToString(s.id.Value) == test.ServiceID)
                        {
                            result = true;
                            return(false);
                        }
                    }
                    return(true);
                }, webServiceReader, test.Parameters);
            }
            catch
            {
                //error logging not required here
                return(false);
            }
            return(result);
        }