public virtual void TestServiceNotificationsStopOnceUnregistered()
        {
            BreakableService             svc      = new BreakableService(false, false, false);
            BreakableStateChangeListener listener = new BreakableStateChangeListener();

            svc.RegisterServiceListener(listener);
            svc.Init(new Configuration());
            AssertEventCount(listener, 1);
            svc.UnregisterServiceListener(listener);
            svc.Start();
            AssertEventCount(listener, 1);
            svc.Stop();
            AssertEventCount(listener, 1);
            svc.Stop();
        }
        public virtual void TestServiceNotificationsUnregisterDuringCallback()
        {
            BreakableService             svc      = new BreakableService(false, false, false);
            BreakableStateChangeListener listener = new TestServiceLifecycle.SelfUnregisteringBreakableStateChangeListener
                                                        ();
            BreakableStateChangeListener l2 = new BreakableStateChangeListener();

            svc.RegisterServiceListener(listener);
            svc.RegisterServiceListener(l2);
            svc.Init(new Configuration());
            AssertEventCount(listener, 1);
            AssertEventCount(l2, 1);
            svc.UnregisterServiceListener(listener);
            svc.Start();
            AssertEventCount(listener, 1);
            AssertEventCount(l2, 2);
            svc.Stop();
            AssertEventCount(listener, 1);
            svc.Stop();
        }