-
Notifications
You must be signed in to change notification settings - Fork 307
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
base: master
Are you sure you want to change the base?
Леонид Рыбин #251
Conversation
|
||
public void InitSpiral(double radius, double angleOffset) | ||
{ | ||
pointsGenerator = new CircularSpiralPointGenerator(radius, angleOffset, center); |
This comment was marked as resolved.
This comment was marked as resolved.
Sorry, something went wrong.
{ | ||
private Point center; | ||
private List<Rectangle> rectangles; | ||
private CircularSpiralPointGenerator pointsGenerator; |
This comment was marked as resolved.
This comment was marked as resolved.
Sorry, something went wrong.
return rectangle; | ||
} | ||
|
||
private static Rectangle CreateRectangleWithCenter(Point center, Size rectangleSize) |
This comment was marked as resolved.
This comment was marked as resolved.
Sorry, something went wrong.
|
||
public Point GetPoint() | ||
{ | ||
return TransferPolarToEuclideanPoint(); |
This comment was marked as resolved.
This comment was marked as resolved.
Sorry, something went wrong.
private double angle = 0; | ||
private Point center; | ||
|
||
public CircularSpiralPointGenerator(double radius, double angleOffset, Point center) |
This comment was marked as resolved.
This comment was marked as resolved.
Sorry, something went wrong.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
В CircularSpiralPointGenerator
выполняется построение спирали и получение точек из неё, а в CircularCloudLayouter
идёт работа с прямоугольниками и проверка того что они не пересекаются. Логично вынести этот класс, иначе CircularCloudLayouter
будет перегружен.
cs/TagsCloudVisualization/Program.cs
Outdated
.Select(_ => cloudLayouter.PutNextRectangle(new Size( | ||
random.Next(MinRectangleSize, MaxRectangleSize), | ||
random.Next(MinRectangleSize, MaxRectangleSize)))) | ||
.ToArray(); |
This comment was marked as resolved.
This comment was marked as resolved.
Sorry, something went wrong.
} | ||
|
||
[TestCase(5, 90)] | ||
public void CircularSpiralPointGenerator_WhenCorrectArgs_NotThrowArgumentException(double radius, double angleOffset) |
This comment was marked as resolved.
This comment was marked as resolved.
Sorry, something went wrong.
} | ||
|
||
[TestCaseSource(nameof(CorrectPointsCaseData))] | ||
public Point GetPoint_ReturnCorrectPoint(int pointNumber) |
This comment was marked as resolved.
This comment was marked as resolved.
Sorry, something went wrong.
private Point center; | ||
|
||
[SetUp] | ||
public void Setup() |
This comment was marked as resolved.
This comment was marked as resolved.
Sorry, something went wrong.
new TestCaseData(6).Returns(new Point(-3, 3)) | ||
}; | ||
|
||
} |
This comment was marked as resolved.
This comment was marked as resolved.
Sorry, something went wrong.
Action act = () => circularCloudLayouter.PutNextRectangle(new Size(width, height)); | ||
act.Should().Throw<ArgumentException>(); | ||
} | ||
} |
This comment was marked as resolved.
This comment was marked as resolved.
Sorry, something went wrong.
public readonly List<Rectangle> rectangles; | ||
private readonly CircularSpiralPointGenerator pointsGenerator; | ||
|
||
public CircularCloudLayouter(Point center) |
This comment was marked as resolved.
This comment was marked as resolved.
Sorry, something went wrong.
cs/TagsCloudVisualization/Program.cs
Outdated
{ | ||
var center = new Point(ImageWidth / 2, ImageHeight / 2); | ||
var cloudLayouter = new CircularCloudLayouter(center); | ||
var random = new Random(); |
This comment was marked as resolved.
This comment was marked as resolved.
Sorry, something went wrong.
cs/TagsCloudVisualization/Program.cs
Outdated
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.
This comment was marked as resolved.
Sorry, something went wrong.
[TestFixture] | ||
public class CircularSpiralPointGeneratorTests | ||
{ | ||
private CircularSpiralPointGenerator spiral; |
This comment was marked as resolved.
This comment was marked as resolved.
Sorry, something went wrong.
spiral = new CircularSpiralPointGenerator(3, 100, DefaultCenter); | ||
Point[] actualPoins = new Point[6]; | ||
int pointNumber = 6; | ||
Point[] correctPoints = |
This comment was marked as resolved.
This comment was marked as resolved.
Sorry, something went wrong.
There was a problem hiding this comment.
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.
This comment was marked as resolved.
Sorry, something went wrong.
}; | ||
var pointNumber = correctPoints.Length; | ||
|
||
for (var i = 0; i < pointNumber; i++) |
This comment was marked as resolved.
This comment was marked as resolved.
Sorry, something went wrong.
{ | ||
private static readonly Point DefaultCenter = new(0, 0); | ||
private readonly double defaultRadius = 1; | ||
private readonly double defaultAngleOffset = 10; |
There was a problem hiding this comment.
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.
This comment was marked as resolved.
Sorry, something went wrong.
[TestFixture] | ||
public class CircularCloudLayouterTests | ||
{ | ||
private CircularCloudLayouter circularCloudLayouter; |
This comment was marked as resolved.
This comment was marked as resolved.
Sorry, something went wrong.
public void PutNextRectangle_ShouldReturnRectanglesWithoutIntersections() | ||
{ | ||
var rectanglesNumber = 100; | ||
circularCloudLayouter = new CircularCloudLayouter(OptimalCenter, OptimalRadius, OptimalAngleOffset); |
There was a problem hiding this comment.
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.
This comment was marked as resolved.
Sorry, something went wrong.
public void GetPoint_ReturnCorrectPoints() | ||
{ | ||
var spiral = new CircularSpiralPointGenerator(3, 100, DefaultCenter); | ||
var actualPoins = new Point[6]; |
There was a problem hiding this comment.
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); |
There was a problem hiding this comment.
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
можно будет избавиться.
No description provided.