mirror of
https://github.com/eliasstepanik/OSCADSharpDotnet7.git
synced 2026-01-11 21:48:34 +00:00
Added setters for Dependency file operation interfaces
This commit is contained in:
parent
308aa7f25c
commit
5425cad195
@ -145,7 +145,7 @@ namespace OSCADSharp.UnitTests
|
||||
var mock = new Mock<IFileWriter>();
|
||||
mock.Setup(_wrtr => _wrtr.WriteAllLines(It.IsAny<string>(), It.IsAny<string[]>()))
|
||||
.Callback<string, string[]>((path, contents) => { output = contents; });
|
||||
Dependencies.FileWriter = mock.Object;
|
||||
Dependencies.SetFileWriter(mock.Object);
|
||||
|
||||
cube.ToFile("myFile");
|
||||
|
||||
@ -162,7 +162,7 @@ namespace OSCADSharp.UnitTests
|
||||
var mock = new Mock<IFileWriter>();
|
||||
mock.Setup(_wrtr => _wrtr.WriteAllLines(It.IsAny<string>(), It.IsAny<string[]>()))
|
||||
.Callback<string, string[]>((path, contents) => { output = contents; });
|
||||
Dependencies.FileWriter = mock.Object;
|
||||
Dependencies.SetFileWriter(mock.Object);
|
||||
|
||||
cube.ToFile("myFile");
|
||||
|
||||
|
||||
@ -24,7 +24,7 @@ namespace OSCADSharp.UnitTests.Scripting
|
||||
var compound = new Variable("x", 5) / 12;
|
||||
|
||||
string type = compound.GetType().ToString();
|
||||
Assert.AreEqual("OSCADSharp.Scripting.CompoundVariable", type);
|
||||
Assert.AreEqual("OSCADSharp.CompoundVariable", type);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -21,7 +21,7 @@ namespace OSCADSharp.UnitTests
|
||||
var mock = new Mock<IFileWriter>();
|
||||
mock.Setup(_wrtr => _wrtr.WriteAllLines(It.IsAny<string>(), It.IsAny<string[]>()))
|
||||
.Callback<string, string[]>((path, contents) => { output = contents; });
|
||||
Dependencies.FileWriter = mock.Object;
|
||||
Dependencies.SetFileWriter(mock.Object);
|
||||
|
||||
cube.ToFile("myFile");
|
||||
|
||||
@ -39,7 +39,7 @@ namespace OSCADSharp.UnitTests
|
||||
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;
|
||||
Dependencies.SetFileWriter(mock.Object);
|
||||
|
||||
cube.ToFile("test").Open();
|
||||
}
|
||||
|
||||
@ -14,11 +14,31 @@ namespace OSCADSharp
|
||||
/// <summary>
|
||||
/// Used to write scripts to file
|
||||
/// </summary>
|
||||
public static IFileWriter FileWriter = new DefaultFileWriter();
|
||||
public static IFileWriter FileWriter { get; private set; } = new DefaultFileWriter();
|
||||
|
||||
/// <summary>
|
||||
/// Sets the filewriter for OSCADSharp to use
|
||||
/// </summary>
|
||||
/// <param name="writer"></param>
|
||||
public static void SetFileWriter(IFileWriter writer)
|
||||
{
|
||||
FileWriter = writer;
|
||||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// Factory method to provide the class used to perform actions on output scripts
|
||||
/// </summary>
|
||||
public static Func<string, IFileInvoker> FileInvokerFactory = (path) => { return new DefaultFileInvoker(path); };
|
||||
public static Func<string, IFileInvoker> FileInvokerFactory { get; private set; } = (path) => { return new DefaultFileInvoker(path); };
|
||||
|
||||
/// <summary>
|
||||
/// Sets the factory method OSCADSharp will use to get
|
||||
/// file invoker objects
|
||||
/// </summary>
|
||||
/// <param name="invokerFactoryMethod"></param>
|
||||
public static void SetFileInvokerFactory(Func<string, IFileInvoker> invokerFactoryMethod)
|
||||
{
|
||||
FileInvokerFactory = invokerFactoryMethod;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user