Ejemplo n.º 1
0
        public void GetAll()
        {
            // Should be any actual implementation
            var tags   = new CommonTags();
            var values = new[]
            {
                "v1.0", "Test", "value 1", "value 2"
            };

            tags.Version     = values[0];
            tags.Environment = values[1];

            tags.SetTag("sample.1", values[2]);
            tags.SetTag("sample.2", values[3]);

            ValidateTags(tags.GetAllTags(), values);
        }
Ejemplo n.º 2
0
        public void SetTag_WillNotCauseDuplicates()
        {
            // Initialize common tags
            var tags = new CommonTags()
            {
                Version     = "v1.0",
                Environment = "Test"
            };

            // Initialize custom tags
            tags.SetTag("sample.1", "Temp 1");
            tags.SetTag("sample.2", "Temp 2");

            // Try set existing tag
            tags.SetTag(Tags.Version, "v2.0");
            tags.SetTag("sample.2", "Temp 3");

            var all          = tags.GetAllTags();
            var distinctKeys = all.Select(x => x.Key).Distinct().Count();

            Assert.Equal(all.Count, distinctKeys);
            Assert.Single(all, x => x.Key == Tags.Version && x.Value == "v2.0");
            Assert.Single(all, x => x.Key == "sample.2" && x.Value == "Temp 3");
        }