User Tools

Site Tools


technical_notes:public:20131015-wpf-unit-test-behavior

Parent

WPF - How to test a behavior ?

To set your control on your behavior, use the method Attach.

[TestClass]
public class MyBehaviorTest
{
  [TestMethod]
  public void TestBehaviorBasic()
  {
    // Assign
    TextBox textbox = new TextBox();
    MyBehavior behavior = new MyBehavior();
    behavior.Attach(textboxMock);
 
    // Action
    textbox.Text = "test&test"; // Remove special characters on text changed
 
    // Assert
    Assert.AreEqual("testtest", textbox.Text);
  }
}
,
technical_notes/public/20131015-wpf-unit-test-behavior.txt · Last modified: 2013/10/15 16:44 by Fabien Arcellier