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)); } }
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()); }
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))); } }
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)); } }
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)); }
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); } } }
private void Accept(Request request) { var ack = new Message(MessageType.Acknowledgement) { Id = request.Id }; _messageLayer.Send(ack); }
public void OnSend(Message message) { }
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))); }
public void Should_send_message_over_lower_layer() { var message = new Message(MessageType.Acknowledgement); _messageLayer.Send(message); _lowerLayerMock.Verify(l => l.Send(message)); }
public void SetUp() { _message = new Message(MessageType.Acknowledgement); }
public void Reset_message_should_be_empty() { var message = new Message(MessageType.Reset); Assert.IsNotNull(message); }
public void Acknowledgement_message_should_be_empty() { var message = new Message(MessageType.Acknowledgement); Assert.IsNotNull(message); }