1

How can I write a unit test to test the ActualWidth property in a UserControl in Silverligh 4?

I hoped that this method would pass, but it fails.

I am using the Silverlight ToolKit april 2010, and VS 2010.

<TestMethod()> _
Public Sub TestAcrtualWidth()
    Me.MyUserControl.Width = 100
    Me.MyUserControl.UpdateLayout()
    Assert.IsTrue(Me.MyUserControl.ActualWidth > 0)
End Sub
Dave Clemmer
  • 3,741
  • 12
  • 49
  • 72
eflles
  • 6,606
  • 11
  • 41
  • 55

1 Answers1

0

The problem was that I added MyUserControl to a new instance of a Canvas. If I instead used :

Me.TestPanel.Children.add(Me.MyUserControl) 

It worked!

Dave Clemmer
  • 3,741
  • 12
  • 49
  • 72
eflles
  • 6,606
  • 11
  • 41
  • 55