2009-12-07 Rolf Bjarne Kvinge <RKvinge@novell.com>
[moon.git] / test / 2.0 / moon-unit / System.Windows / VisualStateTest.cs
blob08be21e7b7d46ffbfcb3ba651845ea8472702ef7
1 using System;
2 using System.Net;
3 using System.Linq;
4 using System.Windows;
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
20 [TestClass]
21 public partial class VisualStateTest : SilverlightTest
23 [TestMethod]
24 [MoonlightBug]
25 public void GroupNameTest ()
27 UserControl c = (UserControl) XamlReader.Load (@"
28 <UserControl
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>
36 <Canvas>
38 </Canvas>
39 </UserControl>");
40 VisualStateGroup g = VisualStateManager.GetVisualStateGroups (c).Cast<VisualStateGroup> ().First ();
41 Assert.AreEqual ("Tester", g.Name, "#1");
44 [TestMethod]
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);
52 [TestMethod]
53 [MoonlightBug]
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)
63 [TestMethod]
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);
70 [TestMethod]
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);
77 [TestMethod]
78 public void TestDefaults ()
80 VisualState st = new VisualState ();
81 Assert.AreEqual ("", st.Name, "1");
82 Assert.IsNull (st.Storyboard, "2");
85 [TestMethod]
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);