public void TestSettingPropertiesBeforeAddingToPlotter() { var types = GetAllCharts(); var properties = from type in types let typeProperties = type.GetProperties(BindingFlags.Public | BindingFlags.Instance) let ownProperties = from prop in typeProperties where prop.CanWrite && prop.CanRead where testedAssemblies.Contains(prop.DeclaringType.Assembly) select prop select new { Type = type, Properties = ownProperties.ToArray() }; var propertiesList = properties.ToList(); var charts = (from item in propertiesList let instance = Activator.CreateInstance(item.Type) select new { Instance = instance, Properties = item.Properties }).ToList(); PropertySetSystem system = new PropertySetSystem(); // setting custom values foreach (var chart in charts) { var instance = chart.Instance; foreach (var property in chart.Properties) { system.TrySetValue(instance, property); } } ChartPlotter plotter = ChartPlotter.CreateEmpty(); foreach (var chart in charts) { plotter.Children.Add(chart.Instance as IPlotterElement); } foreach (var chart in charts) { var instance = chart.Instance; foreach (var property in chart.Properties) { system.TrySetValue(instance, property); } } }
public void TestXamlAreEqual() { ChartPlotter plotter = new ChartPlotter(); plotter.Children.Clear(); string plotterXaml = XamlWriter.Save(plotter); ChartPlotter empty = ChartPlotter.CreateEmpty(); empty.Children.Clear(); string emptyXaml = XamlWriter.Save(empty); Assert.AreEqual(plotterXaml, emptyXaml); }