public void TestClusterStart() { _coreA.Start(10001); _coreB.Start(10002); Assert.AreEqual(CoreState.WaitingForMaster, _coreA.GetStatus()); Assert.AreEqual(CoreState.WaitingForMaster, _coreB.GetStatus()); _clusterManager.Start(); Thread.Sleep(500); Assert.AreEqual(CoreState.RunningMaster, _coreA.GetStatus()); Assert.AreEqual(CoreState.RunningSlave, _coreB.GetStatus()); }
private void WaitForState(NodeCore node, CoreState expectedState, int timeToWait) { for (int i = 0; i < 10; i++) { Thread.Sleep(timeToWait / 10); if (node.GetStatus() == expectedState) { return; } } Thread.Sleep(timeToWait / 10); Assert.AreEqual(expectedState, node.GetStatus(), "Node did not enter the expected state after {0} milliseconds", timeToWait); }