Exemplo n.º 1
0
        public void PropertySetter_SetLength(string unit, float length)
        {
            var applicationOptions = OptionsMocks.CreateApplicationOptions();
            var propertySetter     = new PropertySetter(applicationOptions);
            var component          = ComponentMocks.CreateComponent <BasicTemplatelessComponent>();

            component.Name = "TestComponent";

            var propertyValue = new LengthPropertyValue(unit, length);

            propertySetter.SetValue(component, nameof(BasicTemplatelessComponent.Length), propertyValue);

            Assert.Equal(unit == "%", component.Length[UnitType.Percentage] != 0);
            Assert.Equal(unit == "px", component.Length[UnitType.Pixel] != 0);
            Assert.Equal(unit == "x", component.Length[UnitType.Ratio] != 0);
            Assert.Equal(unit == "u", component.Length[UnitType.Unit] != 0);
        }
        private static RelativeLength ToRelativeLength(LengthPropertyValue value)
        {
            var args = value.Units.Select(x => new RelativeLength(value[x], ToUnitType(x))).ToArray();

            return(args.Sum());
        }