예제 #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;
 }
예제 #2
0
        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);
        }
예제 #3
0
 private void OnEnable()
 {
     InputPreprocessor.AddPreprocessor(PreprocessInput);
 }
예제 #4
0
 private void OnDisable()
 {
     InputPreprocessor.RemovePreprocessor(PreprocessInput);
 }