public void Validate_OnNotExistingService_False() { //Mock the args and setup command var args = Mock.Of <IRunningConditionArgs>( isRunning => isRunning.ServiceName == new LiteralScalarResolver <string>("NOT EXISTING") && isRunning.TimeOut == new LiteralScalarResolver <int>("5000") ); var factory = new ProcessConditionFactory(); var condition = factory.Instantiate(args); //Assert Assert.That(condition.Validate(), Is.False); }
public void Validate_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 args and setup command var args = Mock.Of <IRunningConditionArgs>( isRunning => isRunning.ServiceName == new LiteralScalarResolver <string>(SERVICE_NAME) && isRunning.TimeOut == new LiteralScalarResolver <int>("5000") ); var factory = new ProcessConditionFactory(); var condition = factory.Instantiate(args); //Assert Assert.That(condition.Validate(), Is.True); }