Browse Source

add unit tests for property setters

pull/53/merge
Siegfried Pammer 12 years ago
parent
commit
9f71500fab
  1. 41
      src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Tests/Designer/SetPropertyTests.cs
  2. 1
      src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Tests/WpfDesign.Tests.csproj

41
src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Tests/Designer/SetPropertyTests.cs

@ -0,0 +1,41 @@ @@ -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);
}
}
}

1
src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Tests/WpfDesign.Tests.csproj

@ -65,6 +65,7 @@ @@ -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" />

Loading…
Cancel
Save