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)); }
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); } }
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"); }
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"); }
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; } }
public void ThrowArgumentException_WhenFilesDoesNotExists() { var result = TagCloudProgram.Execute(Options.Standart); result.Error.Should().NotBeNullOrEmpty(); }
public void ThrowArgumentException_WhenOptionsAreNull() { var result = TagCloudProgram.Execute(null); result.Error.Should().NotBeNullOrEmpty(); }
public void ThrowArgumentException_WhenFilesDoesNotExists() { Action execute = () => TagCloudProgram.Execute(Options.Standart); execute.Should().Throw <ArgumentException>(); }
public void ThrowArgumentException_WhenOptionsAreNull() { Action execute = () => TagCloudProgram.Execute(null); execute.Should().Throw <ArgumentException>(); }
private static void Run(Options options) { TagCloudProgram.Execute(options) .OnFail(System.Console.WriteLine) .Then(x => System.Console.WriteLine($"Picture saved to {options.PathToPicture}")); }