示例#1
0
        // oh man, this is a bad boy.It should be ArgumentNullException.
        public void InitializeAndValidate_Null()
        {
            UriFormatException error = null;
            UnitTestUriParser  p     = new UnitTestUriParser();

            p._InitializeAndValidate(null, out error);
        }
示例#2
0
        public void Resolve_UriNull()
        {
            UriFormatException error = null;
            UnitTestUriParser  p     = new UnitTestUriParser();

            Assert.AreEqual(full_http, p._Resolve(http, null, out error), "http-http");
        }
示例#3
0
        public void GetComponents_Ftp2()
        {
            UnitTestUriParser p = new UnitTestUriParser();

            Assert.AreEqual("ftp", p._GetComponents(ftp2, UriComponents.Scheme, UriFormat.Unescaped), "ftp.Scheme");
            Assert.AreEqual("username:password", p._GetComponents(ftp2, UriComponents.UserInfo, UriFormat.Unescaped), "ftp.UserInfo");
            Assert.AreEqual("ftp.go-mono.com", p._GetComponents(ftp2, UriComponents.Host, UriFormat.Unescaped), "ftp.Host");
            Assert.AreEqual(String.Empty, p._GetComponents(ftp2, UriComponents.Port, UriFormat.Unescaped), "ftp.Port");
            Assert.AreEqual("with some spaces/mono.tgz", p._GetComponents(ftp2, UriComponents.Path, UriFormat.Unescaped), "ftp.Path");
            Assert.AreEqual("with%20some%20spaces/mono.tgz", p._GetComponents(ftp2, UriComponents.Path, UriFormat.UriEscaped), "ftp.Path-UriEscaped");
            Assert.AreEqual("with some spaces/mono.tgz", p._GetComponents(ftp2, UriComponents.Path, UriFormat.SafeUnescaped), "ftp.Path-SafeUnescaped");
            Assert.AreEqual(String.Empty, p._GetComponents(ftp2, UriComponents.Query, UriFormat.Unescaped), "ftp.Query");
            Assert.AreEqual(String.Empty, p._GetComponents(ftp2, UriComponents.Fragment, UriFormat.Unescaped), "ftp.Fragment");
            Assert.AreEqual("21", p._GetComponents(ftp2, UriComponents.StrongPort, UriFormat.Unescaped), "ftp.StrongPort");
            Assert.AreEqual(String.Empty, p._GetComponents(ftp2, UriComponents.KeepDelimiter, UriFormat.Unescaped), "http.KeepDelimiter");
            Assert.AreEqual("ftp.go-mono.com:21", p._GetComponents(ftp2, UriComponents.HostAndPort, UriFormat.Unescaped), "http.HostAndPort");
            Assert.AreEqual("username:[email protected]:21", p._GetComponents(ftp2, UriComponents.StrongAuthority, UriFormat.Unescaped), "http.StrongAuthority");
            Assert.AreEqual("ftp://*****:*****@ftp.go-mono.com/with some spaces/mono.tgz", p._GetComponents(ftp2, UriComponents.AbsoluteUri, UriFormat.Unescaped), "http.AbsoluteUri");
            Assert.AreEqual("/with some spaces/mono.tgz", p._GetComponents(ftp2, UriComponents.PathAndQuery, UriFormat.Unescaped), "http.PathAndQuery");
            Assert.AreEqual("ftp://ftp.go-mono.com/with some spaces/mono.tgz", p._GetComponents(ftp2, UriComponents.HttpRequestUrl, UriFormat.Unescaped), "http.HttpRequestUrl");
            Assert.AreEqual("ftp://ftp.go-mono.com", p._GetComponents(ftp2, UriComponents.SchemeAndServer, UriFormat.Unescaped), "http.SchemeAndServer");
            Assert.AreEqual("ftp://*****:*****@ftp.go-mono.com/with some spaces/mono.tgz", p._GetComponents(ftp2, UriComponents.SerializationInfoString, UriFormat.Unescaped), "http.SerializationInfoString");
            Assert.AreSame(p, p._OnNewUri(), "OnNewUri");
            // strange mixup
            Assert.AreEqual("ftp://*****:*****@", p._GetComponents(ftp2, UriComponents.Scheme | UriComponents.UserInfo, UriFormat.Unescaped), "ftp.Scheme+UserInfo");
            Assert.AreEqual(":21/with some spaces/mono.tgz", p._GetComponents(ftp2, UriComponents.Path | UriComponents.StrongPort, UriFormat.Unescaped), "ftp.Path+StrongPort");
        }
