public void Parse_Integer() { var src = new ArgumentCollection(new[] { "Sample.json", "/Timeout", "Dummy", "/Retry", "Dummy" }, '/', true); Assert.That(src.GetTimeout(), Is.EqualTo(30)); Assert.That(src.GetRetryCount(), Is.EqualTo(1)); }
public void Parse(IEnumerable <string> args, int id) { var src = new ArgumentCollection(args, '/', true); Assert.That(src.GetTimeout(), Is.EqualTo(300)); Assert.That(src.GetRetryCount(), Is.EqualTo(10)); Assert.That(src.GetCommand(), Is.Not.Null.And.Not.Empty); Assert.That(src.GetConfiguration(), Is.Not.EqualTo("Sample.json").And.EndWith("Sample.json")); Assert.That(src.GetResourceDirectory(), Is.Not.EqualTo("Printers").And.EndWith("Printers")); }
public void Parse_Empty() { var src = new ArgumentCollection(new string[0], '/', true); var dir = Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location); Assert.That(src.GetTimeout(), Is.EqualTo(30)); Assert.That(src.GetRetryCount(), Is.EqualTo(1)); Assert.That(src.GetCommand(), Is.Empty); Assert.That(src.GetConfiguration(), Is.Null); Assert.That(src.GetResourceDirectory(), Is.EqualTo(dir)); }
/* ----------------------------------------------------------------- */ /// /// Uninstall /// /// <summary> /// Executes the uninstallation. /// </summary> /// /* ----------------------------------------------------------------- */ private static void Uninstall(ArgumentCollection src) { var sec = src.GetTimeout(); var engine = src.CreateInstaller(); Logger.Debug(LogType, $"Method:{nameof(Uninstall).Quote()}"); Logger.Debug(LogType, $"Configuration:{engine.Location.Quote()}"); engine.Try(src.GetRetryCount(), i => { engine.Timeout = TimeSpan.FromSeconds(sec * (i + 1)); engine.Uninstall(); }); }
/* ----------------------------------------------------------------- */ /// /// Install /// /// <summary> /// Executes the installation. /// </summary> /// /* ----------------------------------------------------------------- */ private static void Install(ArgumentCollection src, bool reinstall) { var sec = src.GetTimeout(); var engine = src.CreateInstaller(); Logger.Debug(LogType, $"Configuration:{engine.Location.Quote()}"); Logger.Debug(LogType, $"Resource:{engine.ResourceDirectory.Quote()}"); engine.Try(src.GetRetryCount(), i => { engine.Reinstall = reinstall; engine.Timeout = TimeSpan.FromSeconds(sec * (i + 1)); engine.Install(); }); }