public void ShouldParseValidColors(string raw, Color color) { var success = ImageParamsParser.ParseColor(raw, out var res); Assert.IsTrue(success); Assert.AreEqual(color, res); }
public FileContentResult GetImage(int width, int height, string bgColor, string textColor) { var key = $"{width}-{height}-{bgColor}-{textColor}"; byte[] image; if (!_cache.TryGetValue(key, out image)) { var imageDescriptions = ImageParamsParser.Parse(width, height, bgColor, textColor); var ms = _imageGenerator.GenerateImage(imageDescriptions); image = ms; var cacheEntryOptions = new MemoryCacheEntryOptions() .SetSlidingExpiration(TimeSpan.FromHours(8)); _cache.Set(key, image, cacheEntryOptions); } return(File(image, "image/png")); }