public void ConvertFrom()
    {
        var converter = new InterlockColorConverter();

        ConvertFromStringAndAssert(converter, "Aqua", InterlockColor.Aqua);
        ConvertFromStringAndAssert(converter, "Aqua ", InterlockColor.Aqua);
        ConvertFromStringAndAssert(converter, "aqua", InterlockColor.Aqua);
        ConvertFromStringAndAssert(converter, "#00ffff", InterlockColor.Aqua);
        ConvertFromStringAndAssert(converter, "#00ffff80", InterlockColor.Aqua.WithA(128));
        ConvertFromStringAndAssert(converter, "#00ffFF", InterlockColor.Aqua);
        ConvertFromStringAndAssert(converter, "#00ffff  ", InterlockColor.Aqua);
        ConvertFromStringAndAssert(converter, "SlateGray", InterlockColor.SlateGray);
        ConvertFromStringAndAssert(converter, "slategray", InterlockColor.SlateGray);
        ConvertFromStringAndAssert(converter, "slateGray", InterlockColor.SlateGray);
        ConvertFromStringAndAssert(converter, "SLATEGRAY", InterlockColor.SlateGray);
        ConvertFromStringAndAssert(converter, "#00QQff", InterlockColor.Transparent);
        ConvertFromStringAndAssert(converter, "Transparent", InterlockColor.Transparent);
        ConvertFromStringAndAssert(converter, "#FFFFFF00", InterlockColor.Transparent);
        ConvertFromStringAndAssert(converter, "Zany", InterlockColor.Transparent);
        ConvertFromStringAndAssert(converter, string.Empty, InterlockColor.Transparent);
        ConvertFromStringAndAssert(converter, "#010203", new InterlockColor(1, 2, 3));
        ConvertFromStringAndAssert(converter, "#01020300", new InterlockColor(1, 2, 3, a: 0));
        ConvertFromStringAndAssert(converter, "#01020380", new InterlockColor(1, 2, 3, a: 128));
        ConvertFromStringAndAssert(converter, "#010203", InterlockColor.From(0x010203FF));
        ConvertFromStringAndAssert(converter, "#010203FF", InterlockColor.From(0x010203FF));
        ConvertFromStringAndAssert(converter, "#01020300", InterlockColor.From(0x01020300));
        ConvertFromStringAndAssert(converter, "#01020380", InterlockColor.From(0x01020380));
        Assert.AreEqual(InterlockColor.Transparent, InterlockColor.FromText(null));
    }
    public void ConvertTo()
    {
        var converter = new InterlockColorConverter();

        ConvertToStringAndAssert(converter, InterlockColor.Aqua);
        ConvertToStringAndAssert(converter, InterlockColor.Transparent);
        ConvertToStringAndAssert(converter, InterlockColor.From(0x01020390));
        ConvertToStringAndAssert(converter, new InterlockColor(1, 2, 3, a: 128));
    }
Ejemplo n.º 3
0
 public static InterlockColor DecodeColor(this Stream s) => InterlockColor.From(s.Decode <ILTagUInt32>().Value);