Пример #1
0
        public static void FromHex_GivenFullHexWithoutHashPrefix_ReturnsCorrectRgbColor()
        {
            var rgb    = new Rgb(12, 34, 56);
            var hexRgb = Rgb.FromHex("0C2238");

            Assert.AreEqual(rgb, hexRgb);
        }
Пример #2
0
        public void CanConvertHex()
        {
            var color = Rgb.FromHex("#FF00FF");

            Assert.AreEqual(new Rgb(255, 0, 255), color);
            Assert.AreEqual("FF00FF", color.Hex);
        }
Пример #3
0
        public static void FromHex_GivenShortHexWithoutHashPrefix_ReturnsCorrectRgbColor()
        {
            var rgb    = new Rgb(51, 68, 85);
            var hexRgb = Rgb.FromHex("345");

            Assert.AreEqual(rgb, hexRgb);
        }
Пример #4
0
        public static void FromHex_GivenValidShortHex_ReturnsCorrectRgbColor()
        {
            var rgb    = new Rgb(51, 68, 85);
            var hexRgb = Rgb.FromHex("#345");

            Assert.AreEqual(rgb, hexRgb);
        }
        public async Task ReducesSaturation()
        {
            var color    = new Rgb(0, 255, 0);
            var filter   = new BlackWhite();
            var newColor = await filter.ApplyFilter(color);

            Assert.AreEqual(Rgb.FromHex("BFFFBF"), newColor);
        }
Пример #6
0
 public static void FromHex_GivenTooShortString_ThrowsArgException()
 {
     Assert.Multiple(() =>
     {
         Assert.Throws <ArgumentException>(() => Rgb.FromHex("12"));
         Assert.Throws <ArgumentException>(() => Rgb.FromHex("#12"));
     });
 }
 private void Init()
 {
     Sides = new[]
     {
         new Solid(Rgb.FromHex(_colorConfiguration.LeftOrSingle)),
         new Solid(Rgb.FromHex(_colorConfiguration.Center)),
         new Solid(Rgb.FromHex(_colorConfiguration.Right))
     };
 }
Пример #8
0
 public static void FromHex_GivenEmptyHexString_ThrowsArgNullException()
 {
     Assert.Multiple(() =>
     {
         Assert.Throws <ArgumentNullException>(() => Rgb.FromHex(null));
         Assert.Throws <ArgumentNullException>(() => Rgb.FromHex(string.Empty));
         Assert.Throws <ArgumentNullException>(() => Rgb.FromHex("   "));
     });
 }
Пример #9
0
        public void TestSolidColor()
        {
            var side = new Solid(Rgb.FromHex("FFFFFF"))
            {
                Led = _fixtureFile
            };

            side.Load().Wait();
            side.Commit(new IFilter[] { });
            Assert.AreEqual("FFFFFF", side.Led.Contents);
        }
Пример #10
0
        public void RegressionCanConvertRed()
        {
            var red = new Rgb(255, 0, 0);
            var hsb = new Hsb(red).SetBrightness(1);

            Assert.AreEqual(red, new Rgb(hsb));

            var h173  = new Hsb(173 / 360D, 1, 1);
            var color = new Rgb(h173);

            Assert.AreEqual(Rgb.FromHex("00FFE1"), color);
        }
Пример #11
0
        public async Task FadeIn()
        {
            var monitor = GetMonitor();

            monitor.Reading = 100;

            var filter = new PowerFilter(new FakeContainer(), monitor);
            await filter.PreApply(0);

            var color = await filter.ApplyFilter(Rgb.FromHex("FFFFFF"));

            Assert.AreEqual(Rgb.FromHex("000000"), color);
        }
Пример #12
0
        public static void FromHex_GivenIncorrectLengthString_ThrowsArgException()
        {
            Assert.Multiple(() =>
            {
                // > 3 but < 6
                Assert.Throws <ArgumentException>(() => Rgb.FromHex("1234"));
                Assert.Throws <ArgumentException>(() => Rgb.FromHex("#1234"));

                // >6
                Assert.Throws <ArgumentException>(() => Rgb.FromHex("1234567"));
                Assert.Throws <ArgumentException>(() => Rgb.FromHex("#1234567"));
            });
        }
Пример #13
0
        public async Task ProperlyTransitions()
        {
            var monitor = GetMonitor();

            monitor.Reading = 100;

            var filter = new PowerFilter(new FakeContainer(), monitor);
            var color  = Rgb.Empty;

            foreach (var i in Enumerable.Range(1, 2))
            {
                await Task.Delay(1000);

                await monitor.CheckForChanges();

                await filter.PreApply(0);

                color = await filter.ApplyFilter(Rgb.FromHex("FFFFFF"));
            }

            Assert.AreEqual(Rgb.FromHex("FFFFFF"), color);

            monitor.Reading = 0;

            foreach (var i in Enumerable.Range(1, 2))
            {
                await Task.Delay(1000);

                await monitor.CheckForChanges();

                await filter.PreApply(0);

                color = await filter.ApplyFilter(Rgb.FromHex("FFFFFF"));
            }

            Assert.AreEqual(Rgb.FromHex("000000"), color);
        }