Beispiel #1
0
 public TagCloudContainer(ITextReader[] textReaders, InputPreprocessor preprocessor,
                          StatisticsCounter statCounter, WordLayouter layouter,
                          WordPainter painter, WordDrawer drawer)
 {
     this.textReaders  = textReaders;
     this.preprocessor = preprocessor;
     this.statCounter  = statCounter;
     this.layouter     = layouter;
     this.painter      = painter;
     this.drawer       = drawer;
 }
Beispiel #2
0
        public void GetLayoutedWords_ReturnDifferentSizes_OnDifferentWordFrequency()
        {
            var wordLayouter   = new WordLayouter(new CloudLayouterConfiguration(() => cloudLayouter), sizeChooser);
            var previousHeight = -1;

            foreach (var layoutedWord in wordLayouter.GetLayoutedText(analyzedText).Words
                     .OrderBy(x => x.Position.Height))
            {
                layoutedWord.Position.Height.Should().BeGreaterThan(previousHeight);
                previousHeight = layoutedWord.Position.Height;
            }
        }
        public void TagCloudVisualizer_CreatesFileAfterWork()
        {
            var appSettings = new AppSettings(new ImageSettings(), new PictureBoxImageHolder(),
                                              new Palette(), new Restrictions());

            var textReader = A.Fake <ITextReader>();

            A.CallTo(() => textReader.Formats)
            .Returns(new HashSet <string>()
            {
                "txt"
            });
            A.CallTo(() => textReader.GetAllWords(null))
            .WithAnyArguments()
            .Returns(new[] { "meat", "chicken" });

            var inputPreprocessor = new InputPreprocessor(new[] { new ToLowercasePreprocessor() }, appSettings);

            var statCounter = new StatisticsCounter(new [] { new WordCountCollector() });

            ICloudLayouter GetCloudLayouter() => new CircularCloudLayouter(new Point(0, 0));

            var wordSizeChooser = new WordCountSizeChooser();

            var layouter = new WordLayouter(new CloudLayouterConfiguration(GetCloudLayouter), wordSizeChooser);

            var painter = new DefaultWordPainter(appSettings.Palette);

            var drawer = new DefaultWordDrawer(appSettings);

            var tagCloudContainer = new TagCloudContainer(new[] { textReader }, inputPreprocessor,
                                                          statCounter, layouter, painter, drawer);

            var filepath = GetTempFilePathWithExtension(".png");

            var saveFileAction = new SaveFileStub(appSettings, filepath);

            var graphicalVisualizer = new GraphicalVisualizer(new [] { saveFileAction }, appSettings, tagCloudContainer);

            appSettings.CurrentInterface = graphicalVisualizer;
            appSettings.CurrentFile      = "test.txt";

            saveFileAction.Perform();
            File.Exists(filepath).Should().BeTrue();
            File.Delete(filepath);
        }