5 using System
.Windows
.Controls
;
6 using System
.Windows
.Documents
;
7 using System
.Windows
.Ink
;
8 using System
.Windows
.Input
;
9 using System
.Windows
.Markup
;
10 using System
.Windows
.Media
;
11 using System
.Windows
.Media
.Animation
;
12 using System
.Windows
.Shapes
;
13 using System
.Collections
.Generic
;
14 using Mono
.Moonlight
.UnitTesting
;
15 using Microsoft
.VisualStudio
.TestTools
.UnitTesting
;
16 using Microsoft
.Silverlight
.Testing
;
18 namespace MoonTest
.System
.Windows
21 public partial class VisualStateTest
: SilverlightTest
25 public void GroupNameTest ()
27 UserControl c
= (UserControl
) XamlReader
.Load (@"
29 xmlns=""http://schemas.microsoft.com/winfx/2006/xaml/presentation""
30 xmlns:x=""http://schemas.microsoft.com/winfx/2006/xaml""
31 xmlns:clr=""clr-namespace:SilverlightApplication14""
32 x:Name=""RootControl"">
33 <VisualStateManager.VisualStateGroups>
34 <VisualStateGroup x:Name=""Tester"" />
35 </VisualStateManager.VisualStateGroups>
40 VisualStateGroup g
= VisualStateManager
.GetVisualStateGroups (c
).Cast
<VisualStateGroup
> ().First ();
41 Assert
.AreEqual ("Tester", g
.Name
, "#1");
45 public void TestParse ()
47 VisualState vs
= (VisualState
)XamlReader
.Load (@"<vsm:VisualState xmlns=""http://schemas.microsoft.com/client/2007"" xmlns:x=""http://schemas.microsoft.com/winfx/2006/xaml"" xmlns:vsm=""clr-namespace:System.Windows;assembly=System.Windows"" x:Name=""foo""><Storyboard /></vsm:VisualState>");
48 Assert
.AreEqual ("foo", vs
.Name
);
49 Assert
.IsNotNull (vs
.Storyboard
);
54 public void TestParse_NoManagedNamespace ()
56 Assert
.Throws (delegate {
57 XamlReader
.Load (@"<VisualState xmlns=""http://schemas.microsoft.com/client/2007"" xmlns:x=""http://schemas.microsoft.com/winfx/2006/xaml"" x:Name=""foo""><Storyboard /></VisualState>");
59 // "VisualState does not support Storyboard as content."
60 typeof (XamlParseException
)); // Fails in Silverlight 3 (no exception)
64 public void TestParse_NoStoryboard ()
66 VisualState vs
= (VisualState
)XamlReader
.Load (@"<vsm:VisualState xmlns=""http://schemas.microsoft.com/client/2007"" xmlns:x=""http://schemas.microsoft.com/winfx/2006/xaml"" xmlns:vsm=""clr-namespace:System.Windows;assembly=System.Windows"" x:Name=""foo"" />");
67 Assert
.IsNull (vs
.Storyboard
);
71 public void TestParse_NoName ()
73 VisualState vs
= (VisualState
)XamlReader
.Load (@"<vsm:VisualState xmlns=""http://schemas.microsoft.com/client/2007"" xmlns:x=""http://schemas.microsoft.com/winfx/2006/xaml"" xmlns:vsm=""clr-namespace:System.Windows;assembly=System.Windows""><Storyboard /></vsm:VisualState>");
74 Assert
.AreEqual ("", vs
.Name
);
78 public void TestDefaults ()
80 VisualState st
= new VisualState ();
81 Assert
.AreEqual ("", st
.Name
, "1");
82 Assert
.IsNull (st
.Storyboard
, "2");
86 public void UseStoryboardThrice ()
88 Storyboard sb
= new Storyboard ();
89 VisualState s1
= new VisualState { Storyboard = sb }
;
90 VisualState s2
= new VisualState { Storyboard = sb }
;
92 TestPanel
.Resources
.Add ("a", s1
);
93 TestPanel
.Resources
.Add ("b", s2
);
94 TestPanel
.Resources
.Add ("c", sb
);