private FixType EnsureOffsetBounds(int requestedOffset = 1) { // Past the end? if (Address.ToInt64() + (requestedOffset * ElementSize) > LastElement.ToInt64()) { // This is for isolated incidents when iterators // and pointer arithmetic move past the end by 1 element. // // So we'll automatically move to the last element instead, rather // than throwing an exception, just for convenience's sake. if (requestedOffset == 1) { MoveToEnd(); return(FixType.BounceBack); } return(FixType.OutOfBounds); } // Before the start? if (Address.ToInt64() + (requestedOffset * ElementSize) < FirstElement.ToInt64()) { // ... and vice versa if (requestedOffset == -1) { MoveToStart(); return(FixType.BounceBack); } return(FixType.OutOfBounds); } return(FixType.Verified); }
public override bool Equals(object obj) { var similar = obj as Similar; return(similar != null && EqualityComparer <string?> .Default.Equals(FirstElement?.ToString(), similar.FirstElement?.ToString()) && FirstXpath == similar.FirstXpath && EqualityComparer <string?> .Default.Equals(SecondElement?.ToString(), similar.SecondElement?.ToString()) && SecondXpath == similar.SecondXpath); }
public static IEnumerable <TestCaseData> GetTestCases() { var FIRST_ELEMENT = new FirstElement(); var LAST_ELEMENT = new LastElement(); var ELEMENT_AT = new ElementAt(); var SIZE = new Size(); object[][] tests = new object[][] { new object[] { "first-empty-array", FIRST_ELEMENT, new JArray(), null }, new object[] { "first-null", FIRST_ELEMENT, null, null }, new object[] { "first-array", FIRST_ELEMENT, new JArray(1, 2, 3), new JValue(1) }, new object[] { "last-empty-array", LAST_ELEMENT, new JArray(), null }, new object[] { "last-null", LAST_ELEMENT, null, null }, new object[] { "last-array", LAST_ELEMENT, new JArray(1, 2, 3), new JValue(3) }, new object[] { "at-empty-array", ELEMENT_AT, new JArray(5), null }, new object[] { "at-empty-null", ELEMENT_AT, new JArray(null, 1), null }, new object[] { "at-empty-invalid", ELEMENT_AT, new JObject(), null }, new object[] { "at-array", ELEMENT_AT, new JArray(1, 2, 3, 1), new JValue(3) }, new object[] { "at-array-missing", ELEMENT_AT, new JArray(5, 1, 2, 3), null }, new object[] { "size-list", SIZE, new JArray(5, 1, 2, 3), new JValue(4) } }; foreach (var test in tests) { yield return(new TestCaseData(test.Skip(1).ToArray()) { TestName = $"RunTest({test[0]})" }); } }
public bool MatchesTo(CatalogElementCross cross) { return(FirstElement.MatchesTo(cross.FirstElement) && SecondElement.MatchesTo(cross.SecondElement) || FirstElement.MatchesTo(cross.SecondElement) && SecondElement.MatchesTo(cross.FirstElement)); }
public override int GetHashCode() { var hashCode = 801317247; hashCode = hashCode * -1521134295 + EqualityComparer <string?> .Default.GetHashCode(FirstElement?.ToString()); hashCode = hashCode * -1521134295 + EqualityComparer <string> .Default.GetHashCode(FirstXpath); hashCode = hashCode * -1521134295 + EqualityComparer <string?> .Default.GetHashCode(SecondElement?.ToString()); hashCode = hashCode * -1521134295 + EqualityComparer <string> .Default.GetHashCode(SecondXpath); return(hashCode); }
public override string ToString() { return(FirstElement.ToString() + " " + SecondElement.ToString()); }