示例#4
0
        public void GetComponents()
        {
            UnitTestUriParser p = new UnitTestUriParser();

            Assert.AreEqual("http", p._GetComponents(http, UriComponents.Scheme, UriFormat.SafeUnescaped), "http.Scheme");
            Assert.AreEqual(String.Empty, p._GetComponents(http, UriComponents.UserInfo, UriFormat.SafeUnescaped), "http.UserInfo");
            Assert.AreEqual("www.mono-project.com", p._GetComponents(http, UriComponents.Host, UriFormat.SafeUnescaped), "http.Host");
            Assert.AreEqual(String.Empty, p._GetComponents(http, UriComponents.Port, UriFormat.SafeUnescaped), "http.Port");
            Assert.AreEqual("Main_Page", p._GetComponents(http, UriComponents.Path, UriFormat.SafeUnescaped), "http.Path");
            Assert.AreEqual(String.Empty, p._GetComponents(http, UriComponents.Query, UriFormat.SafeUnescaped), "http.Query");
            Assert.AreEqual("FAQ?Edit", p._GetComponents(http, UriComponents.Fragment, UriFormat.SafeUnescaped), "http.Fragment");
            Assert.AreEqual("80", p._GetComponents(http, UriComponents.StrongPort, UriFormat.SafeUnescaped), "http.StrongPort");
            Assert.AreEqual(String.Empty, p._GetComponents(http, UriComponents.KeepDelimiter, UriFormat.SafeUnescaped), "http.KeepDelimiter");
            Assert.AreEqual("www.mono-project.com:80", p._GetComponents(http, UriComponents.HostAndPort, UriFormat.SafeUnescaped), "http.HostAndPort");
            Assert.AreEqual("www.mono-project.com:80", p._GetComponents(http, UriComponents.StrongAuthority, UriFormat.SafeUnescaped), "http.StrongAuthority");
            Assert.AreEqual(full_http, p._GetComponents(http, UriComponents.AbsoluteUri, UriFormat.SafeUnescaped), "http.AbsoluteUri");
            Assert.AreEqual("/Main_Page", p._GetComponents(http, UriComponents.PathAndQuery, UriFormat.SafeUnescaped), "http.PathAndQuery");
            Assert.AreEqual("http://www.mono-project.com/Main_Page", p._GetComponents(http, UriComponents.HttpRequestUrl, UriFormat.SafeUnescaped), "http.HttpRequestUrl");
            Assert.AreEqual("http://www.mono-project.com", p._GetComponents(http, UriComponents.SchemeAndServer, UriFormat.SafeUnescaped), "http.SchemeAndServer");
            Assert.AreEqual(full_http, p._GetComponents(http, UriComponents.SerializationInfoString, UriFormat.SafeUnescaped), "http.SerializationInfoString");
            // strange mixup
            Assert.AreEqual("http://", p._GetComponents(http, UriComponents.Scheme | UriComponents.Port, UriFormat.SafeUnescaped), "http.Scheme+Port");
            Assert.AreEqual("www.mono-project.com#FAQ?Edit", p._GetComponents(http, UriComponents.Host | UriComponents.Fragment, UriFormat.SafeUnescaped), "http.Scheme+Port");
            Assert.AreEqual("/Main_Page", p._GetComponents(http, UriComponents.Port | UriComponents.Path, UriFormat.SafeUnescaped), "http.Scheme+Port");
            Assert.AreSame(p, p._OnNewUri(), "OnNewUri");
        }
示例#5
0
        public void InitializeAndValidate()
        {
            UriFormatException error = null;
            UnitTestUriParser  p     = new UnitTestUriParser();

            p._InitializeAndValidate(http, out error);
            Assert.IsNotNull(error, "out");              // authority/host couldn't be parsed ?!?!
        }
示例#6
0
        public void Resolve_NullUri()
        {
            UriFormatException error = null;
            UnitTestUriParser  p     = new UnitTestUriParser();

            p._Resolve(null, http, out error);
            p._Resolve(http, null, out error);
        }
