public async Task ShouldNotHandleInboundMessageAction(ProtocolMessage.MessageAction action) { bool result = await _state.OnMessageReceived(new ProtocolMessage(action), null); // Assert result.Should().BeFalse(); }
public async Task ShouldNotHandleInboundMessageAction(ProtocolMessage.MessageAction action) { bool result = await _state.OnMessageReceived(new ProtocolMessage(action)); // Assert Assert.False(result); }
public async Task ShouldNotHandleInboundMessageWithAction(ProtocolMessage.MessageAction action) { // Act bool result = await _state.OnMessageReceived(new ProtocolMessage(action)); // Assert result.Should().Be(false); }
public void WhenReceivingAckOrNackMessage_ShouldHandleAction(ProtocolMessage.MessageAction action) { // Act bool result = _ackProcessor.OnMessageReceived(new ProtocolMessage(action)); // Assert Assert.True(result); }
public async Task ShouldIgnoreInboundMessages(ProtocolMessage.MessageAction action) { // Act var result = await _state.OnMessageReceived(new ProtocolMessage(action), null); // Assert result.Should().BeFalse(); }
public async Task ShouldIgnoreInboundMessages(ProtocolMessage.MessageAction action) { // Act var result = await _state.OnMessageReceived(new ProtocolMessage(action)); // Assert Assert.False(result); }
public void WhenReceivingNonAckOrNackMessage_ShouldNotHandleAction(ProtocolMessage.MessageAction action) { // Act bool result = GetAckProcessor().OnMessageReceived(new ProtocolMessage(action)); // Assert Assert.False(result); }
public void SerializesMessageCorrectly_Action(ProtocolMessage.MessageAction messageAction) { // Arrange ProtocolMessage message = new ProtocolMessage(messageAction); string expectedMessage = $"{{\"action\":{(int)messageAction},\"msgSerial\":0}}"; // Act Serialize(message).Should().Be(expectedMessage); }
public async Task ShouldNotHandleInboundMessageAction(ProtocolMessage.MessageAction action) { // Act bool result = await _state.OnMessageReceived(new ProtocolMessage(action)); // Assert Assert.False(result); _context.ShouldHaveNotChangedState(); }
public async Task WhenReceivingAckOrNackMessage_ShouldHandleAction(ProtocolMessage.MessageAction action) { var client = GetDisconnectedClient(); // Act bool result = await client.Workflow.HandleAckMessage(new ProtocolMessage(action)); // Assert result.Should().BeTrue(); }
public void WhenReceiveMessage_HandleAction(ProtocolMessage.MessageAction action) { // Arrange AcknowledgementProcessor target = new AcknowledgementProcessor(); // Act bool result = target.OnMessageReceived(new ProtocolMessage(action)); // Assert Assert.True(result); }
internal static void BlockActionFromReceiving(this IRealtimeClient client, ProtocolMessage.MessageAction action) { var transport = (TestTransportWrapper)((AblyRealtime)client).ConnectionManager.Transport; if (transport is null) { throw new Exception("Client is not using test transport so you can't add BlockedActions"); } transport.BlockReceiveActions.Add(action); }
public async Task ShouldNotHandleInboundMessageAction(ProtocolMessage.MessageAction action) { // Arrange var state = GetState(ErrorInfo.ReasonClosed); // Act bool handled = await state.OnMessageReceived(new ProtocolMessage(action)); // Assert handled.Should().BeFalse(); }
public void DeserializesMessageCorrectly_Action(ProtocolMessage.MessageAction action) { // Arrange string message = $"{{ \"action\": {(int)action} }}"; // Act ProtocolMessage target = JsonHelper.Deserialize <ProtocolMessage>(message); // Assert target.Should().NotBeNull(); Assert.Equal(action, target.Action); }
public void DeserializesMessageCorrectly_Action(ProtocolMessage.MessageAction action) { // Arrange JsonMessageSerializer serializer = new JsonMessageSerializer(); string message = string.Format("{{\"action\":{0}}}", (int)action); // Act ProtocolMessage target = serializer.DeserializeProtocolMessage(message); // Assert Assert.NotNull(target); Assert.Equal <ProtocolMessage.MessageAction>(action, target.Action); }
public void DeserializesMessageCorrectly_Action(ProtocolMessage.MessageAction action) { // Arrange string message = string.Format("{{ \"action\": {0} }}", (int)action); // Act ProtocolMessage target = JsonHelper.Deserialize <ProtocolMessage>(message); // Assert Assert.NotNull(target); Assert.Equal(action, target.Action); }
public void SerializesMessageCorrectly_Action(ProtocolMessage.MessageAction messageAction) { // Arrange JsonMessageSerializer serializer = new JsonMessageSerializer(); ProtocolMessage message = new ProtocolMessage(messageAction); string expectedMessage = string.Format("{{\"action\":{0},\"msgSerial\":0}}", (int)messageAction); // Act object result = serializer.SerializeProtocolMessage(message); // Assert Assert.IsType <string>(result); Assert.Equal <string>(expectedMessage, result as string); }
public void DeserializesMessageCorrectly_Action(ProtocolMessage.MessageAction action) { // Arrange List <byte> expectedMessage = new List <byte>(); expectedMessage.Add(0x81); expectedMessage.AddRange(SerializeString("action")); expectedMessage.Add((byte)action); // Act ProtocolMessage target = MsgPackHelper.Deserialise <ProtocolMessage>(expectedMessage.ToArray()); // Assert Assert.NotNull(target); Assert.Equal(action, target.Action); }
public void WhenSendingNotAPresenceOrDataMessage_MsgSerialNotIncremented(ProtocolMessage.MessageAction messageAction) { // Arrange var targetMessage1 = new ProtocolMessage(messageAction, "Test"); var targetMessage2 = new ProtocolMessage(messageAction, "Test"); var targetMessage3 = new ProtocolMessage(messageAction, "Test"); // Act _ackProcessor.QueueIfNecessary(targetMessage1, null); _ackProcessor.QueueIfNecessary(targetMessage2, null); _ackProcessor.QueueIfNecessary(targetMessage3, null); // Assert Assert.Equal(0, targetMessage1.MsgSerial); Assert.Equal(0, targetMessage2.MsgSerial); Assert.Equal(0, targetMessage3.MsgSerial); }
public void WhenSendingMessage_MsgSerialNotIncremented(ProtocolMessage.MessageAction messageAction) { // Arrange AcknowledgementProcessor target = new AcknowledgementProcessor(); ProtocolMessage targetMessage1 = new ProtocolMessage(messageAction, "Test"); ProtocolMessage targetMessage2 = new ProtocolMessage(messageAction, "Test"); ProtocolMessage targetMessage3 = new ProtocolMessage(messageAction, "Test"); // Act target.SendMessage(targetMessage1, null); target.SendMessage(targetMessage2, null); target.SendMessage(targetMessage3, null); // Assert Assert.Equal(0, targetMessage1.MsgSerial); Assert.Equal(0, targetMessage2.MsgSerial); Assert.Equal(0, targetMessage3.MsgSerial); }
public void WhenSendingPresenceOrDataMessage_IncrementsMsgSerial(ProtocolMessage.MessageAction messageAction) { // Arrange var ackProcessor = GetAckProcessor(); var targetMessage1 = new ProtocolMessage(messageAction, "Test"); var targetMessage2 = new ProtocolMessage(messageAction, "Test"); var targetMessage3 = new ProtocolMessage(messageAction, "Test"); // Act ackProcessor.QueueIfNecessary(targetMessage1, null); ackProcessor.QueueIfNecessary(targetMessage2, null); ackProcessor.QueueIfNecessary(targetMessage3, null); // Assert Assert.Equal(0, targetMessage1.MsgSerial); Assert.Equal(1, targetMessage2.MsgSerial); Assert.Equal(2, targetMessage3.MsgSerial); }
public void SerializesMessageCorrectly_Action(ProtocolMessage.MessageAction messageAction) { // Arrange ProtocolMessage message = new ProtocolMessage(messageAction); List <byte> expectedMessage = new List <byte>(); expectedMessage.Add(0x82); expectedMessage.AddRange(SerializeString("action")); expectedMessage.Add((byte)messageAction); expectedMessage.AddRange(SerializeString("msgSerial")); expectedMessage.Add(0); // Act object result = MsgPackHelper.Serialise(message); // Assert Assert.IsType <byte[]>(result); Assert.Equal(expectedMessage.ToArray(), result as byte[]); }
public async Task WhenSendingNotAPresenceOrDataMessage_MsgSerialNotIncremented( ProtocolMessage.MessageAction messageAction) { // Arrange var client = await GetConnectedClient(); var targetMessage1 = new ProtocolMessage(messageAction, "Test"); var targetMessage2 = new ProtocolMessage(messageAction, "Test"); var targetMessage3 = new ProtocolMessage(messageAction, "Test"); client.ExecuteCommand(SendMessageCommand.Create(targetMessage1)); client.ExecuteCommand(SendMessageCommand.Create(targetMessage2)); client.ExecuteCommand(SendMessageCommand.Create(targetMessage3)); await client.ProcessCommands(); // Assert targetMessage1.MsgSerial.Should().Be(0); targetMessage2.MsgSerial.Should().Be(0); targetMessage3.MsgSerial.Should().Be(0); }
public async Task WhenMessageReceived_ForceDisconnectNotAppliedAndTimerShouldBeAborted(ProtocolMessage.MessageAction action) { // Arrange var transport = new FakeTransport() { State = TransportState.Initialized }; _context.Transport = transport; // Act await _state.OnAttachToContext(); transport.State = TransportState.Connected; await _state.OnMessageReceived(new ProtocolMessage(action)); // Assert _timer.StartedWithAction.Should().BeTrue(); _timer.Aborted.Should().BeTrue(); }