public virtual void TestEventHistory()
        {
            Register();
            BreakableService service = new BreakableService();

            AssertListenerState(listener, Service.STATE.Notinited);
            Assert.Equal(0, listener.GetEventCount());
            service.Init(new Configuration());
            AssertListenerState(listener, Service.STATE.Inited);
            NUnit.Framework.Assert.AreSame(service, listener.GetLastService());
            AssertListenerEventCount(listener, 1);
            service.Start();
            AssertListenerState(listener, Service.STATE.Started);
            AssertListenerEventCount(listener, 2);
            service.Stop();
            AssertListenerState(listener, Service.STATE.Stopped);
            AssertListenerEventCount(listener, 3);
        }
 /// <summary>Assert that the number of state change notifications matches expectations.
 ///     </summary>
 /// <param name="breakable">the listener</param>
 /// <param name="count">the expected count.</param>
 public virtual void AssertListenerEventCount(BreakableStateChangeListener breakable
                                              , int count)
 {
     Assert.Equal("Wrong event count in " + breakable, count, breakable
                  .GetEventCount());
 }
 private void AssertEventCount(BreakableStateChangeListener listener, int expected
                               )
 {
     Assert.Equal(listener.ToString(), expected, listener.GetEventCount
                      ());
 }