示例#7
0
        public void ReRegister()
        {
            string scheme = prefix + "re.register.mono";

            Assert.IsFalse(UriParser.IsKnownScheme(scheme), "IsKnownScheme-false");
            UnitTestUriParser p = new UnitTestUriParser();

            UriParser.Register(p, scheme, 2005);
            Assert.IsTrue(UriParser.IsKnownScheme(scheme), "IsKnownScheme-true");
            UriParser.Register(p, scheme, 2006);
        }
示例#8
0
        public void Register()
        {
            string scheme = prefix + "register.mono";

            Assert.IsFalse(UriParser.IsKnownScheme(scheme), "IsKnownScheme-false");

            UnitTestUriParser p = new UnitTestUriParser();

            UriParser.Register(p, scheme, 2005);
            Assert.AreEqual(scheme, p.SchemeName, "SchemeName");
            Assert.AreEqual(2005, p.DefaultPort, "DefaultPort");

            Assert.IsTrue(UriParser.IsKnownScheme(scheme), "IsKnownScheme-true");
        }
示例#9
0
        public void OnNewUri()
        {
            string scheme = prefix + "on.new.uri";

            Assert.IsFalse(UriParser.IsKnownScheme(scheme), "IsKnownScheme-false");

            UnitTestUriParser p = new UnitTestUriParser();

            UriParser.Register(p, scheme, 1999);

            Assert.IsFalse(p.OnNewUriCalled, "!Called");
            Uri uri = new Uri(scheme + "://www.mono-project.com");

            Assert.IsTrue(p.OnNewUriCalled, "Called");
        }
示例#10
0
        public void OnRegister()
        {
            string scheme = prefix + "onregister";

            Assert.IsFalse(UriParser.IsKnownScheme(scheme), "IsKnownScheme-false");
            UnitTestUriParser p = new UnitTestUriParser();

            try {
                UriParser.Register(p, scheme, 2005);
            }
            catch (NotSupportedException) {
                // special case / ordering
            }
            // if true then the registration is done before calling OnRegister
            Assert.IsTrue(UriParser.IsKnownScheme(scheme), "IsKnownScheme-true");
        }
示例#11
0
        public void OnRegister2()
        {
            string scheme = prefix + "onregister2";

            Assert.IsFalse(UriParser.IsKnownScheme(scheme), "IsKnownScheme-false");
            UnitTestUriParser p = new UnitTestUriParser();

            try {
                UriParser.Register(p, scheme, 2005);
                Uri uri = new Uri(scheme + "://foobar:2005");
                Assert.AreEqual(scheme, uri.Scheme, "uri-prefix");
                Assert.AreEqual(2005, uri.Port, "uri-port");

                Assert.AreEqual("//foobar:2005", uri.LocalPath, "uri-localpath");
            }
            catch (NotSupportedException) {
                // special case / ordering
            }
            // if true then the registration is done before calling OnRegister
            Assert.IsTrue(UriParser.IsKnownScheme(scheme), "IsKnownScheme-true");
        }
示例#12
0
        public void Register_Minus1Port()
        {
            UnitTestUriParser p = new UnitTestUriParser();

            UriParser.Register(p, prefix + "minus1.port", -1);
        }
示例#13
0
		public void IsWellFormedOriginalString_Null ()
		{
			UnitTestUriParser p = new UnitTestUriParser ();
			p._IsWellFormedOriginalString (null);
		}
示例#14
0
		public void IsBaseOf_NullUri ()
		{
			UnitTestUriParser p = new UnitTestUriParser ();
			p._IsBaseOf (null, http);
		}
示例#15
0
        public void IsWellFormedOriginalString()
        {
            UnitTestUriParser p = new UnitTestUriParser();

            Assert.IsTrue(p._IsWellFormedOriginalString(http), "http");
        }
示例#16
0
        public void IsBaseOf_UriNull()
        {
            UnitTestUriParser p = new UnitTestUriParser();

            p._IsBaseOf(http, null);
        }
示例#17
0
		public void GetComponents_BadUriFormat ()
		{
			UnitTestUriParser p = new UnitTestUriParser ();
			p._GetComponents (http, UriComponents.Host, (UriFormat) Int32.MinValue);
		}
示例#18
0
        public void GetComponents_BadUriFormat()
        {
            UnitTestUriParser p = new UnitTestUriParser();

            p._GetComponents(http, UriComponents.Host, (UriFormat)Int32.MinValue);
        }
