public void Get_Should_GetService()
        {
            // arrange
            var serviceName = _nameGenerator.RandomName;

            _serviceInstaller.InstallService(serviceName);

            // act
            var service = new Model.WindowsServiceInfo(serviceName);

            // assert
            service.AccountDomain.Should().Be(null);
            service.AccountName.Should().Be("LocalSystem");
            service.Description.Should().Be(null);
            service.DisplayName.Should().Be(serviceName);
            service.ErrorControl.Should().Be(WindowsServiceErrorControl.Normal);
            service.InteractWithDesktop.Should().Be(false);
            service.Name.Should().Be(serviceName);
            service.Path.Should().Be(_serviceInstaller.ServicePath);
            service.ProcessId.Should().Be(0);
            service.StartMode.Should().Be(WindowsServiceStartMode.Automatic);
            service.State.Should().Be(WindowsServiceState.Stopped);
            service.Status.Should().Be(WindowsServiceStatus.Ok);
            service.CanPause.Should().BeFalse();
            service.CanStop.Should().BeFalse();
            service.ExitCode.Should().Be(1077u);
            service.ServiceDependencies.Should().BeEmpty();
        }
        public void Continue_Should_Resume_PausedService()
        {
            // arrange
            var serviceName = _nameGenerator.GetRandomName(Prefix);

            _serviceInstaller.InstallService(serviceName);
            ServiceHelper.StartService(serviceName);
            ServiceHelper.PauseService(serviceName);

            _shell.GetState(serviceName).Should().Be(WindowsServiceState.Paused);

            // act
            var result = _shell.Continue(serviceName);

            // assert
            result.Should().BeTrue();

            ServiceHelper.GetState(serviceName).Should().Be(WindowsServiceState.Running);
        }
Пример #3
0
        public void Start_Should_Start_StoppedService()
        {
            // arrange
            var serviceName = _nameGenerator.GetRandomName(Prefix);

            _serviceInstaller.InstallService(serviceName);
            Thread.Sleep(1000);

            _shell.GetState(serviceName).Should().Be(WindowsServiceState.Stopped);

            // act
            var result = _shell.Start(serviceName);

            Thread.Sleep(1000);


            // assert
            result.Should().BeTrue();

            ServiceHelper.GetState(serviceName).Should().Be(WindowsServiceState.Running);
        }