Exemplo n.º 1
0
        public void UpdateLog_OnValueUpdateReceived()
        {
            var message = new NodeMessage(0, TestValue, MessageType.ValueUpdate, null, Guid.Empty);

            _leaderNodeRunner.ReceiveMessage(message);

            _node.Log.Count.ShouldBe(1);
            _node.Log[0].Value.ShouldBe(TestValue);
            _node.Log[0].Type.ShouldBe(OperationType.Update);
        }
Exemplo n.º 2
0
        public void UpdateLogAndConfirm_OnLogUpdate()
        {
            var message = new NodeMessage(0, TestValue, MessageType.LogUpdate, LeaderName, Guid.Empty);

            _nodeRunner.ReceiveMessage(message);

            _node.Log.Count.ShouldBe(1);
            _node.Log[0].Value.ShouldBe(TestValue);
            _node.Log[0].Type.ShouldBe(OperationType.Update);
            _messageBroker.Received(1).Send(Arg.Is <NodeMessage>(m => m.Type == MessageType.LogUpdateConfirmation),
                                            Arg.Is <string>(x => x.Equals(LeaderName)));
        }
Exemplo n.º 3
0
        public void ResetTimer_WhenMessageFromNewLeaderReceived()
        {
            _candidate.ReceiveMessage(new NodeMessage(2, "test", MessageType.Info, "someSender", Guid.Empty));

            _timer.Received(1).Reset();
        }