示例#19
0
		public void Register_NullScheme ()
		{
			UnitTestUriParser p = new UnitTestUriParser ();
			UriParser.Register (p, null, 2006);
		}
示例#20
0
		public void Register ()
		{
			string scheme = prefix + "register.mono";
			Assert.IsFalse (UriParser.IsKnownScheme (scheme), "IsKnownScheme-false");

			UnitTestUriParser p = new UnitTestUriParser ();
			UriParser.Register (p, scheme, 2005);
			Assert.AreEqual (scheme, p.SchemeName, "SchemeName");
			Assert.AreEqual (2005, p.DefaultPort, "DefaultPort");

			Assert.IsTrue (UriParser.IsKnownScheme (scheme), "IsKnownScheme-true");
		}
示例#21
0
		public void Resolve_NullUri ()
		{
			UriFormatException error = null;
			UnitTestUriParser p = new UnitTestUriParser ();
			p._Resolve (null, http, out error);
			p._Resolve (http, null, out error);
		}
示例#22
0
		public void Resolve_UriNull ()
		{
			UriFormatException error = null;
			UnitTestUriParser p = new UnitTestUriParser ();
			Assert.AreEqual (full_http, p._Resolve (http, null, out error), "http-http");
		}
示例#23
0
		public void OnRegister2 ()
		{
			string scheme = prefix + "onregister2";
			Assert.IsFalse (UriParser.IsKnownScheme (scheme), "IsKnownScheme-false");
			UnitTestUriParser p = new UnitTestUriParser ();
			try {
				UriParser.Register (p, scheme, 2005);
				Uri uri = new Uri (scheme + "://foobar:2005");
				Assert.AreEqual (scheme, uri.Scheme, "uri-prefix");
				Assert.AreEqual (2005, uri.Port, "uri-port");
				
				Assert.AreEqual ("//foobar:2005", uri.LocalPath, "uri-localpath");
			}
			catch (NotSupportedException) {
				// special case / ordering
			}
			// if true then the registration is done before calling OnRegister
			Assert.IsTrue (UriParser.IsKnownScheme (scheme), "IsKnownScheme-true");
		}
示例#24
0
		public void OnRegister ()
		{
			string scheme = prefix + "onregister";
			Assert.IsFalse (UriParser.IsKnownScheme (scheme), "IsKnownScheme-false");
			UnitTestUriParser p = new UnitTestUriParser ();
			try {
				UriParser.Register (p, scheme, 2005);
			}
			catch (NotSupportedException) {
				// special case / ordering
			}
			// if true then the registration is done before calling OnRegister
			Assert.IsTrue (UriParser.IsKnownScheme (scheme), "IsKnownScheme-true");
		}
示例#25
0
		public void OnNewUri ()
		{
			string scheme = prefix + "on.new.uri";
			Assert.IsFalse (UriParser.IsKnownScheme (scheme), "IsKnownScheme-false");

			UnitTestUriParser p = new UnitTestUriParser ();
			UriParser.Register (p, scheme, 1999);

			Assert.IsFalse (p.OnNewUriCalled, "!Called");
			Uri uri = new Uri (scheme + "://www.mono-project.com");
			Assert.IsTrue (p.OnNewUriCalled, "Called");
		}
示例#26
0
        public void Register_TooBigPort()
        {
            UnitTestUriParser p = new UnitTestUriParser();

            UriParser.Register(p, prefix + "too.big.port", UInt16.MaxValue);
        }
示例#27
0
		public void IsBaseOf_UriNull ()
		{
			UnitTestUriParser p = new UnitTestUriParser ();
			p._IsBaseOf (http, null);
		}
示例#28
0
		public void Register_NegativePort ()
		{
			UnitTestUriParser p = new UnitTestUriParser ();
			UriParser.Register (p, prefix + "negative.port", -2);
		}
示例#29
0
		public void InitializeAndValidate ()
		{
			UriFormatException error = null;
			UnitTestUriParser p = new UnitTestUriParser ();
			p._InitializeAndValidate (http, out error);
			Assert.IsNotNull (error, "out"); // authority/host couldn't be parsed ?!?!
		}
示例#30
0
		public void Register_Minus1Port ()
		{
			UnitTestUriParser p = new UnitTestUriParser ();
			UriParser.Register (p, prefix + "minus1.port", -1);
		}
