Ejemplo n.º 1
0
        public void CombinatorCombinesAdditionalProperties()
        {
            LineSeriesConfigurator a = new();
            LineSeriesConfigurator b = new();

            Expression <Func <LineSeries, string?> > propertyExpression = ls => ls.LabelFormatString;
            const string format = "ABC";

            a.SetAdditional(propertyExpression, format);

            // Property only set on a
            Combinator <LineSeriesConfigurator> combinator = new(a, b);

            LineSeriesConfigurator combined = combinator.Combine();

            ConfigurableProperty <string>?combinedProperty = combined.AdditionalProperties.Get(propertyExpression);

            Assert.NotNull(combinedProperty);
            Assert.True(combinedProperty !.IsSet);
            Assert.Equal(format, combinedProperty.Value);

            // Property set on a AND b, should take the value from a and ignore b
            b.SetAdditional(propertyExpression, "ANOTHER RANDOM VALUE");

            combinator = new Combinator <LineSeriesConfigurator>(a, b);

            combined = combinator.Combine();

            combinedProperty = combined.AdditionalProperties.Get(propertyExpression);
            Assert.NotNull(combinedProperty);
            Assert.True(combinedProperty !.IsSet);
            Assert.Equal(format, combinedProperty.Value);
        }