Beispiel #1
0
        public void IsRunning_OnRunningService_True()
        {
            //Ensure the service is stopped
            var service = new ServiceController(SERVICE_NAME);
            var timeout = TimeSpan.FromMilliseconds(5000);

            if (service.Status != ServiceControllerStatus.Running)
            {
                service.Start();
            }
            service.WaitForStatus(ServiceControllerStatus.Running, timeout);

            //Mock the commandXml
            var info = Mock.Of <IWindowsServiceRunningCheck>(
                start => start.ServiceName == SERVICE_NAME &&
                start.TimeOut == 5000
                );

            //Apply the test
            var predicate = WindowsServiceCheck.IsRunning(info);
            var result    = predicate.Validate();

            //Assert
            Assert.That(result, Is.True);
        }
Beispiel #2
0
        public void IsRunning_OnNotExistingService_False()
        {
            //Mock the commandXml
            var info = Mock.Of <IWindowsServiceRunningCheck>(
                start => start.ServiceName == "NotExisting" &&
                start.TimeOut == 5000
                );

            //Apply the test
            var predicate = WindowsServiceCheck.IsRunning(info);
            var result    = predicate.Validate();

            //Assert
            Assert.That(result, Is.False);
        }