示例#31
0
        public void IsBaseOf()
        {
            UnitTestUriParser p = new UnitTestUriParser();

            Assert.IsTrue(p._IsBaseOf(http, http), "http-http");

            Uri u = new Uri("http://www.mono-project.com/Main_Page#FAQ");

            Assert.IsTrue(p._IsBaseOf(u, http), "http-1a");
            Assert.IsTrue(p._IsBaseOf(http, u), "http-1b");

            u = new Uri("http://www.mono-project.com/Main_Page");
            Assert.IsTrue(p._IsBaseOf(u, http), "http-2a");
            Assert.IsTrue(p._IsBaseOf(http, u), "http-2b");

            u = new Uri("http://www.mono-project.com/");
            Assert.IsTrue(p._IsBaseOf(u, http), "http-3a");
            Assert.IsTrue(p._IsBaseOf(http, u), "http-3b");

            u = new Uri("http://www.mono-project.com/Main_Page/");
            Assert.IsFalse(p._IsBaseOf(u, http), "http-4a");
            Assert.IsTrue(p._IsBaseOf(http, u), "http-4b");

            // docs says the UserInfo isn't evaluated, but...
            u = new Uri("http://*****:*****@www.mono-project.com/Main_Page");
            Assert.IsFalse(p._IsBaseOf(u, http), "http-5a");
            Assert.IsFalse(p._IsBaseOf(http, u), "http-5b");

            // scheme case sensitive ? no
            u = new Uri("HTTP://www.mono-project.com/Main_Page");
            Assert.IsTrue(p._IsBaseOf(u, http), "http-6a");
            Assert.IsTrue(p._IsBaseOf(http, u), "http-6b");

            // host case sensitive ? no
            u = new Uri("http://www.Mono-Project.com/Main_Page");
            Assert.IsTrue(p._IsBaseOf(u, http), "http-7a");
            Assert.IsTrue(p._IsBaseOf(http, u), "http-7b");

            // path case sensitive ? no
            u = new Uri("http://www.Mono-Project.com/MAIN_Page");
            Assert.IsTrue(p._IsBaseOf(u, http), "http-8a");
            Assert.IsTrue(p._IsBaseOf(http, u), "http-8b");

            // different scheme
            u = new Uri("ftp://www.mono-project.com/Main_Page");
            Assert.IsFalse(p._IsBaseOf(u, http), "http-9a");
            Assert.IsFalse(p._IsBaseOf(http, u), "http-9b");

            // different host
            u = new Uri("http://www.go-mono.com/Main_Page");
            Assert.IsFalse(p._IsBaseOf(u, http), "http-10a");
            Assert.IsFalse(p._IsBaseOf(http, u), "http-10b");

            // different port
            u = new Uri("http://www.mono-project.com:8080/");
            Assert.IsFalse(p._IsBaseOf(u, http), "http-11a");
            Assert.IsFalse(p._IsBaseOf(http, u), "http-11b");

            // specify default port
            u = new Uri("http://www.mono-project.com:80/");
            Assert.IsTrue(p._IsBaseOf(u, http), "http-12a");
            Assert.IsTrue(p._IsBaseOf(http, u), "http-12b");
        }
示例#32
0
		public void Register_UInt16PortMinus1 ()
		{
			UnitTestUriParser p = new UnitTestUriParser ();
			UriParser.Register (p, prefix + "uint16.minus.1.port", UInt16.MaxValue - 1);
		}
示例#33
0
        public void IsBaseOf_NullUri()
        {
            UnitTestUriParser p = new UnitTestUriParser();

            p._IsBaseOf(null, http);
        }
示例#34
0
		public void GetComponents_Null ()
		{
			UnitTestUriParser p = new UnitTestUriParser ();
			p._GetComponents (null, UriComponents.Host, UriFormat.SafeUnescaped);
		}
示例#35
0
        public void IsWellFormedOriginalString_Null()
        {
            UnitTestUriParser p = new UnitTestUriParser();

            p._IsWellFormedOriginalString(null);
        }
示例#36
0
        public void Register_NullScheme()
        {
            UnitTestUriParser p = new UnitTestUriParser();

            UriParser.Register(p, null, 2006);
        }
示例#37
0
		public void Register_TooBigPort ()
		{
			UnitTestUriParser p = new UnitTestUriParser ();
			UriParser.Register (p, prefix + "too.big.port", UInt16.MaxValue);
		}
