public void TestDeviceAllowedMessages([NotNull] Dictionary <Type, uint> aExpectedMessageArgs) { Clear(); // If we've updated a class with new messages, but haven't updated the device, fail. Assert.AreEqual(aExpectedMessageArgs.Count, bleDevice.GetAllowedMessageTypes().Count()); foreach (var item in aExpectedMessageArgs) { Assert.True(bleDevice.GetAllowedMessageTypes().Contains(item.Key)); Assert.NotNull(bleDevice.GetMessageAttrs(item.Key)); if (item.Value == 0) { Assert.Null(bleDevice.GetMessageAttrs(item.Key).FeatureCount); } else { Assert.AreEqual(item.Value, bleDevice.GetMessageAttrs(item.Key).FeatureCount); } } }
GetAllowedMessageTypesAsDictionary([NotNull] IButtplugDevice aDevice) { Dictionary <string, MessageAttributes> msgs = new Dictionary <string, MessageAttributes>(); foreach (var msg in aDevice.GetAllowedMessageTypes()) { msgs.Add(msg.Name, aDevice.GetMessageAttrs(msg)); } return(msgs); }
private static IEnumerable <string> GetAllowedMessageTypesAsStrings([NotNull] IButtplugDevice aDevice) { return(from x in aDevice.GetAllowedMessageTypes() select x.Name); }