|
| 1 | +using Microsoft.VisualStudio.TestTools.UnitTesting; |
| 2 | +using System.Collections.Generic; |
| 3 | + |
| 4 | +namespace Polished.Tests.Mixins |
| 5 | +{ |
| 6 | + [TestClass] |
| 7 | + public class RadialGradient |
| 8 | + { |
| 9 | + private readonly IMixins _mixins = new Polished.Mixins(); |
| 10 | + |
| 11 | + [TestMethod] |
| 12 | + public void TwoColorStops() |
| 13 | + { |
| 14 | + string actual = _mixins.RadialGradient(new RadialGradientConfiguration { ColorStops = new List<string> { "#fff", "#000" } }); |
| 15 | + string expected = "background-color:#fff;background-image:radial-gradient(#fff, #000);"; |
| 16 | + Assert.AreEqual(expected, actual); |
| 17 | + } |
| 18 | + |
| 19 | + [TestMethod] |
| 20 | + public void ExtentShapeAndPosition() |
| 21 | + { |
| 22 | + string actual = _mixins.RadialGradient(new RadialGradientConfiguration |
| 23 | + { |
| 24 | + ColorStops = new List<string> { "#00FFFF 0%", "rgba(0, 0, 255, 0) 50%", "#0000FF 95%" }, |
| 25 | + Extent = "farthest-corner at 45px 45px", |
| 26 | + Position = "center", |
| 27 | + Shape = "ellipse" |
| 28 | + }); |
| 29 | + string expected = "background-color:#00FFFF;background-image:radial-gradient(center ellipse farthest-corner at 45px 45px, #00FFFF 0%, rgba(0, 0, 255, 0) 50%, #0000FF 95%);"; |
| 30 | + Assert.AreEqual(expected, actual); |
| 31 | + } |
| 32 | + |
| 33 | + [TestMethod] |
| 34 | + public void ExtentAndShape() |
| 35 | + { |
| 36 | + string actual = _mixins.RadialGradient(new RadialGradientConfiguration |
| 37 | + { |
| 38 | + ColorStops = new List<string> { "#00FFFF 0%", "rgba(0, 0, 255, 0) 50%", "#0000FF 95%" }, |
| 39 | + Extent = "farthest-corner at 45px 45px", |
| 40 | + Shape = "ellipse" |
| 41 | + }); |
| 42 | + string expected = "background-color:#00FFFF;background-image:radial-gradient(ellipse farthest-corner at 45px 45px, #00FFFF 0%, rgba(0, 0, 255, 0) 50%, #0000FF 95%);"; |
| 43 | + Assert.AreEqual(expected, actual); |
| 44 | + } |
| 45 | + |
| 46 | + [TestMethod] |
| 47 | + public void Extent() |
| 48 | + { |
| 49 | + string actual = _mixins.RadialGradient(new RadialGradientConfiguration |
| 50 | + { |
| 51 | + ColorStops = new List<string> { "#00FFFF 0%", "rgba(0, 0, 255, 0) 50%", "#0000FF 95%" }, |
| 52 | + Extent = "farthest-corner at 45px 45px" |
| 53 | + }); |
| 54 | + string expected = "background-color:#00FFFF;background-image:radial-gradient(farthest-corner at 45px 45px, #00FFFF 0%, rgba(0, 0, 255, 0) 50%, #0000FF 95%);"; |
| 55 | + Assert.AreEqual(expected, actual); |
| 56 | + } |
| 57 | + |
| 58 | + [TestMethod] |
| 59 | + public void ExtentAndFallback() |
| 60 | + { |
| 61 | + string actual = _mixins.RadialGradient(new RadialGradientConfiguration |
| 62 | + { |
| 63 | + ColorStops = new List<string> { "#00FFFF 0%", "rgba(0, 0, 255, 0) 50%", "#0000FF 95%" }, |
| 64 | + Extent = "farthest-corner at 45px 45px", |
| 65 | + Fallback = "#FFF" |
| 66 | + }); |
| 67 | + string expected = "background-color:#FFF;background-image:radial-gradient(farthest-corner at 45px 45px, #00FFFF 0%, rgba(0, 0, 255, 0) 50%, #0000FF 95%);"; |
| 68 | + Assert.AreEqual(expected, actual); |
| 69 | + } |
| 70 | + |
| 71 | + [TestMethod] |
| 72 | + public void ThrowsIfColorStopsAreNull() |
| 73 | + { |
| 74 | + Assert.ThrowsException<PolishedException>( |
| 75 | + () => _mixins.RadialGradient(null, null, null, null, null) |
| 76 | + ); |
| 77 | + |
| 78 | + } |
| 79 | + |
| 80 | + [TestMethod] |
| 81 | + public void ThrowsIfColorStopsAreLessThan2() |
| 82 | + { |
| 83 | + Assert.ThrowsException<PolishedException>( |
| 84 | + () => _mixins.RadialGradient(new List<string> { "#fff" }, null, null, null, null) |
| 85 | + ); |
| 86 | + } |
| 87 | + } |
| 88 | +} |
0 commit comments