Ejemplo n.º 1
0
        public void OnSend(Message message)
        {
            var request = message as Request;

            if (request != null) {
                Console.WriteLine(string.Format("request sent ({0}): {1}", request.Id, request.Uri));
            }
        }
Ejemplo n.º 2
0
 public void Should_cancel_retransmission_if_reply_received()
 {
     var request = new Request(CodeRegistry.Get, true);
     _messageLayer.Send(request);
     var ack = new Message(MessageType.Acknowledgement) { Id = request.Id };
     _messageLayer.OnReceive(ack);
     Assert.AreEqual(0, _messageLayer.Retransmissions.Count());
 }
Ejemplo n.º 3
0
        public void OnReceive(Message message)
        {
            var response = message as Response;

            if (response != null) {
                Console.WriteLine(string.Format("response received ({0}): {1}", message.Id, ByteConverter.GetString(message.Payload)));
            }
        }
Ejemplo n.º 4
0
        public void OnReceive(Message message)
        {
            var request = message as Request;

            if (request != null) {
                Console.WriteLine(string.Format("request received ({0}): {1}", request.Id, request.Uri.LocalPath));
            }
        }
Ejemplo n.º 5
0
 public void Should_reply_duplicated_requests_from_cache_if_confirmable()
 {
     var request = new Request(CodeRegistry.Get, true) { Id = 1 };
     var ack = new Message(MessageType.Acknowledgement) { Id = 1 };
     _messageLayer.OnReceive(request);
     _messageLayer.Send(ack);
     _messageLayer.OnReceive(request);
     _observer.Verify(h => h.OnReceive(request), Times.Once());
     _lowerLayerMock.Verify(l => l.Send(ack), Times.Exactly(2));
 }
Ejemplo n.º 6
0
        public void OnReceive(Message message)
        {
            var request = message as Request;

            if (request != null) {
                if (CanBePiggyBacked(request)) {
                    Respond(request, true);
                }
                else {
                    if (request.IsConfirmable) {
                        Accept(request);
                    }

                    Respond(request);
                }
            }
        }
Ejemplo n.º 7
0
 private void Accept(Request request)
 {
     var ack = new Message(MessageType.Acknowledgement) { Id = request.Id };
     _messageLayer.Send(ack);
 }
Ejemplo n.º 8
0
 public void OnSend(Message message)
 {
 }
Ejemplo n.º 9
0
 public void Should_set_message_id()
 {
     var message = new Message(MessageType.Acknowledgement);
     _messageLayer.Send(message);
     _lowerLayerMock.Verify(l => l.Send(It.Is<Message>(m => m.Id > 0)));
 }
Ejemplo n.º 10
0
 public void Should_send_message_over_lower_layer()
 {
     var message = new Message(MessageType.Acknowledgement);
     _messageLayer.Send(message);
     _lowerLayerMock.Verify(l => l.Send(message));
 }
Ejemplo n.º 11
0
 public void SetUp()
 {
     _message = new Message(MessageType.Acknowledgement);
 }
Ejemplo n.º 12
0
 public void Reset_message_should_be_empty()
 {
     var message = new Message(MessageType.Reset);
     Assert.IsNotNull(message);
 }
Ejemplo n.º 13
0
 public void Acknowledgement_message_should_be_empty()
 {
     var message = new Message(MessageType.Acknowledgement);
     Assert.IsNotNull(message);
 }