private Test2DPolygonDefinition Helper_Get2DRectangleEdgePolygon_Correct() { Test2DPolygonDefinition result = new Test2DPolygonDefinition(3, 3); result.Points = new byte[] { 1, 0, 1, 0, 0, 0, 1, 0, 1, }; return(result); }
private Test2DPolygonDefinition Helper_Get2DCrossPolygon_Correct() { Test2DPolygonDefinition result = new Test2DPolygonDefinition(5, 3); result.Points = new byte[] { 0, 0, 1, 0, 0, 0, 1, 1, 1, 0, 0, 0, 1, 0, 0, }; return(result); }
private Test2DPolygonDefinition Helper_Get2DRectanglePolygon() { Test2DPolygonDefinition result = new Test2DPolygonDefinition(5, 5); result.Points = new byte[] { 0, 0, 0, 0, 0, 0, 1, 1, 1, 0, 0, 1, 1, 1, 0, 0, 1, 1, 1, 0, 0, 0, 0, 0, 0, }; return(result); }
private int[] Helper_Create_PixelsOfRegionFromParam(Test2DPolygonDefinition testPolygon, Trace.RegionManipulator rm) { List <int> result = new List <int>(); for (int i = 0; i < testPolygon.Points.Length; i++) { if (testPolygon.Points[i] == 1) { result.Add(i); } } return(result.ToArray()); }
public void Test_PolygonRectangle_AtEdgeTest() { // arrange Test2DPolygonDefinition testPolygon = Helper_Get2DRectangleEdgePolygon(); Trace.RegionManipulator rm = Helper_Create_RegionManipulator(testPolygon); Trace.RegionVO region = Helper_Create_RegionFromParam(testPolygon, rm); int[] correctPixelsIndex = Helper_Create_PixelsOfRegionFromParam(Helper_Get2DRectangleEdgePolygon_Correct(), rm); // act int [] newPixelsIndex = new RegionToPolygon_Test().EdgeCrawler(region, rm).ToArray(); // assert bool resultCompare = Helper_ComparePixelRegions(newPixelsIndex, correctPixelsIndex); Assert.IsTrue(resultCompare); }
private Trace.RegionManipulator Helper_Create_RegionManipulator(Test2DPolygonDefinition testPolygon) { CanvasPixel canvas = new CanvasPixel(testPolygon.Width, testPolygon.Height); return(new Trace.RegionManipulator(canvas, canvas)); }
private Trace.RegionVO Helper_Create_RegionFromParam(Test2DPolygonDefinition testPolygon, Trace.RegionManipulator rm) { Trace.RegionVO region = new Trace.RegionVO(new Pixel()); region.Pixels = Helper_Create_PixelsOfRegionFromParam(testPolygon, rm); return(region); }