2 // NetPipeStyleUriParserTest.cs - Unit tests for System.NetPipeStyleUriParser
5 // Sebastien Pouliot <sebastien@ximian.com>
7 // Copyright (C) 2005 Novell, Inc (http://www.novell.com)
9 // Permission is hereby granted, free of charge, to any person obtaining
10 // a copy of this software and associated documentation files (the
11 // "Software"), to deal in the Software without restriction, including
12 // without limitation the rights to use, copy, modify, merge, publish,
13 // distribute, sublicense, and/or sell copies of the Software, and to
14 // permit persons to whom the Software is furnished to do so, subject to
15 // the following conditions:
17 // The above copyright notice and this permission notice shall be
18 // included in all copies or substantial portions of the Software.
20 // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
21 // EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
22 // MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
23 // NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
24 // LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
25 // OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
26 // WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
30 using NUnit.Framework;
35 namespace MonoTests.System {
37 public class UnitTestNetPipeStyleUriParser: NetPipeStyleUriParser {
39 static bool registered;
41 public static bool Registered {
42 get { return registered; }
45 protected override string GetComponents (Uri uri, UriComponents components, UriFormat format)
47 throw new UriFormatException ();
48 // return components.ToString ();
51 protected override void InitializeAndValidate (Uri uri, out UriFormatException parsingError)
53 throw new NotImplementedException ();
54 // base.InitializeAndValidate (uri, out parsingError);
57 protected override bool IsBaseOf (Uri baseUri, Uri relativeUri)
59 throw new NotSupportedException ();
60 // return base.IsBaseOf (baseUri, relativeUri);
63 protected override bool IsWellFormedOriginalString (Uri uri)
65 throw new FormatException ();
66 // return base.IsWellFormedOriginalString (uri);
69 protected override UriParser OnNewUri ()
71 throw new OverflowException ();
72 // return base.OnNewUri ();
75 protected override void OnRegister (string schemeName, int defaultPort)
78 // try to mess up registration
79 base.OnRegister (schemeName, 4040);
80 base.OnRegister ("s" + schemeName, 4444);
83 protected override string Resolve (Uri baseUri, Uri relativeUri, out UriFormatException parsingError)
85 throw new OutOfMemoryException ();
86 // return base.Resolve (baseUri, relativeUri, out parsingError);
91 public class NetPipeStyleUriParserTest {
93 private UnitTestNetPipeStyleUriParser parser;
96 public void FixtureSetUp ()
98 parser = new UnitTestNetPipeStyleUriParser ();
99 // unit tests are being reused in CAS tests
100 if (!UriParser.IsKnownScheme ("net.pipex"))
101 UriParser.Register (parser, "net.pipex", 2);
103 Assert.IsTrue (UnitTestNetPipeStyleUriParser.Registered, "Registered");
104 // our parser code was called
108 public void NetPipeX ()
110 Uri uri = new Uri ("net.pipex://www.mono-project.com/");
111 Assert.AreEqual (2, uri.Port, "Port");
112 // OnRegister cannot be used to change the registering informations
116 [Category ("NotWorking")]
117 public void NetPipeX_Methods ()
119 Uri uri = new Uri ("net.pipex://www.mono-project.com/");
120 Assert.AreEqual (String.Empty, uri.GetComponents (UriComponents.Path, UriFormat.SafeUnescaped), "GetComponents");
121 Assert.IsTrue (uri.IsBaseOf (uri), "IsBaseOf");
122 Assert.IsTrue (uri.IsWellFormedOriginalString (), "IsWellFormedOriginalString");
123 // ??? our parser doesn't seems to be called :(
127 public void SecureNetPipeX ()
129 Uri uri = new Uri ("snet.pipex://www.mono-project.com/");
130 Assert.AreEqual (-1, uri.Port, "Port");
131 // OnRegister cannot be used to change the registering informations