Example #1
0
 /// <summary>
 /// Convert a <see cref="string"/> to an <see cref="Color"/>.
 /// </summary>
 /// <param name="toConvert">The <see cref="string"/> to convert</param>
 /// <returns>The converted <see cref="string"/></returns>
 /// <exception cref="ArgumentNullException">If <see cref="null"/> is passed</exception>
 public override Color Convert(string toConvert)
 {
     if (toConvert is null)
     {
         throw new ArgumentNullException(nameof(toConvert));
     }
     return(ColourMap.GetColourFor(toConvert));
 }
Example #2
0
        public void ColourConverter_ConvertSupportedCode_Succeeds()
        {
            IConverter <string, Color> converter = new ColourConverter();

            foreach (string code in ColourMap.GetAllCodes())
            {
                Color colour = converter.Convert(code);

                Assert.AreEqual(ColourMap.GetColourFor(code), colour);
            }
        }