public void Create() { var src = new SpoolerService(); Assert.That(src.Name, Is.EqualTo("Spooler")); Assert.That(src.Status, Is.EqualTo(ServiceControllerStatus.Running).Or .EqualTo(ServiceControllerStatus.Stopped)); Assert.That(src.Timeout, Is.EqualTo(TimeSpan.FromSeconds(10))); }
public virtual void Setup() { var service = new SpoolerService(); if (service.Status != ServiceControllerStatus.Running) { service.Start(); } }
/* ----------------------------------------------------------------- */ /// /// Log /// /// <summary> /// Puts debug information to the log file. /// </summary> /// /// <param name="src">Service object.</param> /// <param name="action">User action.</param> /// <param name="method">Method name.</param> /// /* ----------------------------------------------------------------- */ public static void Log(this SpoolerService src, Action action, [CallerMemberName] string method = null) { var prev = src.Status; var sw = Stopwatch.StartNew(); action(); src.Put($"[{method}]", $"{prev} -> {src.Status}", $"({sw.Elapsed})"); }
/* ----------------------------------------------------------------- */ /// /// Log /// /// <summary> /// Puts debug information to the log file. /// </summary> /// /// <param name="src">Service object.</param> /// <param name="method">Method name.</param> /// /* ----------------------------------------------------------------- */ public static void Log(this SpoolerService src, [CallerMemberName] string method = null) => src.Put( $"[{method}]", $"{nameof(src.Name)}:{src.Name.Quote()}", $"{nameof(src.Status)}:{src.Status}", $"{nameof(src.DisplayName)}:{src.DisplayName.Quote()}", $"{nameof(src.MachineName)}:{src.MachineName.Quote()}", $"{nameof(src.CanStop)}:{src.CanStop}", $"{nameof(src.Timeout)}:{src.Timeout}" );
public void Restart() => Invoke(() => { var src = new SpoolerService(); src.Stop(); src.Stop(); // ignore Assert.That(src.Status, Is.EqualTo(ServiceControllerStatus.Stopped)); src.Start(); src.Start(); // ignore Assert.That(src.Status, Is.EqualTo(ServiceControllerStatus.Running)); });
public void Reset() => Invoke(() => { var src = new SpoolerService(); src.Reset(); Assert.That(src.Status, Is.EqualTo(ServiceControllerStatus.Running)); });