public void Should_Return_Related_Source_Area(int x, int y, byte option)
        {
            var srcArea1  = Area2D.Create(0, 0, 3, 3);
            var srcArea2  = Area2D.Create(3, 3, 3, 3);
            var srcArea3  = Area2D.Create(6, 6, 3, 3);
            var emptyArea = Area2D.Empty;

            var areas = new[]
            {
                new Tuple <Area2D, Area2D>(Area2D.Create(0, 0, 5, 5), srcArea1),
                new Tuple <Area2D, Area2D>(Area2D.Create(4, 4, 6, 6), srcArea2),
                new Tuple <Area2D, Area2D>(Area2D.Create(-3, -3, 6, 6), srcArea3)
            };
            var areaMap = new Area2DMap(areas, emptyArea);

            var result = areaMap.GetPointSourceArea(new Point(x, y));

            if (option == 1)
            {
                result.IsSameAs(srcArea1).ShouldBeTrue();
            }
            else if (option == 2)
            {
                result.IsSameAs(srcArea2).ShouldBeTrue();
            }
            else if (option == 3)
            {
                result.IsSameAs(srcArea3).ShouldBeTrue();
            }
        }
예제 #2
0
        public void DestPoints_Of_Result_Mapping_Should_Point_To_The_Same_Area_As_The_Initialization_Mapping()
        {
            _mapBuilder.InitNewMap(_initialMapping);
            var newMapping = _mapBuilder.Build();

            foreach (var destPoint in newMapping.DestPoints)
            {
                var newMappingDestPointSourceArea  = newMapping.GetPointSourceArea(destPoint);
                var initMappingDestPointSourceArea = _initialMapping.GetPointSourceArea(destPoint);
                newMappingDestPointSourceArea.IsSameAs(initMappingDestPointSourceArea).ShouldBeTrue();
            }
        }
        public void Should_Return_Empty_Area_When_Dest_Not_Contain_Point()
        {
            var srcArea   = Area2D.Create(0, 0, 3, 3);
            var emptyArea = Area2D.Empty;

            var areas = new[]
            {
                new Tuple <Area2D, Area2D>(Area2D.Create(0, 0, 5, 5), srcArea),
                new Tuple <Area2D, Area2D>(Area2D.Create(4, 4, 6, 6), srcArea),
                new Tuple <Area2D, Area2D>(Area2D.Create(-3, -3, 6, 6), srcArea)
            };
            var areaMap = new Area2DMap(areas, emptyArea);

            var result = areaMap.GetPointSourceArea(new Point(-10, 0));

            result.IsEmpty.ShouldBeTrue();
        }
        public void Should_Return_Source_That_Relates_To_Last_Dest_When_Point_Belongs_To_Several_Dest_Areas()
        {
            var srcArea1  = Area2D.Create(0, 0, 3, 3);
            var srcArea2  = Area2D.Create(3, 3, 3, 3);
            var srcArea3  = Area2D.Create(6, 6, 3, 3);
            var emptyArea = Area2D.Empty;

            var areas = new[]
            {
                new Tuple <Area2D, Area2D>(Area2D.Create(0, 0, 5, 5), srcArea1),
                new Tuple <Area2D, Area2D>(Area2D.Create(4, 4, 6, 6), srcArea2),
                new Tuple <Area2D, Area2D>(Area2D.Create(-3, -3, 6, 6), srcArea3)
            };
            var areaMap = new Area2DMap(areas, emptyArea);

            var result = areaMap.GetPointSourceArea(new Point(4, 4));

            result.IsSameAs(srcArea2).ShouldBeTrue();
        }