Ejemplo n.º 1
0
        public void TestNotAvailableWindowsServiceStateIsReturnedWhenServiceNameIsNull()
        {
            try
            {
                const WindowsServiceState expected = WindowsServiceState.NotAvailable;

                var state = _serviceUtils.GetServiceState(Host, null);

                Assert.AreEqual(expected, state, "Error testing service state, expected WindowsServiceState.NotAvailable");
            }
            finally
            {
                _processUtils.VerifyAll();
            }
        }
Ejemplo n.º 2
0
        /// <inheritdoc />
        public void WaitForState(string serviceName, WindowsServiceState state, TimeSpan timeout)
        {
            ThrowIfCantFindService(serviceName);

            var startedTime = DateTime.UtcNow;

            do
            {
                if (GetState(serviceName) == state)
                {
                    return;
                }

                Thread.Sleep(DelayTimeInMiliseconds);
            } while (DateTime.UtcNow - startedTime < timeout);

            throw new TimeoutException();
        }
Ejemplo n.º 3
0
        public void TestStoppedWindowsServiceStateIsReturned()
        {
            try
            {
                const WindowsServiceState expected = WindowsServiceState.Stopped;

                var    output = "Service is STOPPED";
                string errors;

                _processUtils.Setup(m => m.ExecuteProcess(It.IsAny <ProcessStartInfo>(), out output, out errors)).Returns(true);

                var state = _serviceUtils.GetServiceState(Host, ServiceName);

                Assert.AreEqual(expected, state, "Error testing service state, expected WindowsServiceState.Stopped");
            }
            finally
            {
                _processUtils.VerifyAll();
            }
        }
        /// <inheritdoc />
        public IWindowsServiceInfoExtensions WaitForState(WindowsServiceState state)
        {
            _shell.Value.WaitForState(_info.Name, state);

            return(Refresh());
        }
Ejemplo n.º 5
0
 /// <inheritdoc />
 public void WaitForState(string serviceName, WindowsServiceState state)
 {
     WaitForState(serviceName, state, _timeout);
 }