Esempio n. 1
0
 public void ColorConversion()
 {
     Assert.Multiple(() =>
     {
         Assert.AreEqual(Color.FromArgb(0xff, 0xff, 0xff), ColorExtension.FromHexa("ffffff"));
         Assert.AreEqual(Color.FromArgb(0x00, 0x00, 0x00), ColorExtension.FromHexa("000000"));
         Assert.AreEqual(Color.FromArgb(0x12, 0x34, 0x56), ColorExtension.FromHexa("123456"));
         Assert.AreEqual(Color.FromArgb(0x52, 0xf4, 0xe2), ColorExtension.FromHexa("52f4e2"));
         Assert.AreEqual(Color.FromArgb(0xb1, 0xc1, 0xd8), ColorExtension.FromHexa("b1c1d8"));
         Assert.AreEqual(Color.FromArgb(0x42, 0x42, 0x42), ColorExtension.FromHexa("424242"));
         Assert.Throws <ArgumentException>(() => { ColorExtension.FromHexa("#424242"); });
         Assert.Throws <ArgumentException>(() => { ColorExtension.FromHexa("42z242"); });
         Assert.Throws <ArgumentException>(() => { ColorExtension.FromHexa("4242424"); });
         Assert.Throws <ArgumentException>(() => { ColorExtension.FromHexa("424242-"); });
     });
 }