public void Constructor_WithCenterAndGenerator_DoesNotThrowException()
        {
            center          = new Point(5, 5);
            pointsGenerator = new SpiralPointsGenerator(DistanceBetweenPoints, AngleIncrement);

            Action action = () => new CircularCloudLayouter(center, pointsGenerator);

            action.Should().NotThrow();
        }
        public void Rectangles_AfterLayouterCreating_IsEmptyList()
        {
            center          = new Point(5, 5);
            pointsGenerator = new SpiralPointsGenerator(DistanceBetweenPoints, AngleIncrement);
            layouter        = new CircularCloudLayouter(center, pointsGenerator);

            var rectangles = layouter.Rectangles;

            rectangles.Should().BeEmpty();
        }
        public void PutNextRectangle_UsesPointsGenerator()
        {
            center          = new Point(5, 5);
            pointsGenerator = A.Fake <IPointsGenerator>();
            layouter        = new CircularCloudLayouter(center, pointsGenerator);

            layouter.PutNextRectangle(new Size(10, 10));

            A.CallTo(() => pointsGenerator.GetPoints()).MustHaveHappened();
        }
        public void Rectangles_WithRandomSize_DoNotIntersect(int rectanglesAmount)
        {
            center          = new Point(5, 5);
            pointsGenerator = new SpiralPointsGenerator(DistanceBetweenPoints, AngleIncrement);
            layouter        = new CircularCloudLayouter(center, pointsGenerator);

            AddRandomRectangles(rectanglesAmount);

            CheckIntersection(layouter.Rectangles);
        }
        public void PutNextRectangleMethod_OnCorrectSize_DoesNotThrowException()
        {
            center          = new Point(5, 5);
            pointsGenerator = new SpiralPointsGenerator(DistanceBetweenPoints, AngleIncrement);
            layouter        = new CircularCloudLayouter(center, pointsGenerator);
            rectangleSize   = new Size(10, 10);

            Action action = () => layouter.PutNextRectangle(rectangleSize);

            action.Should().NotThrow();
        }
        public void PutNextRectangle_OnInvalidSize_ThrowsArgumentException(int width, int height)
        {
            center          = new Point(5, 5);
            pointsGenerator = new SpiralPointsGenerator(DistanceBetweenPoints, AngleIncrement);
            layouter        = new CircularCloudLayouter(center, pointsGenerator);
            var invalidRectangleSize = new Size(width, height);

            var result = layouter.PutNextRectangle(invalidRectangleSize);

            result.IsSuccess.Should().BeFalse();
        }
        public void Rectangles_AfterAdding_HasAllRectanglesInList(int rectangleAmount)
        {
            center          = new Point(5, 5);
            pointsGenerator = new SpiralPointsGenerator(DistanceBetweenPoints, AngleIncrement);
            layouter        = new CircularCloudLayouter(center, pointsGenerator);
            rectangleSize   = new Size(10, 10);

            AddRectangles(rectangleAmount);
            var rectanglesAmount = layouter.Rectangles.Count;

            rectanglesAmount.Should().Be(rectangleAmount);
        }
        public void PutNextRectangle_UsesPointsGeneratorOnce()
        {
            center          = new Point(5, 5);
            pointsGenerator = A.Fake <IPointsGenerator>();
            A.CallTo(() => pointsGenerator.GetPoints()).Returns(new[] { new Point(), new Point(100, 100) });
            layouter = new CircularCloudLayouter(center, pointsGenerator);

            layouter.PutNextRectangle(new Size(10, 10));
            layouter.PutNextRectangle(new Size(10, 10));

            A.CallTo(() => pointsGenerator.GetPoints()).MustHaveHappened(Repeated.Exactly.Once);
        }
        public void PutNextRectangle_AfterFirstAdding_ReturnsRectangleWithCenterInLayoutCenter()
        {
            center          = new Point(5, 5);
            pointsGenerator = new SpiralPointsGenerator(DistanceBetweenPoints, AngleIncrement);
            layouter        = new CircularCloudLayouter(center, pointsGenerator);
            rectangleSize   = new Size(10, 10);

            var firstRectangle       = layouter.PutNextRectangle(rectangleSize);
            var firstRectangleCenter = firstRectangle.GetValueOrThrow().GetCenter();

            firstRectangleCenter.Should().Be(center);
        }
        public void PutNextRectangle_UsesPointsFromPointsGenerator()
        {
            var points = new[] { new Point(), new Point(2, 0), new Point(0, 2) };

            center          = new Point();
            pointsGenerator = A.Fake <IPointsGenerator>();
            A.CallTo(() => pointsGenerator.GetPoints()).Returns(points);
            layouter = new CircularCloudLayouter(center, pointsGenerator);

            layouter.PutNextRectangle(new Size(1, 1));
            layouter.PutNextRectangle(new Size(1, 1));
            layouter.PutNextRectangle(new Size(1, 1));

            layouter.Rectangles.Select(rectangle => rectangle.GetCenter()).Should().BeEquivalentTo(points);
        }
Esempio n. 11
0
        public RedundantConstraintsRemover(IPointsGenerator pointsGenerator, IBenchmark benchmark, ExperimentParameters experimentParameters)
        {
            _domainSpaceSampler             = pointsGenerator;
            _benchmark                      = benchmark;
            _maxNumberOfPointsInSingleArray = experimentParameters.MaxNumberOfPointsInSingleArray;

            var numberOfDimensions = benchmark.Domains.Length;
            var domains            = benchmark.Domains;
            var domainSamplingStep = experimentParameters.DomainSamplingStep;
            var temp = 1.0;

            for (var i = 0; i < numberOfDimensions; i++)
            {
                temp *= (domains[i].UpperLimit - domains[i].LowerLimit) / domainSamplingStep;
            }

            _numberOfPointsToGenerate = (long)temp;
        }
        public void Rectangles_OnIncreasingSize_HaveDensityMoreThanSeventyPercent(int rectanglesAmount)
        {
            const double expectedDensity = 0.7;

            center          = new Point(5, 5);
            pointsGenerator = new SpiralPointsGenerator(DistanceBetweenPoints, AngleIncrement);
            layouter        = new CircularCloudLayouter(center, pointsGenerator);

            for (var i = rectanglesAmount; i > 0; i--)
            {
                layouter.PutNextRectangle(new Size(i * 3, i));
            }
            var radius           = GetDistanceToFatherPoint(layouter.Rectangles);
            var circleSquare     = Math.PI * radius * radius;
            var rectanglesSquare = layouter.Rectangles.Sum(rectangle => rectangle.Width * rectangle.Height);
            var density          = rectanglesSquare / circleSquare;

            density.Should().BeGreaterOrEqualTo(expectedDensity);
        }
Esempio n. 13
0
 public CircularCloudLayouter(Point center, bool compression, IPointsGenerator pointGen) : base(center)
 {
     Center          = center;
     PointsGenerator = pointGen;
     compressionFlag = compression;
 }
Esempio n. 14
0
 public CircularCloudLayouter(IPointsGenerator pointsGenerator)
 {
     this.pointsGenerator = pointsGenerator;
     Rectangles           = new List <Rectangle>();
 }
Esempio n. 15
0
 public CircularCloudLayouter(Point center, IPointsGenerator pointsGenerator)
 {
     this.center      = center;
     pointsEnumerator = pointsGenerator.GetPoints().GetEnumerator();
 }