public void MultipleInvalidServices() { const string serviceName1 = "ASDEDFG123234fwerw4f"; const string serviceName2 = "ERseSfsdfDF23£23eE"; using (var domain = new WindowServiceStateDomain(new WindowsServiceStateCheckConfig { Enabled = true, ExpectedState = "Running", FriendlyId = "HealthCheckTest", Services = new List <string> { serviceName1, serviceName2 } })) { Feature.WithScenario("Multiple invalid windows service names supplied") .Given(domain.TheAgentIsStarted) .When(domain.TheHealthCheckIsInvoked) .Then(domain.ShouldThrow_Exception, typeof(InvalidOperationException)) .And(domain._ShouldBeInTheExceptionMesssage, serviceName1) .And(domain._ShouldBeInTheExceptionMesssage, serviceName2) .ExecuteWithReport(); } }
public void ValidServiceCorrectState() { using (var domain = new WindowServiceStateDomain(new WindowsServiceStateCheckConfig { Enabled = true, ExpectedState = "Running", FriendlyId = "HealthCheckTest", Services = new List <string> { "DHCP Client" } })) { Feature.WithScenario("A valid windows service name specified and it should be in the expected state") .Given(domain.TheAgentIsStarted) .When(domain.TheHealthCheckIsInvoked) .Then(domain.ThrewNoException) .And(domain.ThereShouldBe_HealthCheckNotificationsReceived, 0) .ExecuteWithReport(); } }
public void ValidServiceIncorrectState() { using (var domain = new WindowServiceStateDomain(new WindowsServiceStateCheckConfig { Enabled = true, ExpectedState = "Stopped", FriendlyId = "HealthCheckTest", Services = new List <string> { "DHCP Client" } })) { Feature.WithScenario("A valid windows service name specified but the expected state is incorrect") .Given(domain.TheAgentIsStarted) .And(domain.TheAgentIsStarted) .When(domain.TheHealthCheckIsInvoked) .Then(domain.ThereShouldBe_HealthCheckNotificationsReceived, 1) //.And(domain.TheResultMessageShouldIndicateFailure) .ExecuteWithReport(); } }