示例#38
0
		public void IsWellFormedOriginalString ()
		{
			UnitTestUriParser p = new UnitTestUriParser ();
			Assert.IsTrue (p._IsWellFormedOriginalString (http), "http");
		}
示例#39
0
		public void GetComponents_BadUriComponents ()
		{
			UnitTestUriParser p = new UnitTestUriParser ();
			Assert.AreEqual (full_http, p._GetComponents (http, (UriComponents) Int32.MinValue, UriFormat.SafeUnescaped), "http");
		}
示例#40
0
		public void ReRegister ()
		{
			string scheme = prefix + "re.register.mono";
			Assert.IsFalse (UriParser.IsKnownScheme (scheme), "IsKnownScheme-false");
			UnitTestUriParser p = new UnitTestUriParser ();
			UriParser.Register (p, scheme, 2005);
			Assert.IsTrue (UriParser.IsKnownScheme (scheme), "IsKnownScheme-true");
			UriParser.Register (p, scheme, 2006);
		}
示例#41
0
		public void GetComponents_Ftp2 ()
		{
			UnitTestUriParser p = new UnitTestUriParser ();
			Assert.AreEqual ("ftp", p._GetComponents (ftp2, UriComponents.Scheme, UriFormat.Unescaped), "ftp.Scheme");
			Assert.AreEqual ("username:password", p._GetComponents (ftp2, UriComponents.UserInfo, UriFormat.Unescaped), "ftp.UserInfo");
			Assert.AreEqual ("ftp.go-mono.com", p._GetComponents (ftp2, UriComponents.Host, UriFormat.Unescaped), "ftp.Host");
			Assert.AreEqual (String.Empty, p._GetComponents (ftp2, UriComponents.Port, UriFormat.Unescaped), "ftp.Port");
			Assert.AreEqual ("with some spaces/mono.tgz", p._GetComponents (ftp2, UriComponents.Path, UriFormat.Unescaped), "ftp.Path");
			Assert.AreEqual ("with%20some%20spaces/mono.tgz", p._GetComponents (ftp2, UriComponents.Path, UriFormat.UriEscaped), "ftp.Path-UriEscaped");
			Assert.AreEqual ("with some spaces/mono.tgz", p._GetComponents (ftp2, UriComponents.Path, UriFormat.SafeUnescaped), "ftp.Path-SafeUnescaped");
			Assert.AreEqual (String.Empty, p._GetComponents (ftp2, UriComponents.Query, UriFormat.Unescaped), "ftp.Query");
			Assert.AreEqual (String.Empty, p._GetComponents (ftp2, UriComponents.Fragment, UriFormat.Unescaped), "ftp.Fragment");
			Assert.AreEqual ("21", p._GetComponents (ftp2, UriComponents.StrongPort, UriFormat.Unescaped), "ftp.StrongPort");
			Assert.AreEqual (String.Empty, p._GetComponents (ftp2, UriComponents.KeepDelimiter, UriFormat.Unescaped), "http.KeepDelimiter");
			Assert.AreEqual ("ftp.go-mono.com:21", p._GetComponents (ftp2, UriComponents.HostAndPort, UriFormat.Unescaped), "http.HostAndPort");
			Assert.AreEqual ("username:[email protected]:21", p._GetComponents (ftp2, UriComponents.StrongAuthority, UriFormat.Unescaped), "http.StrongAuthority");
			Assert.AreEqual ("ftp://*****:*****@ftp.go-mono.com/with some spaces/mono.tgz", p._GetComponents (ftp2, UriComponents.AbsoluteUri, UriFormat.Unescaped), "http.AbsoluteUri");
			Assert.AreEqual ("/with some spaces/mono.tgz", p._GetComponents (ftp2, UriComponents.PathAndQuery, UriFormat.Unescaped), "http.PathAndQuery");
			Assert.AreEqual ("ftp://ftp.go-mono.com/with some spaces/mono.tgz", p._GetComponents (ftp2, UriComponents.HttpRequestUrl, UriFormat.Unescaped), "http.HttpRequestUrl");
			Assert.AreEqual ("ftp://ftp.go-mono.com", p._GetComponents (ftp2, UriComponents.SchemeAndServer, UriFormat.Unescaped), "http.SchemeAndServer");
			Assert.AreEqual ("ftp://*****:*****@ftp.go-mono.com/with some spaces/mono.tgz", p._GetComponents (ftp2, UriComponents.SerializationInfoString, UriFormat.Unescaped), "http.SerializationInfoString");
			Assert.AreSame (p, p._OnNewUri (), "OnNewUri");
			// strange mixup
			Assert.AreEqual ("ftp://*****:*****@", p._GetComponents (ftp2, UriComponents.Scheme | UriComponents.UserInfo, UriFormat.Unescaped), "ftp.Scheme+UserInfo");
			Assert.AreEqual (":21/with some spaces/mono.tgz", p._GetComponents (ftp2, UriComponents.Path | UriComponents.StrongPort, UriFormat.Unescaped), "ftp.Path+StrongPort");
		}
