Ejemplo n.º 1
0
        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)));
        }
Ejemplo n.º 2
0
        public virtual void Setup()
        {
            var service = new SpoolerService();

            if (service.Status != ServiceControllerStatus.Running)
            {
                service.Start();
            }
        }
Ejemplo n.º 3
0
        /* ----------------------------------------------------------------- */
        ///
        /// 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})");
        }
Ejemplo n.º 4
0
 /* ----------------------------------------------------------------- */
 ///
 /// 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}"
     );
Ejemplo n.º 5
0
        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));
        });
Ejemplo n.º 6
0
 public void Reset() => Invoke(() =>
 {
     var src = new SpoolerService();
     src.Reset();
     Assert.That(src.Status, Is.EqualTo(ServiceControllerStatus.Running));
 });