コード例 #1
0
ファイル: TagCloudForm.cs プロジェクト: Rozentor/fp
        private void DrawButton_Click(object sender, EventArgs e)
        {
            Picture.Image?.Dispose();

            if (options.PathToWords == null)
            {
                loadTextFileToolStripMenuItem.PerformClick();
            }
            if (options.PathToWords == null)
            {
                return;
            }

            if (options.PathToPicture == null)
            {
                saveImageToolStripMenuItem.PerformClick();
            }
            if (options.PathToPicture == null)
            {
                return;
            }

            TagCloudProgram
            .Execute(options)
            .OnFail(er =>
            {
                Output.Text =
                    "ERROR:\n " +
                    Environment.NewLine +
                    Environment.NewLine +
                    er;
                Picture.Image = new Bitmap(1, 1);
            })
            .Then(x => Picture.Image = Image.FromFile(options.PathToPicture));
        }
コード例 #2
0
ファイル: Program.cs プロジェクト: Rozentor/di
 private static void Run(Options options)
 {
     try
     {
         TagCloudProgram.Execute(options);
         System.Console.WriteLine($"Picture saved to {options.PathToPicture}");
     }
     catch (Exception e)
     {
         System.Console.WriteLine(e.Message);
     }
 }
コード例 #3
0
ファイル: TagCloudProgram_Should.cs プロジェクト: Rozentor/fp
        public void CreatePicture()
        {
            using (var file = File.CreateText("text.txt"))
                file.WriteLine("some text here 123 just for test");
            var options = Options.Standart;

            options.PathToPicture = "result.png";
            options.PathToWords   = "text.txt";

            TagCloudProgram.Execute(Options.Standart);

            File.Exists("result.png").Should().BeTrue();
            File.Delete("result.png");
            File.Delete("text.txt");
        }
コード例 #4
0
ファイル: TagCloudProgram_Should.cs プロジェクト: Rozentor/fp
        public void ChangeImageSize()
        {
            using (var file = File.CreateText("text.txt"))
                file.WriteLine("some text here 123 just for test");
            var options = Options.Standart;

            options.Size          = "100x100";
            options.PathToPicture = "result.png";
            options.PathToWords   = "text.txt";

            TagCloudProgram.Execute(Options.Standart);

            using (var image = Image.FromFile("result.png"))
                image.Size.Should().Be(new Size(100, 100));
            File.Delete("result.png");
            File.Delete("text.txt");
        }
コード例 #5
0
ファイル: TagCloudForm.cs プロジェクト: Rozentor/di
        private void DrawButton_Click(object sender, EventArgs e)
        {
            Picture.Image?.Dispose();

            if (options.PathToWords == null)
            {
                loadTextFileToolStripMenuItem.PerformClick();
            }
            if (options.PathToWords == null)
            {
                return;
            }

            if (options.PathToPicture == null)
            {
                saveImageToolStripMenuItem.PerformClick();
            }
            if (options.PathToPicture == null)
            {
                return;
            }

            try
            {
                TagCloudProgram.Execute(options);
                Picture.Image = Image.FromFile(options.PathToPicture);
            }
            catch (Exception exception)
            {
                while (exception.InnerException != null)
                {
                    exception = exception.InnerException;
                }
                Output.Text = "ERROR: " + exception.Message;
            }
        }
コード例 #6
0
ファイル: TagCloudProgram_Should.cs プロジェクト: Rozentor/fp
        public void ThrowArgumentException_WhenFilesDoesNotExists()
        {
            var result = TagCloudProgram.Execute(Options.Standart);

            result.Error.Should().NotBeNullOrEmpty();
        }
コード例 #7
0
ファイル: TagCloudProgram_Should.cs プロジェクト: Rozentor/fp
        public void ThrowArgumentException_WhenOptionsAreNull()
        {
            var result = TagCloudProgram.Execute(null);

            result.Error.Should().NotBeNullOrEmpty();
        }
コード例 #8
0
        public void ThrowArgumentException_WhenFilesDoesNotExists()
        {
            Action execute = () => TagCloudProgram.Execute(Options.Standart);

            execute.Should().Throw <ArgumentException>();
        }
コード例 #9
0
        public void ThrowArgumentException_WhenOptionsAreNull()
        {
            Action execute = () => TagCloudProgram.Execute(null);

            execute.Should().Throw <ArgumentException>();
        }
コード例 #10
0
ファイル: Program.cs プロジェクト: Rozentor/fp
 private static void Run(Options options)
 {
     TagCloudProgram.Execute(options)
     .OnFail(System.Console.WriteLine)
     .Then(x => System.Console.WriteLine($"Picture saved to {options.PathToPicture}"));
 }