public void SegmentCollectionMergeSegmentsTest() { // merge using segments SegmentCollection collection = new SegmentCollection(_raster.Object); Segment segment = collection.GetSegment(0, 0); Int32 count = collection.Count; for (Int32 rowIndex = 0; rowIndex < _raster.Object.NumberOfRows; rowIndex++) { for (Int32 columnIndex = 0; columnIndex < _raster.Object.NumberOfColumns; columnIndex++) { Segment otherSegment = collection.GetSegment(rowIndex, columnIndex); collection.MergeSegments(segment, otherSegment); Assert.IsFalse(segment != otherSegment && collection.Contains(segment) && collection.Contains(otherSegment)); segment = collection.GetSegment(rowIndex, columnIndex); Assert.AreEqual(count, collection.Count); count--; } } Assert.AreEqual(_raster.Object.NumberOfColumns * _raster.Object.NumberOfRows, segment.Count); // merge using segment and indices collection = new SegmentCollection(_raster.Object); segment = collection.GetSegment(0, 0); count = collection.Count; for (Int32 rowIndex = 0; rowIndex < _raster.Object.NumberOfRows; rowIndex++) { for (Int32 columnIndex = 0; columnIndex < _raster.Object.NumberOfColumns; columnIndex++) { collection.MergeSegments(segment, rowIndex, columnIndex); Segment otherSegment = collection.GetSegment(rowIndex, columnIndex); Assert.AreEqual(segment, otherSegment); Assert.AreEqual(count, collection.Count); count--; } } Assert.AreEqual(_raster.Object.NumberOfColumns * _raster.Object.NumberOfRows, segment.Count); // merge using indices collection = new SegmentCollection(_raster.Object); segment = collection.GetSegment(0, 0); count = collection.Count; for (Int32 rowIndex = 0; rowIndex < _raster.Object.NumberOfRows; rowIndex++) { for (Int32 columnIndex = 0; columnIndex < _raster.Object.NumberOfColumns; columnIndex++) { collection.MergeSegments(0, 0, rowIndex, columnIndex); Segment otherSegment = collection.GetSegment(rowIndex, columnIndex); Assert.AreEqual(segment, otherSegment); Assert.AreEqual(count, collection.Count); count--; } } Assert.AreEqual(_raster.Object.NumberOfColumns * _raster.Object.NumberOfRows, segment.Count); }