示例#42
0
		// oh man, this is a bad boy.It should be ArgumentNullException.
		public void InitializeAndValidate_Null ()
		{
			UriFormatException error = null;
			UnitTestUriParser p = new UnitTestUriParser ();
			p._InitializeAndValidate (null, out error);
		}
示例#43
0
        public void Register_NegativePort()
        {
            UnitTestUriParser p = new UnitTestUriParser();

            UriParser.Register(p, prefix + "negative.port", -2);
        }
示例#44
0
        public void GetComponents_Null()
        {
            UnitTestUriParser p = new UnitTestUriParser();

            p._GetComponents(null, UriComponents.Host, UriFormat.SafeUnescaped);
        }
示例#45
0
        public void Register_UInt16PortMinus1()
        {
            UnitTestUriParser p = new UnitTestUriParser();

            UriParser.Register(p, prefix + "uint16.minus.1.port", UInt16.MaxValue - 1);
        }
示例#46
0
        public void GetComponents_BadUriComponents()
        {
            UnitTestUriParser p = new UnitTestUriParser();

            Assert.AreEqual(full_http, p._GetComponents(http, (UriComponents)Int32.MinValue, UriFormat.SafeUnescaped), "http");
        }
示例#47
0
		public void GetComponents ()
		{
			UnitTestUriParser p = new UnitTestUriParser ();
			Assert.AreEqual ("http", p._GetComponents (http, UriComponents.Scheme, UriFormat.SafeUnescaped), "http.Scheme");
			Assert.AreEqual (String.Empty, p._GetComponents (http, UriComponents.UserInfo, UriFormat.SafeUnescaped), "http.UserInfo");
			Assert.AreEqual ("www.mono-project.com", p._GetComponents (http, UriComponents.Host, UriFormat.SafeUnescaped), "http.Host");
			Assert.AreEqual (String.Empty, p._GetComponents (http, UriComponents.Port, UriFormat.SafeUnescaped), "http.Port");
			Assert.AreEqual ("Main_Page", p._GetComponents (http, UriComponents.Path, UriFormat.SafeUnescaped), "http.Path");
			Assert.AreEqual (String.Empty, p._GetComponents (http, UriComponents.Query, UriFormat.SafeUnescaped), "http.Query");
			Assert.AreEqual ("FAQ?Edit", p._GetComponents (http, UriComponents.Fragment, UriFormat.SafeUnescaped), "http.Fragment");
			Assert.AreEqual ("80", p._GetComponents (http, UriComponents.StrongPort, UriFormat.SafeUnescaped), "http.StrongPort");
			Assert.AreEqual (String.Empty, p._GetComponents (http, UriComponents.KeepDelimiter, UriFormat.SafeUnescaped), "http.KeepDelimiter");
			Assert.AreEqual ("www.mono-project.com:80", p._GetComponents (http, UriComponents.HostAndPort, UriFormat.SafeUnescaped), "http.HostAndPort");
			Assert.AreEqual ("www.mono-project.com:80", p._GetComponents (http, UriComponents.StrongAuthority, UriFormat.SafeUnescaped), "http.StrongAuthority");
			Assert.AreEqual (full_http, p._GetComponents (http, UriComponents.AbsoluteUri, UriFormat.SafeUnescaped), "http.AbsoluteUri");
			Assert.AreEqual ("/Main_Page", p._GetComponents (http, UriComponents.PathAndQuery, UriFormat.SafeUnescaped), "http.PathAndQuery");
			Assert.AreEqual ("http://www.mono-project.com/Main_Page", p._GetComponents (http, UriComponents.HttpRequestUrl, UriFormat.SafeUnescaped), "http.HttpRequestUrl");
			Assert.AreEqual ("http://www.mono-project.com", p._GetComponents (http, UriComponents.SchemeAndServer, UriFormat.SafeUnescaped), "http.SchemeAndServer");
			Assert.AreEqual (full_http, p._GetComponents (http, UriComponents.SerializationInfoString, UriFormat.SafeUnescaped), "http.SerializationInfoString");
			// strange mixup
			Assert.AreEqual ("http://", p._GetComponents (http, UriComponents.Scheme | UriComponents.Port, UriFormat.SafeUnescaped), "http.Scheme+Port");
			Assert.AreEqual ("www.mono-project.com#FAQ?Edit", p._GetComponents (http, UriComponents.Host | UriComponents.Fragment, UriFormat.SafeUnescaped), "http.Scheme+Port");
			Assert.AreEqual ("/Main_Page", p._GetComponents (http, UriComponents.Port | UriComponents.Path, UriFormat.SafeUnescaped), "http.Scheme+Port");
			Assert.AreSame (p, p._OnNewUri (), "OnNewUri");
		}
