Exemplo n.º 1
0
        /// <summary>
        /// Uses a <see cref="DoubleArrayEqualityComparer"/> to check for equality.
        /// </summary>
        /// <param name="other">
        /// The object to compare with.
        /// </param>
        /// <returns>
        /// The true if other is equal.
        /// </returns>
        public override bool Equals(object other)
        {
            if (other == null)
            {
                return(false);
            }

            if (other is double[])
            {
                return(EqualityComparer.Equals(this._convertedGenome, (double[])other));
            }

            if (!(other is GenomeDoubleRepresentation))
            {
                return(false);
            }

            return(EqualityComparer.Equals(this._convertedGenome, ((GenomeDoubleRepresentation)other)._convertedGenome));
        }
Exemplo n.º 2
0
            /// <summary>
            /// Checks if <see cref="TestImpurityCalculator.CurrentTargets"/> is equal to <paramref name="targets"/>.
            /// </summary>
            /// <param name="impurityCalculator">The test impurity calculator.</param>
            /// <param name="targets">The targets parameter from <see cref="ISplitSearcher{TImpurityCalculator}.FindBestSplit"/>.</param>
            private void CheckIfTargetsDoMatch(TestImpurityCalculator impurityCalculator, double[] targets)
            {
                if (impurityCalculator.CurrentTargets == null)
                {
                    this._callCount.ShouldBeLessThanOrEqualTo(1);
                    return;
                }

                var arrayComparer = new DoubleArrayEqualityComparer();

                arrayComparer.Equals(impurityCalculator.CurrentTargets, targets).ShouldBe(true);
            }