Example #1
0
        public void Demo1()
        {
            var textPath       = Path.Combine(Directory.GetCurrentDirectory(), "..", "..", "..", "text.txt");
            var text           = Reader.ReadFile(textPath);
            var preparer       = new Preparer(new[] { "что", "если", "это", "как" }, word => word.Length > 3);
            var prepared       = preparer.CreateWordFreqList(text, 200);
            var algorithm      = AlgorithmFabric.Create(AlgorithmType.Exponential);
            var graphicalWords = algorithm(prepared);
            var painter        = new Painter(FontFamily.GenericSansSerif,
                                             new RandomChoicePalette(new[]
                                                                     { Color.Peru, Color.Pink, Color.Green, Color.Red, Color.Blue, Color.Black }, Color.White),
                                             size => new CircularLayouter(size));

            var img = painter.Paint(graphicalWords);

            var path = Path.Combine(Directory.GetCurrentDirectory(), "demo1.jpg");

            Saver.SaveImage(img, path);

            Console.WriteLine($"Изображение сохранено в {path}");
        }
Example #2
0
        public void ReadFile_ShouldThrow_NotExistingFile()
        {
            var func = new Action(() => Reader.ReadFile("absolutely not a file path"));

            func.Should().Throw <FileNotFoundException>();
        }
Example #3
0
        public void ReadFile_ShouldReturnPlainText_ExistingFile()
        {
            var path = Path.Combine(Environment.CurrentDirectory, "../../..", "testFile.txt");

            Reader.ReadFile(path).Should().Be("abc\r\nabc\r\nefg");
        }