public virtual void TestEquals() { Expression expr = JavascriptCompiler.Compile("sqrt(_score) + ln(popularity)"); SimpleBindings bindings = new SimpleBindings(); bindings.Add(new SortField("_score", SortFieldType.SCORE)); bindings.Add(new SortField("popularity", SortFieldType.INT32)); SimpleBindings otherBindings = new SimpleBindings(); otherBindings.Add(new SortField("_score", SortFieldType.INT64)); otherBindings.Add(new SortField("popularity", SortFieldType.INT32)); SortField sf1 = expr.GetSortField(bindings, true); // different order SortField sf2 = expr.GetSortField(bindings, false); Assert.IsFalse(sf1.Equals(sf2)); // different bindings sf2 = expr.GetSortField(otherBindings, true); Assert.IsFalse(sf1.Equals(sf2)); // different expression Expression other = JavascriptCompiler.Compile("popularity/2"); sf2 = other.GetSortField(bindings, true); Assert.IsFalse(sf1.Equals(sf2)); // null Assert.IsFalse(sf1.Equals(null)); // same instance: Assert.AreEqual(sf1, sf1); }
public override bool Equals(object obj) { if (obj is ResultWrapper <T> ) { ResultWrapper <T> target = (ResultWrapper <T>)obj; if (SortField != null) { return(SortField.Equals(target.SortField)); } return(_reference.Equals(target._reference)); } return(false); }
public override bool Equals(object obj) { if (obj == null) { return(false); } if (obj == this) { return(true); } return(obj is SearchOrdersSort other && ((SortField == null && other.SortField == null) || (SortField?.Equals(other.SortField) == true)) && ((SortOrder == null && other.SortOrder == null) || (SortOrder?.Equals(other.SortOrder) == true))); }
public override bool Equals(object obj) { if (obj == null) { return(false); } if (obj == this) { return(true); } return(obj is ListCustomersRequest other && ((Cursor == null && other.Cursor == null) || (Cursor?.Equals(other.Cursor) == true)) && ((SortField == null && other.SortField == null) || (SortField?.Equals(other.SortField) == true)) && ((SortOrder == null && other.SortOrder == null) || (SortOrder?.Equals(other.SortOrder) == true))); }