示例#48
0
		public void IsBaseOf ()
		{
			UnitTestUriParser p = new UnitTestUriParser ();
			Assert.IsTrue (p._IsBaseOf (http, http), "http-http");

			Uri u = new Uri ("http://www.mono-project.com/Main_Page#FAQ");
			Assert.IsTrue (p._IsBaseOf (u, http), "http-1a");
			Assert.IsTrue (p._IsBaseOf (http, u), "http-1b");

			u = new Uri ("http://www.mono-project.com/Main_Page");
			Assert.IsTrue (p._IsBaseOf (u, http), "http-2a");
			Assert.IsTrue (p._IsBaseOf (http, u), "http-2b");

			u = new Uri ("http://www.mono-project.com/");
			Assert.IsTrue (p._IsBaseOf (u, http), "http-3a");
			Assert.IsTrue (p._IsBaseOf (http, u), "http-3b");

			u = new Uri ("http://www.mono-project.com/Main_Page/");
			Assert.IsFalse (p._IsBaseOf (u, http), "http-4a");
			Assert.IsTrue (p._IsBaseOf (http, u), "http-4b");

			// docs says the UserInfo isn't evaluated, but...
			u = new Uri ("http://*****:*****@www.mono-project.com/Main_Page");
			Assert.IsFalse (p._IsBaseOf (u, http), "http-5a");
			Assert.IsFalse (p._IsBaseOf (http, u), "http-5b");

			// scheme case sensitive ? no
			u = new Uri ("HTTP://www.mono-project.com/Main_Page");
			Assert.IsTrue (p._IsBaseOf (u, http), "http-6a");
			Assert.IsTrue (p._IsBaseOf (http, u), "http-6b");

			// host case sensitive ? no
			u = new Uri ("http://www.Mono-Project.com/Main_Page");
			Assert.IsTrue (p._IsBaseOf (u, http), "http-7a");
			Assert.IsTrue (p._IsBaseOf (http, u), "http-7b");

			// path case sensitive ? no
			u = new Uri ("http://www.Mono-Project.com/MAIN_Page");
			Assert.IsTrue (p._IsBaseOf (u, http), "http-8a");
			Assert.IsTrue (p._IsBaseOf (http, u), "http-8b");

			// different scheme
			u = new Uri ("ftp://www.mono-project.com/Main_Page");
			Assert.IsFalse (p._IsBaseOf (u, http), "http-9a");
			Assert.IsFalse (p._IsBaseOf (http, u), "http-9b");

			// different host
			u = new Uri ("http://www.go-mono.com/Main_Page");
			Assert.IsFalse (p._IsBaseOf (u, http), "http-10a");
			Assert.IsFalse (p._IsBaseOf (http, u), "http-10b");

			// different port
			u = new Uri ("http://www.mono-project.com:8080/");
			Assert.IsFalse (p._IsBaseOf (u, http), "http-11a");
			Assert.IsFalse (p._IsBaseOf (http, u), "http-11b");

			// specify default port
			u = new Uri ("http://www.mono-project.com:80/");
			Assert.IsTrue (p._IsBaseOf (u, http), "http-12a");
			Assert.IsTrue (p._IsBaseOf (http, u), "http-12b");
		}