public void TestOnStartThenStop() { var controller = new ServiceController(_testService.TestServiceName); AssertExpectedProperties(controller); string expected = @"OnStart args= OnStop "; controller.Stop(); controller.WaitForStatus(ServiceControllerStatus.Stopped); Assert.Equal(expected, _testService.GetServiceOutput()); }
public void StartWithArguments() { var controller = new ServiceController(_testService.TestServiceName); controller.WaitForStatus(ServiceControllerStatus.Running, _testService.ControlTimeout); Assert.Equal(ServiceControllerStatus.Running, controller.Status); controller.Stop(); controller.WaitForStatus(ServiceControllerStatus.Stopped, _testService.ControlTimeout); Assert.Equal(ServiceControllerStatus.Stopped, controller.Status); var args = new[] { "a", "b", "c", "d", "e" }; controller.Start(args); controller.WaitForStatus(ServiceControllerStatus.Running, _testService.ControlTimeout); Assert.Equal(ServiceControllerStatus.Running, controller.Status); string argsOutput = _testService.GetServiceOutput().Trim(); string argsInput = "OnStart args=" + string.Join(",", args); Assert.Equal(argsInput, argsOutput); }