Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Леонид Рыбин #251

Open
wants to merge 13 commits into
base: master
Choose a base branch
from

Conversation

JavaScriptHaters
Copy link

No description provided.


public void InitSpiral(double radius, double angleOffset)
{
pointsGenerator = new CircularSpiralPointGenerator(radius, angleOffset, center);

This comment was marked as resolved.

{
private Point center;
private List<Rectangle> rectangles;
private CircularSpiralPointGenerator pointsGenerator;

This comment was marked as resolved.

return rectangle;
}

private static Rectangle CreateRectangleWithCenter(Point center, Size rectangleSize)

This comment was marked as resolved.


public Point GetPoint()
{
return TransferPolarToEuclideanPoint();

This comment was marked as resolved.

private double angle = 0;
private Point center;

public CircularSpiralPointGenerator(double radius, double angleOffset, Point center)

This comment was marked as resolved.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

В CircularSpiralPointGenerator выполняется построение спирали и получение точек из неё, а в CircularCloudLayouter идёт работа с прямоугольниками и проверка того что они не пересекаются. Логично вынести этот класс, иначе CircularCloudLayouter будет перегружен.

.Select(_ => cloudLayouter.PutNextRectangle(new Size(
random.Next(MinRectangleSize, MaxRectangleSize),
random.Next(MinRectangleSize, MaxRectangleSize))))
.ToArray();

This comment was marked as resolved.

}

[TestCase(5, 90)]
public void CircularSpiralPointGenerator_WhenCorrectArgs_NotThrowArgumentException(double radius, double angleOffset)

This comment was marked as resolved.

}

[TestCaseSource(nameof(CorrectPointsCaseData))]
public Point GetPoint_ReturnCorrectPoint(int pointNumber)

This comment was marked as resolved.

private Point center;

[SetUp]
public void Setup()

This comment was marked as resolved.

new TestCaseData(6).Returns(new Point(-3, 3))
};

}

This comment was marked as resolved.

Action act = () => circularCloudLayouter.PutNextRectangle(new Size(width, height));
act.Should().Throw<ArgumentException>();
}
}

This comment was marked as resolved.

public readonly List<Rectangle> rectangles;
private readonly CircularSpiralPointGenerator pointsGenerator;

public CircularCloudLayouter(Point center)

This comment was marked as resolved.

{
var center = new Point(ImageWidth / 2, ImageHeight / 2);
var cloudLayouter = new CircularCloudLayouter(center);
var random = new Random();

This comment was marked as resolved.

var center = new Point(ImageWidth / 2, ImageHeight / 2);
var cloudLayouter = new CircularCloudLayouter(center);
var random = new Random();
var rectangles = new Rectangle[RectanglesNumber];

This comment was marked as resolved.

[TestFixture]
public class CircularSpiralPointGeneratorTests
{
private CircularSpiralPointGenerator spiral;

This comment was marked as resolved.

spiral = new CircularSpiralPointGenerator(3, 100, DefaultCenter);
Point[] actualPoins = new Point[6];
int pointNumber = 6;
Point[] correctPoints =

This comment was marked as resolved.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

var correctPoints = new[] { ... };

public void GetPoint_ReturnCorrectPoints()
{
spiral = new CircularSpiralPointGenerator(3, 100, DefaultCenter);
Point[] actualPoins = new Point[6];

This comment was marked as resolved.

};
var pointNumber = correctPoints.Length;

for (var i = 0; i < pointNumber; i++)

This comment was marked as resolved.

{
private static readonly Point DefaultCenter = new(0, 0);
private readonly double defaultRadius = 1;
private readonly double defaultAngleOffset = 10;

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Эти 2 поля не используются - убрать.

[Test]
public void CircularCloudLayouter_WhenCorrectArgs_NotThrowArgumentException()
{
Action act = () => new CircularCloudLayouter(new Point(5, 15));

This comment was marked as resolved.

[TestFixture]
public class CircularCloudLayouterTests
{
private CircularCloudLayouter circularCloudLayouter;

This comment was marked as resolved.

public void PutNextRectangle_ShouldReturnRectanglesWithoutIntersections()
{
var rectanglesNumber = 100;
circularCloudLayouter = new CircularCloudLayouter(OptimalCenter, OptimalRadius, OptimalAngleOffset);
Copy link

@SlavikGh0st SlavikGh0st Nov 18, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

У нас оптимальный лэйаутер - это тот, который new CircularCloudLayouter(OptimalCenter) - надо его тестировать.

IsIntersectionBetweenRectangles(rectangles).Should().BeFalse();
}

private bool IsIntersectionBetweenRectangles(Rectangle[] rectangles)

This comment was marked as resolved.

public void GetPoint_ReturnCorrectPoints()
{
var spiral = new CircularSpiralPointGenerator(3, 100, DefaultCenter);
var actualPoins = new Point[6];

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Эта то строка теперь не нужна)

public void TagsCloud_ShouldBeShapeOfCircularCloud_WhenOptimalParameters()
{
var rectanglesNumber = 1000;
var circularCloudLayouter = new CircularCloudLayouter(OptimalCenter, OptimalRadius, OptimalAngleOffset);

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Так везде надо new CircularCloudLayouter(OptimalCenter) сделать, я просто не стал в каждом месте писать.
И тогда от полей OptimalRadius, OptimalAngleOffset можно будет избавиться.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants