public void AddRemoveItemDoesNotFireTimeoutEvent() { MqttProtocolInformation.Settings.NetworkTimeout = 4; // 4 seconds var store = new MessageStore(); var are = new AutoResetEvent(false); var eventData = "Test data"; string connectionKey = "123"; var msg = new MqttPublishMessageBuilder { MessageId = 42, QualityOfService = QualityOfService.AtLeastOnce, TopicName = "a/b/c" }; store.MessageTimeout += (sender, args) => { Assert.Fail("MessageTimeout event fired but should not have."); are.Set(); }; store.Add(msg.GetMessage(), eventData, connectionKey); Thread.Sleep(1000); store.Remove(MessageType.PubAck, 42, connectionKey); if (!are.WaitOne(MqttProtocolInformation.Settings.NetworkTimeout*2)) { Assert.AreEqual(0, store.Count); } }
public void RemoveItemReturnsEventData() { MqttProtocolInformation.Settings.NetworkTimeout = 4; // 4 seconds var store = new MessageStore(); var eventData = "Test data"; string connectionKey = "123"; var msg = new MqttPublishMessageBuilder { MessageId = 42, QualityOfService = QualityOfService.AtLeastOnce, TopicName = "a/b/c" }; store.Add(msg.GetMessage(), eventData, connectionKey); Thread.Sleep(1000); object testData = store.Remove(MessageType.PubAck, 42, connectionKey); Assert.AreSame(eventData, testData); }