From 3e4d9603c01bf22c960b1c1cc9a5e5495904c358 Mon Sep 17 00:00:00 2001 From: Oliver Booth Date: Tue, 28 Mar 2023 15:54:06 +0100 Subject: [PATCH] test: cover Color.Deconstruct --- X10D.Tests/src/Drawing/ColorTests.cs | 48 ++++++++++++++++++++++++++++ 1 file changed, 48 insertions(+) diff --git a/X10D.Tests/src/Drawing/ColorTests.cs b/X10D.Tests/src/Drawing/ColorTests.cs index d673af4..a7ecec9 100644 --- a/X10D.Tests/src/Drawing/ColorTests.cs +++ b/X10D.Tests/src/Drawing/ColorTests.cs @@ -16,6 +16,54 @@ public class ColorTests private static readonly Color Magenta = Color.FromArgb(255, 0, 255); private static readonly Color Yellow = Color.FromArgb(255, 255, 0); + [TestMethod] + public void Deconstruct_ShouldDeconstructColor_GivenColor() + { + (byte r, byte g, byte b) = Black; + Assert.AreEqual(0, r); + Assert.AreEqual(0, g); + Assert.AreEqual(0, b); + + (byte a, r, g, b) = Black; + Assert.AreEqual(255, a); + Assert.AreEqual(0, r); + Assert.AreEqual(0, g); + Assert.AreEqual(0, b); + + (r, g, b) = Red; + Assert.AreEqual(255, r); + Assert.AreEqual(0, g); + Assert.AreEqual(0, b); + + (a, r, g, b) = Red; + Assert.AreEqual(255, a); + Assert.AreEqual(255, r); + Assert.AreEqual(0, g); + Assert.AreEqual(0, b); + + (r, g, b) = Green; + Assert.AreEqual(0, r); + Assert.AreEqual(255, g); + Assert.AreEqual(0, b); + + (a, r, g, b) = Green; + Assert.AreEqual(255, a); + Assert.AreEqual(0, r); + Assert.AreEqual(255, g); + Assert.AreEqual(0, b); + + (r, g, b) = Blue; + Assert.AreEqual(0, r); + Assert.AreEqual(0, g); + Assert.AreEqual(255, b); + + (a, r, g, b) = Blue; + Assert.AreEqual(255, a); + Assert.AreEqual(0, r); + Assert.AreEqual(0, g); + Assert.AreEqual(255, b); + } + [TestMethod] public void GetClosestConsoleColor_ShouldReturnClosestColor_GivenValidColor() {