public Tuple<string, string> Process(CssParser.StyleClass styleClass)
        {
            string value;
            if (styleClass.Attributes.TryGetValue("background-color", out value))
            {
                var result = rgbRegex.Match(value);
                if (result.Success)
                {
                    var numbers = digitRegex.Matches(value);

                    var first = numbers[0].Value;
                    var second = numbers[1].Value;
                    var third = numbers[2].Value;

                    // TODO: detect opacity values

                    var outputValue = string.Format("#FF{0}{1}{2}", first.AsHexValue(), second.AsHexValue(), third.AsHexValue());
                    return new Tuple<string, string>(BackgroundKey, outputValue);
                }
            }

            styleClass.Attributes.TryGetValue("background", out value);

            if (hexRegex.IsMatch(value))
            {
                var outputValue = value.ToUpper().Replace("#", "#FF");
                return new Tuple<string, string>(BackgroundKey, outputValue);
            }

            return new Tuple<string, string>(BackgroundKey, value.ToTitleCase());
        }
 public CssProcessor(CssParser process, BackgroundMapper mapper)
 {
     this.process = process;
     this.mapper = mapper;
 }
 public void Parse_WithMultipleValues_UsesLastValue()
 {
     var parser = new CssParser();
     var result = parser.Parse("foo { key: thing; key: another-thing; }");
     Assert.Equal("another-thing", result.First().Attributes["key"]);
 }
 public void Parse_WithEmptyValue_ReturnsEmptyResourcesSet()
 {
     var parser = new CssParser();
     var result = parser.Parse("");
     Assert.Empty(result);
 }
 public void Parse_WithAClassAndNoContents_ReturnsOneItem()
 {
     var parser = new CssParser();
     var result = parser.Parse("foo { }");
     Assert.NotEmpty(result);
 }
 public bool IsMatch(CssParser.StyleClass styleClass)
 {
     return styleClass.Attributes.Any(t => t.Key.StartsWith("background"));
 }