mirror of
https://github.com/eliasstepanik/OSCADSharpDotnet7.git
synced 2026-01-11 13:38:33 +00:00
Test for .Open() if file path is invalid.
This commit is contained in:
parent
d5ec961cb1
commit
6b628d9bca
@ -30,5 +30,21 @@ namespace OSCADSharp.UnitTests
|
||||
|
||||
Assert.AreEqual("", output[1]);
|
||||
}
|
||||
|
||||
[TestMethod]
|
||||
[ExpectedException(typeof(InvalidOperationException))]
|
||||
public void Settings_NullOpenSCADPathThrowsError()
|
||||
{
|
||||
Settings.OpenSCADPath = null;
|
||||
|
||||
var cube = new Cube();
|
||||
|
||||
var mock = new Mock<IFileWriter>();
|
||||
mock.Setup(_wrtr => _wrtr.WriteAllLines(It.IsAny<string>(), It.IsAny<string[]>()))
|
||||
.Callback<string, string[]>((path, contents) => { });
|
||||
Dependencies.FileWriter = mock.Object;
|
||||
|
||||
cube.ToFile("test").Open();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -17,12 +17,26 @@ namespace OSCADSharp.Files
|
||||
|
||||
public void CreateModel(string outputFile)
|
||||
{
|
||||
Process.Start(Settings.OpenSCADPath, String.Format("-o {0} {1}", outputFile, this.filePath));
|
||||
try
|
||||
{
|
||||
Process.Start(Settings.OpenSCADPath, String.Format("-o {0} {1}", outputFile, this.filePath));
|
||||
}
|
||||
catch (InvalidOperationException)
|
||||
{
|
||||
throw new InvalidOperationException("Cannot open because Settings.OpenSCADPath is not a valid file path. Please check that the path defined points to you OpenSCAD executable.");
|
||||
}
|
||||
}
|
||||
|
||||
public void Open()
|
||||
{
|
||||
Process.Start(Settings.OpenSCADPath, String.Format("{0}", this.filePath));
|
||||
try
|
||||
{
|
||||
Process.Start(Settings.OpenSCADPath, String.Format("{0}", this.filePath));
|
||||
}
|
||||
catch (InvalidOperationException)
|
||||
{
|
||||
throw new InvalidOperationException("Cannot open because Settings.OpenSCADPath is not a valid file path. Please check that the path defined points to you OpenSCAD executable.");
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user