public void AllCountTest() { var nodes = CreateNodes(NodesCount); var nodesCollection = new NodeCollection(nodes); Assert.AreEqual(NodesCount, nodesCollection.All.Count()); }
public void AddNewNodeForbidsNullsTest() { var nodes = CreateNodes(2); var nodesCollection = new NodeCollection(nodes); Assert.Throws<ArgumentNullException>(() => nodesCollection.AddNewNode(null)); }
public void AddNewNodeForbidsIdDuplication() { var nodes = CreateNodes(2); var nodesCollection = new NodeCollection(nodes); Assert.Throws<ArgumentException>(() => nodesCollection.AddNewNode(new NodeConfiguration{ServerId = 1})); }
public void CanAddNodesTest() { var nodes = CreateNodes(NodesCount); var nodesColection = new NodeCollection(nodes); nodesColection.AddNewNode(new NodeConfiguration() {ServerId = 19}); Assert.AreEqual(NodesCount + 1, nodesColection.All.Count()); }
public void AddNewNodeForbidsSecondMasterTest() { var nodes = CreateNodes(2, i => i == 0); var nodesCollection = new NodeCollection(nodes); var secondMaster = new Mock<INodeConfiguration>(); secondMaster.SetupGet(m => m.IsMaster).Returns(true); Assert.Throws<ArgumentException>(() => nodesCollection.AddNewNode(secondMaster.Object)); }
public void CanMarkAsDeadNodeTest() { var nodes = CreateNodes(NodesCount); var nodesColection = new NodeCollection(nodes); nodesColection.MarkAsDead(1); Assert.AreEqual(NodesCount - 1, nodesColection.All.Count()); Assert.AreEqual(1, nodesColection.DeadNodesCount); }
public void CannotAddSecondMasterTest() { var nodes = CreateNodes(NodesCount); var nodesColection = new NodeCollection(nodes); var master = new NodeConfiguration() {IsMaster = true}; Assert.Throws<ArgumentException>(() => nodesColection.AddNewNode(master)); }
public void SyblingsTest() { m_ServerConfigurationMock.Setup((config) => config.ServerId).Returns(0); var nodes = CreateNodes(NodesCount); var nodesCollection = new NodeCollection(nodes); var syblings = nodesCollection.Siblings; Assert.IsFalse(syblings.Any(sybling => sybling.ServerId == ServerClass.Configuration.ServerId)); }
public void SelfAccessTest() { m_ServerConfigurationMock.Setup((config) => config.ServerId).Returns(1); var nodes = CreateNodes(NodesCount); var nodesCollection = new NodeCollection(nodes); var self = nodesCollection.Self; Assert.AreEqual(nodes.Single(n => n.ServerId == 1), self); }
public void SelfAccessInCaseBadIdTest() { m_ServerConfigurationMock.Setup((config) => config.ServerId).Returns(11); var nodes = CreateNodes(NodesCount); var nodesCollection = new NodeCollection(nodes); Assert.Throws<ApplicationException>(() => { var self = nodesCollection.Self; }); }
public void RemoveDeadNodeWorksWithInvalidIdsTest() { var nodes = CreateNodes(NodesCount); var nodesColection = new NodeCollection(nodes); Assert.DoesNotThrow(() => nodesColection.MarkAsDead(17)); }
public void MasterThrowsExceptionInCaseOfManyMastersTest() { var nodes = CreateNodes(NodesCount, (serverId) => serverId < 2); var nodesCollection = new NodeCollection(nodes); Assert.Throws<ApplicationException>(() => { var master = nodesCollection.Master; }); }
public void MasterTest() { var nodes = CreateNodes(NodesCount, (serverId) => serverId == 0); var nodesCollection = new NodeCollection(nodes); var master = nodesCollection.Master; Assert.AreEqual(0, master.ServerId); }