public void LatLonRect_RectSubsetTests() { //LatLonRect rect = LatLonRect.FromNWSE(new LatLon(12, 4), new LatLon(2, 24)); LatLonRect rect = LatLonRect.FromPointAndSpan(2, 4, 10, 20); LatLonRect result = rect.ApplySubset(new RectSubset() { Left = 1, Right = 2, Top = 3, Bottom = 4 }); LatLonRect expected = LatLonRect.FromPointAndSpan(6, 5, 3, 17); AssertExpectedVsActual("rect1", expected, result); result = rect.ApplySubset(new RectSubset() { Left = 0.25, LeftScale = RectSubsetScale.Relative, Right = 0.5, RightScale = RectSubsetScale.Relative, Top = 0.1, TopScale = RectSubsetScale.Relative, Bottom = 0.2, BottomScale = RectSubsetScale.Relative }); expected = LatLonRect.FromPointAndSpan(4, 9, 7, 5); AssertExpectedVsActual("rect2", expected, result); result = rect.ApplySubset(new RectSubset() { Left = -0.25, LeftScale = RectSubsetScale.Relative, Right = 10, Top = 0.1, TopScale = RectSubsetScale.Relative, Bottom = 0.2, BottomScale = RectSubsetScale.Relative, BottomValueType = RectSubsetValueType.Length }); expected = LatLonRect.FromPointAndSpan(9, 1.5, 2, 12.5); AssertExpectedVsActual("rect3", expected, result); result = rect.ApplySubset(new RectSubset() { Left = 10, LeftValueType = RectSubsetValueType.Length, Top = 5, TopValueType = RectSubsetValueType.Length, RightValueType = RectSubsetValueType.Length, BottomValueType = RectSubsetValueType.Length }); expected = LatLonRect.FromPointAndSpan(4.5, 9, 5, 10); AssertExpectedVsActual("rect4", expected, result); }
public void LatLonRect_Miniaturize() { LatLonRect rect = LatLonRect.FromPointAndSpan(2, 4, -10, 18); var mini = rect.Miniaturize(new LatLon(5, 7)); var miniEnumerator = mini.GetEnumerator(); AssertExpectedException <InvalidOperationException>("Forgetting to MoveNext after creating enumerator", () => miniEnumerator.Current.ToString()); AssertExpectedVsActual("moveNext0", true, miniEnumerator.MoveNext()); AssertExpectedVsActual("enumeration0", LatLonRect.FromPointAndSpan(2, 4, -5, 6), miniEnumerator.Current); AssertExpectedVsActual("moveNext1", true, miniEnumerator.MoveNext()); AssertExpectedVsActual("enumeration1", LatLonRect.FromPointAndSpan(-3, 4, -5, 6), miniEnumerator.Current); AssertExpectedVsActual("moveNext2", true, miniEnumerator.MoveNext()); AssertExpectedVsActual("enumeration2", LatLonRect.FromPointAndSpan(2, 10, -5, 6), miniEnumerator.Current); AssertExpectedVsActual("moveNext3", true, miniEnumerator.MoveNext()); AssertExpectedVsActual("enumeration3", LatLonRect.FromPointAndSpan(-3, 10, -5, 6), miniEnumerator.Current); AssertExpectedVsActual("moveNext4", true, miniEnumerator.MoveNext()); AssertExpectedVsActual("enumeration4", LatLonRect.FromPointAndSpan(2, 16, -5, 6), miniEnumerator.Current); AssertExpectedVsActual("moveNext5", true, miniEnumerator.MoveNext()); AssertExpectedVsActual("enumeration5", LatLonRect.FromPointAndSpan(-3, 16, -5, 6), miniEnumerator.Current); AssertExpectedVsActual("moveNext6", false, miniEnumerator.MoveNext()); AssertExpectedException <InvalidOperationException>("Moving past end of enumerator", () => miniEnumerator.Current.ToString()); miniEnumerator.Reset(); AssertExpectedVsActual("moveNext0b", true, miniEnumerator.MoveNext()); AssertExpectedVsActual("enumeration0b", LatLonRect.FromPointAndSpan(2, 4, -5, 6), miniEnumerator.Current); }
public void LatLonRect_InstantiationTests() { LatLonRect rect = new LatLonRect(2, 3, 4, 5); LatLonRect expected = new LatLonRect(new LatLon(2, 3), new LatLon(4, 5)); AssertExpectedVsActual("rect1", expected, rect); rect = LatLonRect.FromPointAndSpan(new LatLon(4, 6), new LatLon(7, 8)); expected = new LatLonRect(11, 14, 4, 6); AssertExpectedVsActual("rect2", expected, rect); rect = LatLonRect.FromNWSE(new LatLon(5, 6), new LatLon(7, 8)); expected = new LatLonRect(5, 8, 7, 6); AssertExpectedVsActual("rect3", expected, rect); rect = LatLonRect.Parse("5, 6, 7, 8"); expected = new LatLonRect(5, 6, 7, 8); AssertExpectedVsActual("rect4", expected, rect); }