コード例 #1
0
        public void GetTags_NoAccessorSetup_ReturnsNull()
        {
            // Arrange
            var mapping = new ComponentMapping <EventHubNamespace>(null);

            // Act
            var tags = mapping.GetTags(new EventHubNamespace());

            // Assert
            Assert.Null(tags);
        }
コード例 #2
0
        public void GetTags_WithTagAccessorButNullInObject_ReturnsNull()
        {
            // Arrange
            var mapping = new ComponentMapping <EventHubNamespace>(null)
                          .WithTags(enh => enh.Tags);

            var obj = new EventHubNamespace();

            // Act
            var tags = mapping.GetTags(obj);

            // Assert
            Assert.Null(tags);
        }
コード例 #3
0
        public void GetTags_WithTagAccessor_ReturnsTags()
        {
            // Arrange
            var mapping = new ComponentMapping <EventHubNamespace>(null)
                          .WithTags(enh => enh.Tags);

            var obj = new EventHubNamespace
            {
                Tags = new List <string>
                {
                    "value1",
                    "value2"
                }
            };

            // Act
            var tags = mapping.GetTags(obj);

            // Assert
            Assert.Equal(2, tags.Count());
            Assert.Contains("value1", tags);
            Assert.Contains("value2", tags);
        }
コード例 #4
0
        public void GetTags_WithTagGetterDefined_GetsExpectedTags()
        {
            // Arrange
            var mapping = new ComponentMapping <EventHubNamespace>(null)
                          .WithTags(Tags.FromExpression <EventHubNamespace>(ns => ns.TagMap.Select(p => $"{p.Key}::{p.Value}")));

            var eh = new EventHubNamespace
            {
                TagMap = new Dictionary <string, string>
                {
                    ["a"] = "b",
                    ["c"] = "d"
                }
            };

            // Act
            var tags = mapping.GetTags(eh);

            // Assert
            Assert.Equal(2, tags.Count());
            Assert.Contains("a::b", tags);
            Assert.Contains("c::d", tags);
        }