Example #1
0
        /// <summary>
        /// Returns true iff <code>o</code> is equal to this. </summary>
        public override bool Equals(object o)
        {
            if (this == o)
            {
                return(true);
            }
            if (!(o is SpanNearQuery))
            {
                return(false);
            }

            SpanNearQuery spanNearQuery = (SpanNearQuery)o;

            if (m_inOrder != spanNearQuery.m_inOrder)
            {
                return(false);
            }
            if (m_slop != spanNearQuery.m_slop)
            {
                return(false);
            }
            if (!Equatable.Wrap(m_clauses).Equals(spanNearQuery.m_clauses))
            {
                return(false);
            }

            return(Boost == spanNearQuery.Boost);
        }
        public void ShouldBeA_SuperType_FailsWithTypesNotEqualMessage()
        {
            object actual = new Equatable(1);
            MockFormatter.NotEqual(typeof(SubEquatable), typeof(Equatable), "foo").Returns("bar");
            EasyAssertionException result = Assert.Throws<EasyAssertionException>(() => actual.ShouldBeA<SubEquatable>("foo"));

            Assert.AreEqual("bar", result.Message);
        }
Example #3
0
 /// <summary>
 /// Returns a hash code value for this object. </summary>
 public override int GetHashCode()
 {
     return(Number.SingleToInt32Bits(Boost)
            ^ Slop
            ^ Equatable.Wrap(GetTerms()).GetHashCode()
            ^ Equatable.Wrap(GetPositions()).GetHashCode()
            ^ n);
 }
Example #4
0
        public RegexGroup(Hash <string, IObject> passed) : this()
        {
            text   = "";
            index  = 0;
            length = 0;

            this.passed = passed;
            internals   = new Hash <string, IObject>();

            equatable = new Equatable <RegexGroup>(this, "text", "index", "length");
        }
Example #5
0
        public static EqualsData <Equatable> IEquatableData()
        {
            var one = new Equatable(1);

            return(new EqualsData <Equatable>
            {
                { one, one, true },
                { one, new Equatable(1), true },
                { new Equatable(int.MinValue + 1), new Equatable(1), false },
                { new Equatable(-1), new Equatable(int.MaxValue), false }
            });
        }
        public int LastIndexOf(T item)
        {
            for (var index = list.Count - 1; index >= 0; index--)
            {
                if (Equatable.Equals(item, list[index]))
                {
                    return(index);
                }
            }

            return(-1);
        }
Example #7
0
        public override bool Equals(object o)
        {
            if (this.GetType() != o.GetType())
            {
                return(false);
            }
            var other = (MultiFunction)o;

            // LUCENENET specific: ensure our passed in list is equatable by
            // wrapping it in an EquatableList if it is not one already
            return(Equatable.Wrap(this.m_sources).Equals(other.m_sources));
        }
Example #8
0
        public RegexMatch(Hash <string, IObject> passed) : this()
        {
            text        = "";
            index       = 0;
            length      = 0;
            groups      = new RegexGroup[0];
            nameToIndex = _ => none <int>();

            this.passed = passed;
            internals   = new Hash <string, IObject>();

            equatable = new Equatable <RegexMatch>(this, "text", "index", "length", "groups");
        }
Example #9
0
            public override bool Equals(object o)
            {
                if (object.ReferenceEquals(this, o))
                {
                    return(true);
                }

                if (!(o is Parent))
                {
                    return(false);
                }

                return(base.Equals(o) && Equatable.AreEqual(this.Children, (o as Parent).Children));
            }
Example #10
0
        public override int GetHashCode()
        {
            int result;

            result = Equatable.Wrap(m_clauses).GetHashCode();
            // Mix bits before folding in things like boost, since it could cancel the
            // last element of clauses.  this particular mix also serves to
            // differentiate SpanNearQuery hashcodes from others.
            result ^= (result << 14) | ((int)((uint)result >> 19)); // reversible
            result += Number.SingleToRawInt32Bits(Boost);
            result += m_slop;
            result ^= (m_inOrder ? unchecked ((int)0x99AFD3BD) : 0);
            return(result);
        }
Example #11
0
        public virtual bool Equals(T other)
        {
            if ((object)other == null)
            {
                return(false);
            }

            Type t         = GetType();
            Type otherType = other.GetType();

            if (t != otherType)
            {
                return(false);
            }

            FieldInfo[] fields = t.GetFields(BindingFlags.Instance | BindingFlags.NonPublic | BindingFlags.Public);

            foreach (FieldInfo field in fields)
            {
                object value1 = field.GetValue(other);
                object value2 = field.GetValue(this);

                if (value1 == null)
                {
                    if (value2 != null)
                    {
                        return(false);
                    }
                }
                else
                {
                    if (t.IsArray)
                    {
                        if (!Equatable.ArraysAreEqual(value1 as IList, value2 as IList))
                        {
                            return(false);
                        }
                    }

                    if (!value1.Equals(value2))
                    {
                        return(false);
                    }
                }
            }

            return(true);
        }
        public int IndexOf(T item)
        {
            var index = 0;

            foreach (var x in list)
            {
                if (Equatable.Equals(item, x))
                {
                    return(index);
                }

                index++;
            }

            return(-1);
        }
