public Result <List <TagRectangle> > GetRectangles(Graphics graphics, ImageSettings imageSettings, string path = null) { layouter.Clear(); var tagCollection = tagCollectionFactory.Create(imageSettings, path); if (!tagCollection.IsSuccess) { return(Result.Fail <List <TagRectangle> >(tagCollection.Error)); } var center = new Point(imageSettings.Width / 2, imageSettings.Height / 2); var rectangles = Result.Of(() => tagCollection.Value .Select(t => new TagRectangle( t, layouter.PutNextRectangle(GetWordSize(t, graphics), center))) .ToList()) .Then(list => { if (!list.Any(r => IsRectangleInPolygon(r.Area, imageSettings.Width, imageSettings.Height))) { throw new ArgumentException("Облако не помещается в изображение"); } return(list); }); return(rectangles); }
public void WordsToTagsParser_Should_NotThrows_When_Parse() { Action action = () => tagCollectionFactory.Create(imageSettings, pathToReadWords); action.Should().NotThrow(); }