Browse Source

Added unit test for using SolidColorBrush as a resource. This also tests that the inner text of an XML element is only set if the element type defines a Content property.

pull/68/head
gumme 12 years ago
parent
commit
f4a283ff9b
  1. 40
      src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Tests/Designer/ModelTests.cs

40
src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Tests/Designer/ModelTests.cs

@ -2,17 +2,19 @@ @@ -2,17 +2,19 @@
// This code is distributed under the GNU LGPL (for details please see \doc\license.txt)
using System;
using System.Text;
using System.IO;
using System.Xml;
using System.Diagnostics;
using System.IO;
using System.Text;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using NUnit.Framework;
using System.Windows.Media;
using System.Xml;
using ICSharpCode.WpfDesign.Designer;
using ICSharpCode.WpfDesign.Designer.Xaml;
using ICSharpCode.WpfDesign.Designer.Services;
using ICSharpCode.WpfDesign.Designer.Xaml;
using NUnit.Framework;
namespace ICSharpCode.WpfDesign.Tests.Designer
{
@ -368,6 +370,34 @@ namespace ICSharpCode.WpfDesign.Tests.Designer @@ -368,6 +370,34 @@ namespace ICSharpCode.WpfDesign.Tests.Designer
{
AddBindingWithStaticResourceWhereResourceOnSameElement(true);
}
[Test]
public void AddBrushAsResource()
{
DesignItem checkBox = CreateCanvasContext("<CheckBox/>");
DesignItem canvas = checkBox.Parent;
DesignItemProperty canvasResources = canvas.Properties.GetProperty("Resources");
DesignItem brush = canvas.Services.Component.RegisterComponentForDesigner(new SolidColorBrush());
brush.Key = "testBrush";
brush.Properties[SolidColorBrush.ColorProperty].SetValue(Colors.Fuchsia);
Assert.IsTrue(canvasResources.IsCollection);
canvasResources.CollectionElements.Add(brush);
checkBox.Properties[CheckBox.ForegroundProperty].SetValue(new StaticResourceExtension());
DesignItemProperty prop = checkBox.Properties[CheckBox.ForegroundProperty];
prop.Value.Properties["ResourceKey"].SetValue("testBrush");
string expectedXaml = "<Canvas.Resources>\n" +
" <SolidColorBrush x:Key=\"testBrush\" Color=\"#FFFF00FF\" />\n" +
"</Canvas.Resources>\n" +
"<CheckBox Foreground=\"{StaticResource ResourceKey=testBrush}\" />";
AssertCanvasDesignerOutput(expectedXaml, checkBox.Context);
AssertLog("");
}
}
public class MyMultiConverter : IMultiValueConverter

Loading…
Cancel
Save