Esempio n. 1
0
        public void OffsetToCentreMustMoveToCentre()
        {
            var subject = new Area(new Point(12.34, 45.56), new Point(67.67, 89.90));
            Area result = subject.OffsetToMakeTopLeftCentre();

            Assert.AreEqual(result.Centre, subject.TopLeft);
        }
Esempio n. 2
0
        public void OffsetToCentreMustNotReassignReference()
        {
            var subject = new Area(new Point(12.34, 45.56), new Point(67.67, 89.90));
            Area result = subject.OffsetToMakeTopLeftCentre();

            Assert.AreNotEqual(subject.TopLeft, result.TopLeft);
        }
Esempio n. 3
0
        private Area GetProposedAreaSemiCircle(double actualWidth, double actualHeight, Point centre, Func<Area, ProximityTestResult> overlapsWithOthers)
        {
            // A angle of 0 degrees in this context is moving directly to the right
            this.angle = this.dimensions.CalculateNextAvailableAngle();
            Area proposedArea;
            var calc = new CircleCalculator(centre, this.angle);
            double radius = 250;
            ProximityTestResult proximityResult = null;

            do
            {
                if (proximityResult != null && proximityResult.Proximity == Proximity.VeryClose)
                {
                    radius += LayoutConstants.MinimumDistanceBetweenObjects / 2;
                }
                else
                {
                    radius += LayoutConstants.MinimumDistanceBetweenObjects;
                }

                proposedArea = new Area(calc.CalculatePointOnCircle(radius), actualWidth, actualHeight);
                proposedArea = proposedArea.OffsetToMakeTopLeftCentre();
                proximityResult = overlapsWithOthers(proposedArea);
            }
            while (proximityResult.Proximity == Proximity.Overlapping || proximityResult.Proximity == Proximity.VeryClose);

            return proposedArea;
        }