public void when_getting_explicit_client_flow_from_type_then_succeeds() { ClientProtocolFlowProvider flowProvider = new ClientProtocolFlowProvider(Mock.Of <IMqttTopicEvaluator>(), Mock.Of <IRepositoryProvider>(), new MqttConfiguration()); ClientConnectFlow connectFlow = flowProvider.GetFlow <ClientConnectFlow>(); PublishSenderFlow senderFlow = flowProvider.GetFlow <PublishSenderFlow>(); PublishReceiverFlow receiverFlow = flowProvider.GetFlow <PublishReceiverFlow>(); ClientSubscribeFlow subscribeFlow = flowProvider.GetFlow <ClientSubscribeFlow>(); ClientUnsubscribeFlow unsubscribeFlow = flowProvider.GetFlow <ClientUnsubscribeFlow>(); PingFlow disconnectFlow = flowProvider.GetFlow <PingFlow>(); Assert.NotNull(connectFlow); Assert.NotNull(senderFlow); Assert.NotNull(receiverFlow); Assert.NotNull(subscribeFlow); Assert.NotNull(unsubscribeFlow); Assert.NotNull(disconnectFlow); }
public async Task when_sending_ping_request_then_ping_response_is_sent() { string clientId = Guid.NewGuid().ToString(); Mock <IMqttChannel <IPacket> > channel = new Mock <IMqttChannel <IPacket> >(); IPacket sentPacket = default; channel.Setup(c => c.SendAsync(It.IsAny <IPacket>())) .Callback <IPacket>(packet => sentPacket = packet) .Returns(Task.Delay(0)); PingFlow flow = new PingFlow(); await flow.ExecuteAsync(clientId, new PingRequest(), channel.Object); PingResponse pingResponse = sentPacket as PingResponse; Assert.NotNull(pingResponse); MqttPacketType.PingResponse.Should().Be(pingResponse.Type); }
public async Task when_sending_ping_request_then_ping_response_is_sent() { var clientId = Guid.NewGuid().ToString(); var channel = new Mock <IMqttChannel <IPacket> > (); var sentPacket = default(IPacket); channel.Setup(c => c.SendAsync(It.IsAny <IPacket> ())) .Callback <IPacket> (packet => sentPacket = packet) .Returns(Task.Delay(0)); var flow = new PingFlow(); await flow.ExecuteAsync(clientId, new PingRequest(), channel.Object) .ConfigureAwait(continueOnCapturedContext: false); var pingResponse = sentPacket as PingResponse; Assert.NotNull(pingResponse); Assert.Equal(MqttPacketType.PingResponse, pingResponse.Type); }