public void DoesNotStopWhenAlreadyStopped() { var stopped = false; var cluster = new RestCluster(); cluster.OnBeforeStopAll = () => { stopped = !stopped; }; cluster.StartAll(); cluster.StopAll(); cluster.StopAll(); stopped.ShouldBeTrue(); }
public void InvokesDelegates() { var beforeAll = false; var beforeEach = false; var afterAll = false; var afterEach = false; var server = Substitute.For <IRestServer>(); server.IsListening.Returns(true); var cluster = new RestCluster(); cluster.OnBeforeStopAll = () => { beforeAll = true; }; cluster.OnBeforeStopEach = srvr => { beforeEach = true; }; cluster.OnAfterStopAll = () => { afterAll = true; }; cluster.OnAfterStopEach = srvr => { afterEach = true; }; cluster.Add("x", server); cluster.StartAll(); beforeAll.ShouldBeFalse(); beforeEach.ShouldBeFalse(); afterAll.ShouldBeFalse(); afterEach.ShouldBeFalse(); cluster.StopAll(); beforeAll.ShouldBeTrue(); beforeEach.ShouldBeTrue(); afterAll.ShouldBeTrue(); afterEach.ShouldBeTrue(); }
public void StopsServerWhenClusterStops() { var cluster = new RestCluster(); var server = Substitute.For <IRestServer>(); server.IsListening.Returns(true); cluster.Add(server); cluster.StartAll(); cluster.StopAll(); server.Received().Stop(); }