/// <summary>This class is internal only to make tests work. /// </summary> /// <param name="args"></param> /// <returns></returns> internal static int Main(string[] args) { if (args == null || args.Length == 0) { return((int)ReturnValues.NoInput); } var options = ParseArgs(args); var impl = new ProgramImpl( PluginHandler.Create(), new System.IO.Abstractions.FileSystem(), new AssemblyFactory(), Outputter.Create());; var res = impl.Execute(options); return((int)res); }
public void ShouldLoadAndExecute() { var sourceCode = @" using LehmanLaidun.Plugin; using System.Xml.Linq; namespace MyPlugin { public class Command : ICommand { public string Name => ""My plugin""; public string Description => ""A plugin for testing""; public ParseResult Parse(string pathfile) { return ParseResult.Create( Name, XDocument.Parse($""<data plugin=\""{Name}\"">{pathfile}</data>"") ); } } } "; var assembly = CreateAssembly(sourceCode); var sut = PluginHandler.Create(); // Act. sut.Load(new[] { assembly }); var res = sut.Execute("x"); // Assert. res .Select(pr => new { pr.Name, Result = pr.Result.ToString() }) .Should() .BeEquivalentTo( new[] { new { Name = "My plugin", Result = "<data plugin=\"My plugin\">x</data>" }, } ); }
public void CanReturnFileInRoot() { var rootName = Logic.ElementNameRoot; var files = new[] { new { pathfile = Path.Combine(Root, "whatever.jpg"), length = 4, lastAccessTime = DateTime.Parse("2010-01-05 11:22:33Z") } }; var mockedFileSystem = new MockFileSystem( files.ToDictionary(pf => pf.pathfile, pf => CreateMockFileData(pf.length, pf.lastAccessTime)), Root ); var pluginHandler = PluginHandler.Create(); var sut = LogicFactory.CreateForPath(mockedFileSystem, Root, pluginHandler); // # Act. var res = sut.AsXDocument(); // # Assert. res.Should().BeEquivalentTo( XDocument.Parse(@$ " <root path='{Root}'>
public void CanLoadAndExecute() { var assemblyFactory = new AssemblyFactory(); var plugins = new[] { new { Name = "PluginOne", Framework = "netstandard2.0" }, new{ Name = "PluginTwo", Framework = "net6.0" }, }; var pluginPathFiles = plugins.Select(plugin => pathWrapper.Combine( PathToPlugins(), plugin.Name, "bin", "Debug", plugin.Framework, plugin.Name + ".dll") ); var assemblies = pluginPathFiles.Select(pluginPathFile => assemblyFactory.LoadFile(pluginPathFile)); var sut = PluginHandler.Create(); // Act. sut.Load(assemblies); var res = sut.Execute("a"); // Assert. res .Select(pr => new { pr.Name, Result = pr.Result.ToString() }) .Should() .BeEquivalentTo( new[] { new { Name = "Plugin one", Result = "<data plugin=\"Plugin one\">a</data>" }, new { Name = "Plugin two", Result = "<data plugin=\"Plugin two\">a</data>" }, } ); }