diff options
author | Bertrand Le Roy <beleroy@microsoft.com> | 2018-09-21 21:48:01 +0300 |
---|---|---|
committer | Bertrand Le Roy <beleroy@microsoft.com> | 2018-09-21 21:48:01 +0300 |
commit | 51e755eded6517f1f2423b02ebeb0d3bfa1d7809 (patch) | |
tree | 44e01f931202d21ca1ddf2d380fe27c7775f1559 /Xamarin.PropertyEditing.Tests | |
parent | 3a99673a4082de39bedc5018857d5f52fea66e1a (diff) |
Add `CommonColor.ToArgbHex`, throw in some additional tests for good measure.
Diffstat (limited to 'Xamarin.PropertyEditing.Tests')
-rw-r--r-- | Xamarin.PropertyEditing.Tests/CommonColorTests.cs | 38 |
1 files changed, 35 insertions, 3 deletions
diff --git a/Xamarin.PropertyEditing.Tests/CommonColorTests.cs b/Xamarin.PropertyEditing.Tests/CommonColorTests.cs index 3038f7d..5ef524a 100644 --- a/Xamarin.PropertyEditing.Tests/CommonColorTests.cs +++ b/Xamarin.PropertyEditing.Tests/CommonColorTests.cs @@ -182,10 +182,42 @@ namespace Xamarin.PropertyEditing.Tests } [Test] - public void ColorToString() + public void ColorToRgba() { - var color = new CommonColor (0x34, 0x56, 0x78, 0x12); - Assert.AreEqual ("#12345678", color.ToString ()); + Assert.AreEqual ("#12345678", new CommonColor (0x12, 0x34, 0x56, 0x78).ToRgbaHex ()); + } + + [Test] + public void ColorToArgb () + { + Assert.AreEqual ("#12345678", new CommonColor (0x34, 0x56, 0x78, 0x12).ToArgbHex ()); + Assert.AreEqual ("#123456", new CommonColor (0x12, 0x34, 0x56).ToArgbHex ()); + } + + [Test] + public void ColorToString () + { + Assert.AreEqual ("#12345678", new CommonColor (0x34, 0x56, 0x78, 0x12).ToString ()); + } + + [Test] + public void ColorParseArgb () + { + CommonColor parsed; + Assert.IsTrue (CommonColor.TryParseArgbHex ("#123", out parsed)); + Assert.AreEqual (new CommonColor (0x11, 0x22, 0x33), parsed); + + Assert.IsTrue (CommonColor.TryParseArgbHex ("#123456", out parsed)); + Assert.AreEqual (new CommonColor (0x12, 0x34, 0x56), parsed); + + Assert.IsTrue (CommonColor.TryParseArgbHex ("#1234", out parsed)); + Assert.AreEqual (new CommonColor (0x22, 0x33, 0x44, 0x11), parsed); + + Assert.IsTrue (CommonColor.TryParseArgbHex ("#12345678", out parsed)); + Assert.AreEqual (new CommonColor (0x34, 0x56, 0x78, 0x12), parsed); + + Assert.IsFalse (CommonColor.TryParseArgbHex ("not a color", out parsed)); + Assert.AreEqual (CommonColor.Black, parsed); } #pragma warning disable CS0659 // Type overrides Object.Equals(object o) but does not override Object.GetHashCode() |