Esempio n. 1
0
        /// <summary>
        /// Verifies that the hashcodes are uniformly distributed.
        /// </summary>
        internal void VerifyUniformDistribution()
        {
            HashStoreResult result = null;

            try
            {
                result = GetResult();
            }
            catch (NotEnoughHashesException)
            {
                Assert.Fail("Not enough hash code samples were provided to the hash code acceptance contract.");
            }

            double uniformDistributionDeviationProbability = result.UniformDistributionDeviationProbability;

            Assert.LessOrEqual(uniformDistributionDeviationProbability, UniformDistributionQualityLimit);
        }
        /// <summary>
        /// Initializes a new instance of the <see cref="HashStore"/> class.
        /// </summary>
        /// <param name="hashes">The collection of hashcodes.</param>
        public HashStore(IEnumerable <int> hashes)
        {
            int actual = 0;

            foreach (int num2 in hashes)
            {
                Add(num2);
                actual++;
            }

            if (actual < 2)
            {
                throw new NotEnoughHashesException(2, actual);
            }

            _result = CalculateResults(actual);
        }
Esempio n. 3
0
        /// <summary>
        /// Verifies that the probability of a hashcode collision is lower than the desired limit.
        /// </summary>
        internal void VerifyCollisionProbability()
        {
            HashStoreResult result = null;

            try
            {
                result = GetResult();
            }
            catch (NotEnoughHashesException)
            {
                Assert.Fail("Not enough hash code samples were provided to the hash code acceptance contract.");
            }

            double collisionProbability = result.CollisionProbability;

            Assert.LessOrEqual(collisionProbability, CollisionProbabilityLimit);
        }