Beispiel #1
0
        public void DefaultConstructor()
        {
            var lu = new CSSLengthUnit();

            Assert.AreEqual(0, lu.Units);
            Assert.AreEqual(CSSUnit.None, lu.UnitCategory);
        }
Beispiel #2
0
        public void ToStringTest()
        {
            var units        = r.Next(-15, 15, 0);
            var unitCategory = EnumHelpers.GetRandomValue <CSSUnit>(CSSUnit.None);
            var lu           = new CSSLengthUnit(units, unitCategory);
            var expected     = $"{units}{CSSUnitTypeAttribute.GetUnitSuffix<CSSUnit>(unitCategory)}";

            Assert.AreEqual(expected, lu.ToString());
        }
Beispiel #3
0
        public void ConstructorComponents()
        {
            var units        = r.Next(-15, 15, 0);
            var unitCategory = EnumHelpers.GetRandomValue <CSSUnit>();
            var lu           = new CSSLengthUnit(units, unitCategory);

            Assert.AreEqual(units, lu.Units);
            Assert.AreEqual(unitCategory, lu.UnitCategory);
        }
Beispiel #4
0
        public void ConstructorString()
        {
            var units        = r.Next(-15, 15, 0);
            var unitCategory = EnumHelpers.GetRandomValue <CSSUnit>(CSSUnit.None);
            var input        = $"{units}{CSSUnitTypeAttribute.GetUnitSuffix<CSSUnit>(unitCategory)}";
            var lu           = new CSSLengthUnit(input);

            Assert.AreEqual(units, lu.Units);
            Assert.AreEqual(unitCategory, lu.UnitCategory);
        }
Beispiel #5
0
        public void WidthCustom()
        {
            var propertyIndex = 1;
            var expectedValue = new CSSLengthUnit(r.Next(1, 99), CSSUnit.Percent);

            var src = new RootOptions {
                Width = expectedValue
            };
            var so = PopulateOptions(src);

            AssertPopulatedProperty(so, propertyIndex, expectedValue.ToString());
        }
        public void BorderWidthCustom()
        {
            var propertyIndex = 4;
            var expectedValue = new CSSLengthUnit(r.Next(10, 24), CSSUnit.Points);

            var src = new SuggestedActionsOptions {
                BorderWidth = expectedValue
            };
            var so = PopulateOptions(src);

            AssertPopulatedProperty(so, propertyIndex, expectedValue.ToString());
        }
        public void BorderRadiusCustom()
        {
            var propertyIndex = 2;
            var expectedValue = new CSSLengthUnit(r.Next(10, 24), CSSUnit.Points);;

            var src = new SuggestedActionsOptions {
                BorderRadius = expectedValue
            };
            var so = PopulateOptions(src);

            AssertPopulatedProperty(so, propertyIndex, expectedValue);
        }
        public void BorderWidthCustom()
        {
            var propertyIndex = 5;
            var expectedValue = new CSSLengthUnit(r.Next(0, 5, BubbleOptions.Defaults.BorderWidth.Units), CSSUnit.Pixels);

            var src = new BubbleOptions {
                BorderWidth = expectedValue
            };
            var so = PopulateOptions(src);

            AssertPopulatedProperty(so, propertyIndex, expectedValue);
        }
        public void BorderRadiusCustom()
        {
            var units = r.Next(5, 15,
                               AvatarCommonOptions.Defaults.BorderRadius.Units / 5);
            var expectedRaw = new CSSLengthUnit($"'{units * 5}%'");
            var aa          = new AvatarCommonOptions {
                BorderRadius = expectedRaw
            };
            var so = PopulateOptions(aa);

            Assert.AreEqual(
                expectedRaw.ToString(),
                so[propertyNames[0]]);
        }
Beispiel #10
0
        public void TryParseTest()
        {
            var units        = r.Next(-15, 15, 0);
            var unitCategory = EnumHelpers.GetRandomValue <CSSUnit>(CSSUnit.None);
            var input        = $"{units}{CSSUnitTypeAttribute.GetUnitSuffix<CSSUnit>(unitCategory)}";

            var value = CSSLengthUnit.TryParse(input, out CSSLengthUnit lu);

            Assert.AreEqual(units, lu.Units);
            Assert.AreEqual(unitCategory, lu.UnitCategory);
            Assert.IsTrue(value);

            input += "invalid";
            value  = CSSLengthUnit.TryParse(input, out _);
            Assert.IsFalse(value);
        }
Beispiel #11
0
        public void ParseTest()
        {
            var units        = r.Next(-15, 15, 0);
            var unitCategory = EnumHelpers.GetRandomValue <CSSUnit>(CSSUnit.None);
            var input        = $"{units}{CSSUnitTypeAttribute.GetUnitSuffix<CSSUnit>(unitCategory)}";
            var lu           = CSSLengthUnit.Parse(input);

            Assert.AreEqual(units, lu.Units);
            Assert.AreEqual(unitCategory, lu.UnitCategory);

            input = $"invalid{input}invalid";
            Assert.ThrowsException <ArgumentException>(
                () =>
            {
                lu = CSSLengthUnit.Parse(input);
            }, $"Expected exception from invalid input: {input}");
        }