public void TryParseInvalidName() { var r = new MyNSResolver(); r.Add("a", "urn:foo"); r.Add("#", "urn:bar"); Assert.IsFalse(XamlTypeName.TryParse("$%#___!", r, out dummy), "#1"); Assert.IsFalse(XamlTypeName.TryParse("a:#$#", r, out dummy), "#2"); Assert.IsFalse(XamlTypeName.TryParse("#:foo", r, out dummy), "#3"); }
public void GenericGenericName() { var ns = new MyNSResolver(); ns.Add("s", "urn:foo"); ns.Add("", "urn:bar"); ns.Add("x", XamlLanguage.Xaml2006Namespace); var xn = XamlTypeName.Parse("List(KeyValuePair(x:Int32, s:DateTime))", ns); Assert.AreEqual("urn:bar", xn.Namespace, "#1"); Assert.AreEqual("List", xn.Name, "#2"); Assert.AreEqual("{urn:bar}List({urn:bar}KeyValuePair({http://schemas.microsoft.com/winfx/2006/xaml}Int32, {urn:foo}DateTime))", xn.ToString(), "#3"); }
public void TryParseInvalidGenericName() { var r = new MyNSResolver(); r.Add("x", "urn:foo"); Assert.IsFalse(XamlTypeName.TryParse("x:Foo()", r, out dummy), "#1"); }
public void TryParseGenericName() { var r = new MyNSResolver(); r.Add("x", "urn:foo"); Assert.IsTrue(XamlTypeName.TryParse("x:Foo(x:Foo,x:Bar)", r, out dummy), "#1"); Assert.AreEqual(2, dummy.TypeArguments.Count, "#2"); }
public void TryParseColon() { var r = new MyNSResolver(); r.Add("a", "urn:foo"); Assert.IsFalse(XamlTypeName.TryParse(":", r, out dummy), "#1"); Assert.IsFalse(XamlTypeName.TryParse("a:", r, out dummy), "#2"); Assert.IsFalse(XamlTypeName.TryParse(":b", r, out dummy), "#3"); }
public void TryParseResolveSuccess() { var r = new MyNSResolver(); r.Add("x", "urn:foo"); Assert.IsTrue(XamlTypeName.TryParse("x:Foo", r, out dummy), "#1"); Assert.IsNotNull(dummy, "#2"); Assert.AreEqual("urn:foo", dummy.Namespace, "#2-2"); Assert.AreEqual("Foo", dummy.Name, "#2-3"); }
public void GenericArrayName() { var ns = new MyNSResolver(); ns.Add("s", "urn:foo"); var xn = XamlTypeName.Parse("s:Nullable(s:Int32)[,,]", ns); Assert.AreEqual("urn:foo", xn.Namespace, "#1"); // note that array suffix comes here. Assert.AreEqual("Nullable[,,]", xn.Name, "#2"); // note that array suffix is detached from Name and appended after generic type arguments. Assert.AreEqual("{urn:foo}Nullable({urn:foo}Int32)[,,]", xn.ToString(), "#3"); }
public void GenericGenericName () { var ns = new MyNSResolver (); ns.Add ("s", "urn:foo"); ns.Add ("", "urn:bar"); ns.Add ("x", XamlLanguage.Xaml2006Namespace); var xn = XamlTypeName.Parse ("List(KeyValuePair(x:Int32, s:DateTime))", ns); Assert.AreEqual ("urn:bar", xn.Namespace, "#1"); Assert.AreEqual ("List", xn.Name, "#2"); Assert.AreEqual ("{urn:bar}List({urn:bar}KeyValuePair({http://schemas.microsoft.com/winfx/2006/xaml}Int32, {urn:foo}DateTime))", xn.ToString (), "#3"); }
public void GenericArrayName () { var ns = new MyNSResolver (); ns.Add ("s", "urn:foo"); var xn = XamlTypeName.Parse ("s:Nullable(s:Int32)[,,]", ns); Assert.AreEqual ("urn:foo", xn.Namespace, "#1"); // note that array suffix comes here. Assert.AreEqual ("Nullable[,,]", xn.Name, "#2"); // note that array suffix is detached from Name and appended after generic type arguments. Assert.AreEqual ("{urn:foo}Nullable({urn:foo}Int32)[,,]", xn.ToString (), "#3"); }
public void TryParseGenericName () { var r = new MyNSResolver (); r.Add ("x", "urn:foo"); Assert.IsTrue (XamlTypeName.TryParse ("x:Foo(x:Foo,x:Bar)", r, out dummy), "#1"); Assert.AreEqual (2, dummy.TypeArguments.Count, "#2"); }
public void TryParseInvalidGenericName () { var r = new MyNSResolver (); r.Add ("x", "urn:foo"); Assert.IsFalse (XamlTypeName.TryParse ("x:Foo()", r, out dummy), "#1"); }
public void TryParseResolveSuccess () { var r = new MyNSResolver (); r.Add ("x", "urn:foo"); Assert.IsTrue (XamlTypeName.TryParse ("x:Foo", r, out dummy), "#1"); Assert.IsNotNull (dummy, "#2"); Assert.AreEqual ("urn:foo", dummy.Namespace, "#2-2"); Assert.AreEqual ("Foo", dummy.Name, "#2-3"); }
public void TryParseInvalidName () { var r = new MyNSResolver (); r.Add ("a", "urn:foo"); r.Add ("#", "urn:bar"); Assert.IsFalse (XamlTypeName.TryParse ("$%#___!", r, out dummy), "#1"); Assert.IsFalse (XamlTypeName.TryParse ("a:#$#", r, out dummy), "#2"); Assert.IsFalse (XamlTypeName.TryParse ("#:foo", r, out dummy), "#3"); }
public void TryParseColon () { var r = new MyNSResolver (); r.Add ("a", "urn:foo"); Assert.IsFalse (XamlTypeName.TryParse (":", r, out dummy), "#1"); Assert.IsFalse (XamlTypeName.TryParse ("a:", r, out dummy), "#2"); Assert.IsFalse (XamlTypeName.TryParse (":b", r, out dummy), "#3"); }