public PacketChannelFactory(IMqttChannelFactory innerChannelFactory, IMqttTopicEvaluator topicEvaluator, MqttConfiguration configuration) : this(topicEvaluator, configuration) { this.innerChannelFactory = innerChannelFactory; }
protected ProtocolFlowProvider(IMqttTopicEvaluator topicEvaluator, IRepositoryProvider repositoryProvider, MqttConfiguration configuration) { this.topicEvaluator = topicEvaluator; this.repositoryProvider = repositoryProvider; this.configuration = configuration; }
public PublishReceiverFlow(IMqttTopicEvaluator topicEvaluator, IRepository <RetainedMessage> retainedRepository, IRepository <ClientSession> sessionRepository, MqttConfiguration configuration) : base(sessionRepository, configuration) { this.topicEvaluator = topicEvaluator; this.retainedRepository = retainedRepository; }
public void when_writing_invalid_subscribe_packet_then_fails(string jsonPath) { jsonPath = Path.Combine(Environment.CurrentDirectory, jsonPath); IMqttTopicEvaluator topicEvaluator = Mock.Of <IMqttTopicEvaluator>(e => e.IsValidTopicFilter(It.IsAny <string>()) == true); SubscribeFormatter formatter = new SubscribeFormatter(topicEvaluator); Subscribe subscribe = Packet.ReadPacket <Subscribe>(jsonPath); AggregateException ex = Assert.Throws <AggregateException>(() => formatter.FormatAsync(subscribe).Wait()); Assert.True(ex.InnerException is MqttProtocolViolationException); }
public void when_reading_invalid_topic_filter_in_subscribe_packet_then_fails(string packetPath) { packetPath = Path.Combine(Environment.CurrentDirectory, packetPath); IMqttTopicEvaluator topicEvaluator = Mock.Of <IMqttTopicEvaluator>(e => e.IsValidTopicFilter(It.IsAny <string>()) == true); SubscribeFormatter formatter = new SubscribeFormatter(topicEvaluator); byte[] packet = Packet.ReadAllBytes(packetPath); AggregateException ex = Assert.Throws <AggregateException>(() => formatter.FormatAsync(packet).Wait()); Assert.True(ex.InnerException is MqttProtocolViolationException); }
public ServerSubscribeFlow(IMqttTopicEvaluator topicEvaluator, IRepository <ClientSession> sessionRepository, IRepository <RetainedMessage> retainedRepository, IPacketIdProvider packetIdProvider, IPublishSenderFlow senderFlow, MqttConfiguration configuration) { _topicEvaluator = topicEvaluator; _sessionRepository = sessionRepository; _retainedRepository = retainedRepository; _packetIdProvider = packetIdProvider; _senderFlow = senderFlow; _configuration = configuration; }
public ServerProtocolFlowProvider(IMqttAuthenticationProvider authenticationProvider, IConnectionProvider connectionProvider, IMqttTopicEvaluator topicEvaluator, IRepositoryProvider repositoryProvider, IPacketIdProvider packetIdProvider, ISubject <MqttUndeliveredMessage> undeliveredMessagesListener, MqttConfiguration configuration) : base(topicEvaluator, repositoryProvider, configuration) { _authenticationProvider = authenticationProvider; _connectionProvider = connectionProvider; _packetIdProvider = packetIdProvider; _undeliveredMessagesListener = undeliveredMessagesListener; }
public async Task when_writing_publish_packet_then_succeeds(string jsonPath, string packetPath) { jsonPath = Path.Combine(Environment.CurrentDirectory, jsonPath); packetPath = Path.Combine(Environment.CurrentDirectory, packetPath); byte[] expectedPacket = Packet.ReadAllBytes(packetPath); IMqttTopicEvaluator topicEvaluator = Mock.Of <IMqttTopicEvaluator>(e => e.IsValidTopicName(It.IsAny <string>()) == true); PublishFormatter formatter = new PublishFormatter(topicEvaluator); Publish publish = Packet.ReadPacket <Publish>(jsonPath); byte[] result = await formatter.FormatAsync(publish); expectedPacket.Should().BeEquivalentTo(result); }
public async Task when_reading_subscribe_packet_then_succeeds(string packetPath, string jsonPath) { packetPath = Path.Combine(Environment.CurrentDirectory, packetPath); jsonPath = Path.Combine(Environment.CurrentDirectory, jsonPath); Subscribe expectedSubscribe = Packet.ReadPacket <Subscribe>(jsonPath); IMqttTopicEvaluator topicEvaluator = Mock.Of <IMqttTopicEvaluator>(e => e.IsValidTopicFilter(It.IsAny <string>()) == true); SubscribeFormatter formatter = new SubscribeFormatter(topicEvaluator); byte[] packet = Packet.ReadAllBytes(packetPath); IPacket result = await formatter.FormatAsync(packet); expectedSubscribe.Should().Be(result); }
public void when_creating_packet_channel_then_succeeds() { MqttConfiguration configuration = new MqttConfiguration { WaitTimeoutSecs = 1 }; Subject <byte[]> receiver = new Subject <byte[]>(); Mock <IMqttChannel <byte[]> > bufferedChannel = new Mock <IMqttChannel <byte[]> >(); bufferedChannel.Setup(x => x.ReceiverStream).Returns(receiver); IMqttTopicEvaluator topicEvaluator = Mock.Of <IMqttTopicEvaluator>(); PacketChannelFactory factory = new PacketChannelFactory(topicEvaluator, configuration); IMqttChannel <IPacket> channel = factory.Create(bufferedChannel.Object); Assert.NotNull(channel); }
public ServerPublishReceiverFlow(IMqttTopicEvaluator topicEvaluator, IConnectionProvider connectionProvider, IPublishSenderFlow senderFlow, IRepository <RetainedMessage> retainedRepository, IRepository <ClientSession> sessionRepository, IRepository <ConnectionWill> willRepository, IPacketIdProvider packetIdProvider, ISubject <MqttUndeliveredMessage> undeliveredMessagesListener, MqttConfiguration configuration) : base(topicEvaluator, retainedRepository, sessionRepository, configuration) { _connectionProvider = connectionProvider; _senderFlow = senderFlow; _willRepository = willRepository; _packetIdProvider = packetIdProvider; _undeliveredMessagesListener = undeliveredMessagesListener; }
public SubscribeFormatter(IMqttTopicEvaluator topicEvaluator) { this.topicEvaluator = topicEvaluator; }
public PublishFormatter(IMqttTopicEvaluator topicEvaluator) { _topicEvaluator = topicEvaluator; }
public PacketChannelFactory(IMqttTopicEvaluator topicEvaluator, MqttConfiguration configuration) { this.topicEvaluator = topicEvaluator; this.configuration = configuration; }
public ClientProtocolFlowProvider(IMqttTopicEvaluator topicEvaluator, IRepositoryProvider repositoryProvider, MqttConfiguration configuration) : base(topicEvaluator, repositoryProvider, configuration) { }