示例#1
0
        public void should_get_binding_key_parts_for_member()
        {
            // Arrange
            var bindingKeys = new[]
            {
                Subscription.Matching <StrangeRoutableMessage>(x => x.Id == 123).BindingKey,
                Subscription.Matching <StrangeRoutableMessage>(x => x.Code == "456").BindingKey,
                Subscription.Matching <StrangeRoutableMessage>(x => x.Id == 123 && x.Code == "456").BindingKey,
                Subscription.Any <StrangeRoutableMessage>().BindingKey,
            };

            // Act
            var partsForId   = BindingKeyUtil.GetPartsForMember(MessageUtil.TypeId <StrangeRoutableMessage>(), nameof(StrangeRoutableMessage.Id), bindingKeys);
            var partsForCode = BindingKeyUtil.GetPartsForMember(MessageUtil.TypeId <StrangeRoutableMessage>(), nameof(StrangeRoutableMessage.Code), bindingKeys);

            // Assert
            partsForId.ShouldBeEquivalentTo(BindingKeyPart.Parse("123"), BindingKeyPart.Star, BindingKeyPart.Parse("123"), BindingKeyPart.Star);
            partsForCode.ShouldBeEquivalentTo(BindingKeyPart.Star, BindingKeyPart.Parse("456"), BindingKeyPart.Parse("456"), BindingKeyPart.Star);
        }
 public IReadOnlyList <BindingKeyPart> GetBindingKeyPartsForMember(string memberName)
 => BindingKeyUtil.GetPartsForMember(MessageTypeId, memberName, BindingKeys).ToList();