diff --git a/src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Tests/Designer/SetPropertyTests.cs b/src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Tests/Designer/SetPropertyTests.cs new file mode 100644 index 0000000000..46ec5bc060 --- /dev/null +++ b/src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Tests/Designer/SetPropertyTests.cs @@ -0,0 +1,41 @@ +// Copyright (c) AlphaSierraPapa for the SharpDevelop Team (for details please see \doc\copyright.txt) +// This code is distributed under the GNU LGPL (for details please see \doc\license.txt) + +using System; +using System.Windows; +using System.Windows.Data; +using System.Windows.Markup; + +using NUnit.Framework; + +namespace ICSharpCode.WpfDesign.Tests.Designer +{ + [TestFixture] + public class SetPropertyTests : ModelTestHelper + { + [Test] + public void SetContentToBinding() + { + DesignItem button = CreateCanvasContext("<Button Width='100' Height='200'/>"); + button.Properties.GetProperty("Content").SetValue(new Binding()); + AssertCanvasDesignerOutput("<Button Width=\"100\" Height=\"200\" Content=\"{Binding}\" />", button.Context); + } + + [Test, Ignore("Properties are not present in XAML DOM")] + public void SetContentToStaticResource() + { + DesignItem button = CreateCanvasContext(@"<Button Width='100' Height='200'/>"); + button.Properties.GetProperty("Content").SetValue(new StaticResourceExtension("MyBrush")); + // TODO : maybe we should support positional arguments from ctors as well => {StaticResource MyBrush}? + AssertCanvasDesignerOutput("<Button Width=\"100\" Height=\"200\" Content=\"{StaticResource ResourceKey=MyBrush}\" />", button.Context); + } + + [Test, Ignore("x-Namespace is not resolved properly and properties are not present in XAML DOM")] + public void SetContentToXStatic() + { + DesignItem button = CreateCanvasContext("<Button Width='100' Height='200'/>"); + button.Properties.GetProperty("Content").SetValue(new StaticExtension("Button.ClickModeProperty")); + AssertCanvasDesignerOutput("<Button Width=\"100\" Height=\"200\" Content=\"{x:Static Member=Button.ClickModeProperty}\" />", button.Context); + } + } +} diff --git a/src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Tests/WpfDesign.Tests.csproj b/src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Tests/WpfDesign.Tests.csproj index fa34cacfb2..88d1aeb71d 100644 --- a/src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Tests/WpfDesign.Tests.csproj +++ b/src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Tests/WpfDesign.Tests.csproj @@ -65,6 +65,7 @@ <Compile Include="Designer\OutlineView\InsertTests.cs" /> <Compile Include="Designer\OutlineView\SelectionTests.cs" /> <Compile Include="Designer\PlacementTests.cs" /> + <Compile Include="Designer\SetPropertyTests.cs" /> <Compile Include="XamlDom\ExampleClass.cs" /> <Compile Include="XamlDom\ExampleClassContainer.cs" /> <Compile Include="XamlDom\ExampleService.cs" />