Example #13
0
        public override int GetHashCode()
        {
            const int prime  = 31;
            int       result = base.GetHashCode();

            result = prime * result + ((analyzer == null) ? 0 : analyzer.GetHashCode());
            result = prime * result + ((fieldName == null) ? 0 : fieldName.GetHashCode());
            result = prime * result + ((likeText == null) ? 0 : likeText.GetHashCode());
            result = prime * result + maxQueryTerms;
            result = prime * result + minDocFreq;
            result = prime * result + minTermFrequency;
            result = prime * result + Arrays.GetHashCode(moreLikeFields);
            result = prime * result + Number.SingleToInt32Bits(percentTermsToMatch);
            // LUCENENET: wrap in Equatable to compare set contents
            result = prime * result + ((stopWords == null) ? 0 : Equatable.Wrap(stopWords).GetHashCode());
            return(result);
        }
Example #14
0
        public RegexGroup(Matcher.Group group) : this()
        {
            var(groupText, groupIndex, groupLength) = group;
            text   = groupText;
            index  = groupIndex;
            length = groupLength;

            passed    = new Hash <string, IObject>();
            internals = new Hash <string, IObject>
            {
                ["text"]   = (String)text,
                ["index"]  = (Int)index,
                ["length"] = (Int)length
            };

            equatable = new Equatable <RegexGroup>(this, "text", "index", "length");
        }
Example #15
0
        public override bool Equals(object o)
        {
            if (this == o)
            {
                return(true);
            }
            if (!(o is VectorValueSource))
            {
                return(false);
            }

            var that = (VectorValueSource)o;

            // LUCENENET specific: ensure our passed in list is equatable by
            // wrapping it in an EquatableList if it is not one already
            return(Equatable.Wrap(m_sources).Equals(that.m_sources));
        }
        public int IndexOf(T item, int offset)
        {
            for (var index = 0; index < list.Count; index++)
            {
                if (index < offset)
                {
                    continue;
                }

                if (Equatable.Equals(item, list[index]))
                {
                    return(index);
                }
            }

            return(-1);
        }
Example #17
0
        public override int GetHashCode()
        {
            const int prime  = 31;
            int       result = base.GetHashCode();

            result = prime * result + (m_disableCoord ? 1231 : 1237);
            result = prime * result + Number.SingleToInt32Bits(m_highFreqBoost);
            result = prime * result + /*((highFreqOccur == null) ? 0 :*/ m_highFreqOccur.GetHashCode() /*)*/;
            result = prime * result + Number.SingleToInt32Bits(m_lowFreqBoost);
            result = prime * result + /*((lowFreqOccur == null) ? 0 :*/ m_lowFreqOccur.GetHashCode() /*)*/;
            result = prime * result + Number.SingleToInt32Bits(m_maxTermFrequency);
            result = prime * result + Number.SingleToInt32Bits(m_lowFreqMinNrShouldMatch);
            result = prime * result + Number.SingleToInt32Bits(m_highFreqMinNrShouldMatch);
            // LUCENENET specific: wrap the m_terms to ensure the collection values are
            // compared for equalitly
            result = prime * result + ((m_terms == null) ? 0 : Equatable.Wrap(m_terms).GetHashCode());
            return(result);
        }
Example #18
0
        public RegexMatch(Matcher.Match match, Func <string, IMaybe <int> > nameToIndex) : this()
        {
            text             = match.Text;
            index            = match.Index;
            length           = match.Length;
            groups           = match.Groups.Select(g => new RegexGroup(g)).ToArray();
            this.nameToIndex = nameToIndex;

            passed    = new Hash <string, IObject>();
            internals = new Hash <string, IObject>
            {
                ["text"]   = (String)text,
                ["index"]  = (Int)index,
                ["length"] = (Int)length,
                ["groups"] = new Tuple(groups.Select(g => (IObject)g).ToArray())
            };

            equatable = new Equatable <RegexMatch>(this, "text", "index", "length", "groups");
        }
Example #19
0
            public override bool Equals(object o)
            {
                if (ReferenceEquals(this, o))
                {
                    return(true);
                }

                if (!(o is EntityE))
                {
                    return(false);
                }

                var e = o as EntityE;

                if (!string.Equals(this.Name, e.Name))
                {
                    return(false);
                }

                return(Equatable.AreEqual(this.X, e.X) && Equatable.AreEqual(this.Y, e.Y) && (this.Y2 == null ? e.Y2 == null : this.Y2.Equals(e.Y2)));
            }
Example #20
0
 public override int GetHashCode()
 {
     // LUCENENET specific: ensure our passed in list is equatable by
     // wrapping it in an EquatableList if it is not one already
     return(Equatable.Wrap(m_sources).GetHashCode() + Name.GetHashCode());
 }
Example #21
0
 public bool Equals(Equatable other) => throw new NotImplementedException();
