Exemplo n.º 1
0
        public void GivenConfigurationWithResolvableKeys_and_MultipleValueResolvers_ReturnAttributesWithConcatanatedValues()
        {
            // Arrange
            var contentItem = JObject.Parse(validJsonWithMultipleRelatedKeys);

            var attributesResolver   = new GroupByPrefixTokenGridSettingsAttributesResolver("_");
            var defaultValueResolver = new StringConcatGridSettingValueResolver(" ");
            var valueResolvers       = new Dictionary <string, IGridSettingsAttributeValueResolver>()
            {
                { "data-csv", new StringConcatGridSettingValueResolver(",") },
                { "data-hyphenated", new StringConcatGridSettingValueResolver("-") }
            };

            var service = new GridSettingsAttributesService(attributesResolver, defaultValueResolver, valueResolvers);

            // Act
            var attributes = service.GetSettingsAttributes(contentItem);

            // Assert
            Assert.IsTrue(attributes.ContainsKey("data-csv"));
            Assert.IsTrue(attributes.ContainsKey("data-hyphenated"));
            Assert.IsTrue(attributes.ContainsKey("data-default"));
            Assert.AreEqual("first,second,third", attributes["data-csv"]);
            Assert.AreEqual("first-second-third", attributes["data-hyphenated"]);
            Assert.AreEqual("first second third", attributes["data-default"]);
        }
Exemplo n.º 2
0
        public void GivenConfigurationWithBlankKeyOrValues_ReturnOnlyValidAttributes()
        {
            // Arrange
            var contentItem = JObject.Parse(validJson);
            var service     = new GridSettingsAttributesService();

            // Act
            var attributes = service.GetSettingsAttributes(contentItem);

            // Assert
            Assert.AreEqual(2, attributes.Count);
        }
Exemplo n.º 3
0
        public void GivenValidConfiguration_ReturnValidAttribute()
        {
            // Arrange
            var contentItem = JObject.Parse(jsonWithBlankValuesAndKeys);
            var service     = new GridSettingsAttributesService();

            // Act
            var attributes = service.GetSettingsAttributes(contentItem);

            // Assert
            Assert.AreEqual(2, attributes.Count);
        }
Exemplo n.º 4
0
        public void GivenConfigurationWithResolvableKeys_and_NoAttributeResolver_ReturnAttributesWithoutConcatanatedValues()
        {
            // Arrange
            var contentItem = JObject.Parse(validJsonWithRelatedKeys);

            var service = new GridSettingsAttributesService();

            // Act
            var attributes = service.GetSettingsAttributes(contentItem);

            // Assert
            Assert.AreEqual(3, attributes.Count);
        }
Exemplo n.º 5
0
        public void GivenConfigurationWithoutResolvableKeys_and_AnAttributeResolver_ReturnAttributes()
        {
            // Arrange
            var contentItem = JObject.Parse(validJson);

            var attributesResolver = new GroupByPrefixTokenGridSettingsAttributesResolver("_");
            var service            = new GridSettingsAttributesService(attributesResolver);

            // Act
            var attributes = service.GetSettingsAttributes(contentItem);

            // Assert
            Assert.AreEqual(2, attributes.Count);
        }
Exemplo n.º 6
0
        public void GivenConfigurationWithResolvableKeys_and_CsvValueResolver_ReturnAttributesWithCsvConcatanatedValues()
        {
            // Arrange
            var contentItem = JObject.Parse(validJsonWithRelatedKeysAndCsv);

            var attributesResolver   = new GroupByPrefixTokenGridSettingsAttributesResolver("_");
            var defaultValueResolver = new StringConcatGridSettingValueResolver(",");
            var service = new GridSettingsAttributesService(attributesResolver, defaultValueResolver);

            // Act
            var attributes = service.GetSettingsAttributes(contentItem);

            // Assert
            Assert.IsTrue(attributes.ContainsKey("data-csv"));
            Assert.AreEqual("first,second,third", attributes["data-csv"]);
        }