public void SetUp() { center = new Point(0, 0); layouter = new CircularCloudLayouter(center); rectangles = new List <Rectangle>(); size = CloudLayouterUtilities.GetRandomSize(5, 100, 5, 100); }
public void PutNextRectangle_IncorrectPlacement() { _layout = GetIncorrectRectanglePlacement(); var result = IsRectanglesIntersect(_layout.Rectangles[0], _layout.Rectangles[1]); result.Should().BeFalse(); }
public void Ctor_CorrectCenter_CreatesObject() { var center = new Point(8, 10); var cloud = new CircularCloudLayouter(center, new SimpleRadialAlgorithm()); Assert.AreEqual(cloud.Center, center); }
public void SetUp() { center = new Point(300, 300); layouter = new CircularCloudLayouter(center); layouter.PutNextRectangle(new Size(20, 10)); layouter.PutNextRectangle(new Size(20, 10)); }
public int[] alwaysPutFirstRectangle_atCenter(int pointX, int pointY) { cloudLayouter = new CircularCloudLayouter(new Point(pointX, pointY)); var rectangle = cloudLayouter.PutNextRectangle(new Size(50, 50)); return(new [] { rectangle.Location.X, rectangle.Location.Y }); }
public void PutNextRectangle(int width, int height) { _layout = new CircularCloudLayouter(new Point(0, 0)); var rectangle = _layout.PutNextRectangle(new Size(width, height)); rectangle.Should().BeEquivalentTo(new Rectangle(0, height, width, height)); }
public void SetUp() { imageWidth = 500; imageHeight = 500; center = new Point(imageWidth / 2, imageHeight / 2); layouter = new CircularCloudLayouter(new Point(center.X, center.Y)); }
public void PutNextRectangle_LocateFirstRectangle_OnSpecifiedByYCenter([ValueSource(nameof(cloudCenters))] Point center) { var circularCloudLayouter = new CircularCloudLayouter(center); rectangles.Add(circularCloudLayouter.PutNextRectangle(new Size(31, 42))); rectangles[0].Y.Should().Be(center.Y - 42 / 2); }
public void SetUp() { var spiral = new Spiral(new SpiralSettings()); center = spiral.GetCenter(); layouter = new CircularCloudLayouter(spiral); }
public void PlaceFirstRectangleToCentre_WhenCentrePointIs(int cx, int cy) { layouter = new CircularCloudLayouter(new Vector(cx, cy)); var rect = layouter.PutNextRectangle(new Size(100, 20)); rect.Centre.Should().Be(layouter.Centre); }
public void Init() { radius = double.MinValue; rectanglesInCloud = new List <Rectangle>(); center = new Point(23, 32); layouter = new CircularCloudLayouter(center); }
public void PutNextRectangle_ShouldPlaceRectanglesTightly_WhenManyRectanglesWithDifferentSize(int rectanglesCount) { var layouter = new CircularCloudLayouter(center); var sizes = new List <Size>(); var rnd = new Random(); for (var i = 0; i < rectanglesCount; i++) { var width = rnd.Next(10); var height = rnd.Next(10); sizes.Add(new Size(width, height)); } rectangles = sizes.Select(s => layouter.PutNextRectangle(s)).ToList(); foreach (var rectangle in rectangles) { foreach (var closerRectangle in RectangleUtils.GetRectanglesThatCloserToPoint( center, rectangle, 1)) { rectangles .Where(r => r != rectangle) .Select(r => RectangleUtils.RectanglesAreIntersected(r, closerRectangle)) .Should() .Contain(true); } } }
public void PutNextRectangle_OnNegativeSize_ShouldThrowArgExcept(int width, int height) { var cloudLayouter = new CircularCloudLayouter(); Action action = () => cloudLayouter.PutNextRectangle(new Size(width, height)); action.Should().Throw <ArgumentException>(); }
public void AlwaysFailedTest() { var imageCenter = new Point(VisualizationImageSize.Width / 2, VisualizationImageSize.Height / 2); var cloudLayouter = new CircularCloudLayouter(imageCenter); var randomizer = TestContext.CurrentContext.Random; var rectangleResults = Enumerable.Range(0, 50) .Select(i => cloudLayouter.PutNextRectangle( new Size(randomizer.Next(50, 100), randomizer.Next(50, 100)))) .Append(new Rectangle(imageCenter.X + 45, imageCenter.Y + 90, 86, 54).AsResult()); var rectangles = TestsHelper.SelectValues(rectangleResults).ToArray(); var intersectingRectangles = TestsHelper.GetAnyPairOfIntersectingRectangles(rectangles); if (intersectingRectangles.HasValue) { wrongVisualizationCloud = new WrongVisualizationCloud(TestsHelper.BackgroundColor, TestsHelper.TagStyleByTagType, intersectingRectangles.Value, rectangles); } Assert.Fail("Should fail to test logging functionality."); }
public void CreateImage(IEnumerable <string> args) { var settings = GetSettings(args); var reader = new FileTextReader(); var words = reader.ReadWords(settings.InputFilePath); var filter = new Filter(); var filteredWords = filter.FilterWords(words); IEnumerable <string> newFilteredWords = null; if (filteredWords.IsSuccess) { newFilteredWords = filteredWords.Value; } var converter = new WordToSizeConverter(); var wordsSizes = converter.ConvertToSizes(newFilteredWords); var visualisator = new Visualisator(); var color = settings.WordsColor; var font = settings.WordsFont; var layouter = new CircularCloudLayouter(); var wordsRectangles = wordsSizes.Select(s => new Tuple <string, Rectangle>(s.Item1, layouter.PutNextRectangle(s.Item2))); var currentBitmap = visualisator.Visualize(wordsRectangles, settings.ImageSize, color, font); var saver = new Saver(); saver.SaveImage(currentBitmap, settings.OutputFilePath); }
public void SetUp() { rectangles = new List <Rectangle>(); cloud = new CircularCloudLayouter { Center = center }; }
public void PutNextRectangle_Throws_WhenNegativeSize() { layouter = new CircularCloudLayouter(new Point(0, 0)); Action action = () => PutNextRectangle(new Size(-10, 0)); action.Should().Throw <ArgumentException>(); }
public void PutNextRectangle_WhenPutEnoughRectangles_RectanglesShouldBeLikeCircle() { pointGenerator = new SpiralGenerator(new Point(500, 500)); layouter = new CircularCloudLayouter(pointGenerator); var random = new Random(0); var areaRectangles = 0; double radius = 0; for (var i = 0; i < 100; i++) { var size = new Size(random.Next(10, 50), random.Next(10, 50)); var rect = layouter.PutNextRectangle(size); areaRectangles += rect.Height * rect.Width; var currentRadius = GetDistance(layouter.Center, rect.GetCenter()); if (currentRadius > radius) { radius = currentRadius; } } var expectedRadius = Math.Sqrt(areaRectangles / Math.PI) * 1.2; radius.Should().BeLessThan(expectedRadius); }
public void SetUp() { layout = new CircularCloudLayouter(); rectangles = new List <Rectangle>(); visualizer = new CircularCloudVisualizer(new ImageSettings(), rectangles); defaultSize = new Size(100, 50); }
public void PutNextRectangle_ShouldPutFirstRectangleOnCenter() { var layouter = new CircularCloudLayouter(config, spiral.Object); var rect = layouter.PutNextRectangle(new Size(10, 10)); rect.ShouldBeEquivalentTo(new Rectangle(-5, -5, 10, 10)); }
public void SetUp() { centerPoint = new Point(50, 50); width = 100; height = 100; cloud = new CircularCloudLayouter(centerPoint, width, height); }
public void PutNextRectangle_ShouldCallSpiralOnce() { var layouter = new CircularCloudLayouter(config, spiral.Object); layouter.PutNextRectangle(new Size(10, 10)); spiral.Verify(s => s.GetNextPoint(), Times.Once); }
public static bool IsCircleFormForCloudLayouter(CircularCloudLayouter cloudLayouter) { throw new NotSupportedException(); //var averageRadius = cloudLayouter.Rectangles.Select(r => (int)cloudLayouter.LauoutCenter.MaxDistTo(r)).Average(); //var maxRadius = cloudLayouter.Rectangles.Select(r => (int)cloudLayouter.LauoutCenter.MaxDistTo(r)).Max(); //return maxRadius <= averageRadius * 2; }
public void PutNextRectangle_ReturnsFailedResult_WhenSpiralGeneratorNull() { var layouter = new CircularCloudLayouter(null); var result = layouter.PutNextRectangle(new Size(2, 2)); result.IsSuccess.Should().BeFalse(); result.Error.Should().Contain("Point generator cannot be null"); }
public void ThrowArgumentException_AfterPuttingRectangle(int width, int height) { var spiral = new Spiral(); var tagCloud = new CircularCloudLayouter(spiral); Action putting = () => tagCloud.PutNextRectangle(new Size(width, height)); putting.Should().Throw <ArgumentException>(); }
public Point PutNextRectangle_ShouldReturnInCenter_WhenPutOnlyOne(Point center, Size size) { var layouter = new CircularCloudLayouter(center, new Size(1000, 1000)); var rectangle = layouter.PutNextRectangle(size); return(rectangle.Location); }
public IEnumerable <(string, Rectangle)> GetWordsRectangles(IEnumerable <Word> words, Size pictureSize) { var circularCloudLayouter = new CircularCloudLayouter(new Point(pictureSize.Width / 2, pictureSize.Height / 2), pictureSize); return(words .Select(w => (w.Value, circularCloudLayouter.PutNextRectangle(w.Size)))); }
public void Init() { radius = double.MinValue; rectanglesInCloud = new List <Rectangle>(); center = new Point(23, 32); spiral = new Spiral(new SpiralSettings(center)); layouter = new CircularCloudLayouter(spiral); }
public void SetUp() { center = new Point(100, 100); layout = new CircularCloudLayouter(center); rectangleSizes = GetRandomSizeSet(); rectangles = new List <Rectangle>(); rectangleCount = 10; }
public void SetUp() { var options = new OptionsStub(500, 500); center = new Point(options.Width / 2, options.Height / 2); layouter = new CircularCloudLayouter(); layouter.SetCenter(new Point(center.X, center.Y)); }