Example #22
0
 public Mixin(string name)
 {
     this.name = name;
     equatable = new Equatable <Mixin>(this, "name");
 }
        public void ShouldNotBe_EqualValue_FailsWithObjectsEqualMessage()
        {
            Equatable actual = new Equatable(1);
            Equatable notExpected = new Equatable(1);
            MockFormatter.AreEqual(notExpected, actual, "foo").Returns("bar");

            EasyAssertionException result = Assert.Throws<EasyAssertionException>(() => actual.ShouldNotBe(notExpected, "foo"));

            Assert.AreEqual("bar", result.Message);
        }
        public void ShouldReferTo_DifferentObject_FailsWithObjectsNotSameMessage()
        {
            Equatable actual = new Equatable(1);
            Equatable expected = new Equatable(1);
            MockFormatter.NotSame(expected, actual, "foo").Returns("bar");

            EasyAssertionException result = Assert.Throws<EasyAssertionException>(() => actual.ShouldReferTo(expected, "foo"));

            Assert.AreEqual("bar", result.Message);
        }
        public void ShouldNotBe_DifferentValue_ReturnsActualValue()
        {
            Equatable actual = new Equatable(1);

            Actual<Equatable> result = actual.ShouldNotBe(new Equatable(2));

            Assert.AreSame(actual, result.Value);
        }
        public void ShouldBe_SameValueReturnsActualValue()
        {
            Equatable actual = new Equatable(1);
            Equatable expected = new Equatable(1);
            Actual<Equatable> result = actual.ShouldBe(expected);

            Assert.AreSame(actual, result.And);
        }
Example #27
0
        public override bool Equals(object obj)
        {
            if (this == obj)
            {
                return(true);
            }
            if (!base.Equals(obj))
            {
                return(false);
            }
            if (this.GetType() != obj.GetType())
            {
                return(false);
            }
            var other = (CommonTermsQuery)obj;

            if (m_disableCoord != other.m_disableCoord)
            {
                return(false);
            }
            if (Number.SingleToInt32Bits(m_highFreqBoost) != Number.SingleToInt32Bits(other.m_highFreqBoost))
            {
                return(false);
            }
            if (m_highFreqOccur != other.m_highFreqOccur)
            {
                return(false);
            }
            if (Number.SingleToInt32Bits(m_lowFreqBoost) != Number.SingleToInt32Bits(other.m_lowFreqBoost))
            {
                return(false);
            }
            if (m_lowFreqOccur != other.m_lowFreqOccur)
            {
                return(false);
            }
            if (Number.SingleToInt32Bits(m_maxTermFrequency) != Number.SingleToInt32Bits(other.m_maxTermFrequency))
            {
                return(false);
            }
            if (m_lowFreqMinNrShouldMatch != other.m_lowFreqMinNrShouldMatch)
            {
                return(false);
            }
            if (m_highFreqMinNrShouldMatch != other.m_highFreqMinNrShouldMatch)
            {
                return(false);
            }
            if (m_terms == null)
            {
                if (other.m_terms != null)
                {
                    return(false);
                }
            }
            // LUCENENET specific: wrap the m_terms to ensure the collection values are
            // compared for equalitly
            else if (!Equatable.Wrap(m_terms).Equals(other.m_terms))
            {
                return(false);
            }
            return(true);
        }
Example #28
0
 public static bool operator ==(IdImpl obj1, IdImpl obj2) =>
 Equatable.IsEqual(obj1, obj2, (o1, o2) => o1.id == o2.id);
Example #29
0
        public override bool Equals(object obj)
        {
            if (this == obj)
            {
                return(true);
            }
            if (!base.Equals(obj))
            {
                return(false);
            }
            if (this.GetType() != obj.GetType())
            {
                return(false);
            }
            var other = (MoreLikeThisQuery)obj;

            if (analyzer == null)
            {
                if (other.analyzer != null)
                {
                    return(false);
                }
            }
            else if (!analyzer.Equals(other.analyzer))
            {
                return(false);
            }
            if (fieldName == null)
            {
                if (other.fieldName != null)
                {
                    return(false);
                }
            }
            else if (!fieldName.Equals(other.fieldName, StringComparison.Ordinal))
            {
                return(false);
            }
            if (likeText == null)
            {
                if (other.likeText != null)
                {
                    return(false);
                }
            }
            else if (!likeText.Equals(other.likeText, StringComparison.Ordinal))
            {
                return(false);
            }
            if (maxQueryTerms != other.maxQueryTerms)
            {
                return(false);
            }
            if (minDocFreq != other.minDocFreq)
            {
                return(false);
            }
            if (minTermFrequency != other.minTermFrequency)
            {
                return(false);
            }
            if (!Arrays.Equals(moreLikeFields, other.moreLikeFields))
            {
                return(false);
            }
            if (Number.SingleToInt32Bits(percentTermsToMatch) != Number.SingleToInt32Bits(other.percentTermsToMatch))
            {
                return(false);
            }
            if (stopWords == null)
            {
                if (other.stopWords != null)
                {
                    return(false);
                }
            }
            // LUCENENET: wrap in Equatable to compare set contents
            else if (!Equatable.Wrap(stopWords).Equals(other.stopWords))
            {
                return(false);
            }
            return(true);
        }