public virtual void TestStopFailingInitAndStop() { BreakableService svc = new BreakableService(true, false, true); svc.RegisterServiceListener(new LoggingStateChangeListener()); try { svc.Init(new Configuration()); NUnit.Framework.Assert.Fail("Expected a failure, got " + svc); } catch (BreakableService.BrokenLifecycleEvent e) { Assert.Equal(Service.STATE.Inited, e.state); } //the service state is stopped AssertServiceStateStopped(svc); Assert.Equal(Service.STATE.Inited, svc.GetFailureState()); Exception failureCause = svc.GetFailureCause(); NUnit.Framework.Assert.IsNotNull("Null failure cause in " + svc, failureCause); BreakableService.BrokenLifecycleEvent cause = (BreakableService.BrokenLifecycleEvent )failureCause; NUnit.Framework.Assert.IsNotNull("null state in " + cause + " raised by " + svc, cause.state); Assert.Equal(Service.STATE.Inited, cause.state); }