{
UrlIdentityPermission uip = new UrlIdentityPermission (PermissionState.None);
#if NET_2_0
+ // that cause a NullReferenceException before 2.0
Assert.AreEqual (String.Empty, uip.Url, "Url");
#endif
SecurityElement se = uip.ToXml ();
// only class and version are present
Assert.AreEqual (2, se.Attributes.Count, "Xml-Attributes");
Assert.IsNull (se.Children, "Xml-Children");
-
+#if NET_2_0
UrlIdentityPermission copy = (UrlIdentityPermission)uip.Copy ();
Assert.IsFalse (Object.ReferenceEquals (uip, copy), "ReferenceEquals");
+#endif
}
#if !NET_2_0
}
#endif
+#if NET_2_0
+ [Test]
+ [Category ("NotWorking")]
+ public void PermissionStateUnrestricted ()
+ {
+ // In 2.0 Unrestricted are permitted for identity permissions
+ UrlIdentityPermission uip = new UrlIdentityPermission (PermissionState.Unrestricted);
+ Assert.AreEqual (String.Empty, uip.Url, "Url");
+ SecurityElement se = uip.ToXml ();
+ // only class and version are present
+ Assert.AreEqual (3, se.Attributes.Count, "Xml-Attributes");
+ Assert.IsNull (se.Children, "Xml-Children");
+ // and they aren't equals to None
+ Assert.IsFalse (uip.Equals (new UrlIdentityPermission (PermissionState.None)));
+ }
+#else
[Test]
[ExpectedException (typeof (ArgumentException))]
public void PermissionState_Unrestricted ()
{
UrlIdentityPermission uip = new UrlIdentityPermission (PermissionState.Unrestricted);
}
-
+#endif
[Test]
[ExpectedException (typeof (ArgumentException))]
public void PermissionState_Bad ()
UrlIdentityPermission uip = new UrlIdentityPermission (PermissionState.None);
foreach (string s in GoodUrls) {
uip.Url = s;
+#if NET_2_0
Assert.AreEqual (s, uip.Url, s);
+#else
+ // Fx 1.0/1.1 adds a '/' at the end, while 2.0 keeps the original format
+ // so we only compare the start of the url
+#endif
}
}
[Test]
+#if NET_2_0
+ // this was working in beta1 but is broken in Nov CTP
+ [ExpectedException (typeof (NullReferenceException))]
+ [Category ("NotWorking")]
+#else
[ExpectedException (typeof (ArgumentNullException))]
+#endif
public void Url_Null ()
{
UrlIdentityPermission uip = new UrlIdentityPermission (PermissionState.None);
public void Copy ()
{
UrlIdentityPermission uip = new UrlIdentityPermission (PermissionState.None);
- foreach (string s in GoodUrls)
- {
+ foreach (string s in GoodUrls) {
uip.Url = s;
UrlIdentityPermission copy = (UrlIdentityPermission)uip.Copy ();
- Assert.AreEqual (s, copy.Url, s);
+ // Fx 1.0/1.1 adds a '/' at the end, while 2.0 keeps the original format
+ // so we only compare the start of the url
+ Assert.AreEqual (uip.Url, copy.Url, "Url");
}
}
+ [Test]
+#if !NET_2_0
+ [ExpectedException (typeof (NullReferenceException))]
+#endif
+ public void Copy_None ()
+ {
+ UrlIdentityPermission uip = new UrlIdentityPermission (PermissionState.None);
+ UrlIdentityPermission copy = (UrlIdentityPermission)uip.Copy ();
+ }
+
[Test]
public void Intersect_Null ()
{
Assert.IsNull (uip.Intersect (null), s);
}
}
-
+#if NET_2_0
+ [Category ("NotWorking")]
+#endif
[Test]
public void Intersect_None ()
{
foreach (string s in GoodUrls) {
uip.Url = s;
UrlIdentityPermission result = (UrlIdentityPermission)uip.Intersect (uip);
- Assert.AreEqual (s, result.Url, s);
+ // Fx 1.0/1.1 adds a '/' at the end, while 2.0 keeps the original format
+ // so we only compare the start of the url
+ Assert.IsTrue (result.Url.StartsWith (uip.Url), s);
}
}
}
}
+#if NET_2_0
+ [Category ("NotWorking")]
+#endif
[Test]
public void IsSubset_None ()
{
foreach (string s in GoodUrls) {
uip.Url = s;
UrlIdentityPermission union = (UrlIdentityPermission)uip.Union (null);
- Assert.AreEqual (s, union.Url, s);
+ // Fx 1.0/1.1 adds a '/' at the end, while 2.0 keeps the original format
+ // so we only compare the start of the url
+ Assert.IsTrue (union.Url.StartsWith (uip.Url), s);
}
}
foreach (string s in GoodUrls) {
uip1.Url = s;
UrlIdentityPermission union = (UrlIdentityPermission)uip1.Union (uip2);
- Assert.AreEqual (s, union.Url, s);
+ // Fx 1.0/1.1 adds a '/' at the end, while 2.0 keeps the original format
+ // so we only compare the start of the url
+ Assert.IsTrue (union.Url.StartsWith (uip1.Url), s);
}
uip1 = new UrlIdentityPermission (PermissionState.None);
// b. destination (target) is none
foreach (string s in GoodUrls) {
uip2.Url = s;
UrlIdentityPermission union = (UrlIdentityPermission)uip2.Union (uip1);
- Assert.AreEqual (s, union.Url, s);
+ // Fx 1.0/1.1 adds a '/' at the end, while 2.0 keeps the original format
+ // so we only compare the start of the url
+ Assert.IsTrue (union.Url.StartsWith (uip2.Url), s);
}
}
foreach (string s in GoodUrls) {
uip.Url = s;
union = (UrlIdentityPermission)uip.Union (uip);
- Assert.AreEqual (s, union.Url, s);
+ // Fx 1.0/1.1 adds a '/' at the end, while 2.0 keeps the original format
+ // so we only compare the start of the url
+ Assert.IsTrue (union.Url.StartsWith (uip.Url), s);
}
}
-
+#if NET_2_0
+ [Category ("NotWorking")]
+#endif
[Test]
- [ExpectedException (typeof (ArgumentException))]
public void Union_Different ()
{
UrlIdentityPermission uip1 = new UrlIdentityPermission (GoodUrls [0]);
UrlIdentityPermission uip2 = new UrlIdentityPermission (GoodUrls [1]);
UrlIdentityPermission result = (UrlIdentityPermission)uip1.Union (uip2);
+#if NET_2_0
+ Assert.IsNotNull (result, "Mono U Novell");
+ // new XML format is used to contain more than one site
+ SecurityElement se = result.ToXml ();
+ Assert.AreEqual (2, se.Children.Count, "Childs");
+ Assert.AreEqual (GoodUrls [0], (se.Children [0] as SecurityElement).Attribute ("Url"), "Url#1");
+ Assert.AreEqual (GoodUrls [1], (se.Children [1] as SecurityElement).Attribute ("Url"), "Url#2");
+ // strangely it is still versioned as 'version="1"'.
+ Assert.AreEqual ("1", se.Attribute ("version"), "Version");
+#else
Assert.IsNull (result, "Mono U Novell");
+#endif
}
[Test]