[System] UriKind.RelativeOrAbsolute workaround.
[mono.git] / mcs / class / System.Data.Services / Test / System.Data.Services.Providers / DataServiceProviderMethodsTest.cs
1 // 
2 // DataServiceProviderMethods.cs
3 //  
4 // Author:
5 //       Marek Habersack <grendel@twistedcode.net>
6 // 
7 // Copyright (c) 2011 Novell, Inc
8 // 
9 // Permission is hereby granted, free of charge, to any person obtaining a copy
10 // of this software and associated documentation files (the "Software"), to deal
11 // in the Software without restriction, including without limitation the rights
12 // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
13 // copies of the Software, and to permit persons to whom the Software is
14 // furnished to do so, subject to the following conditions:
15 // 
16 // The above copyright notice and this permission notice shall be included in
17 // all copies or substantial portions of the Software.
18 // 
19 // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
20 // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
21 // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
22 // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
23 // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
24 // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
25 // THE SOFTWARE.
26
27 #if NET_4_0
28 using System;
29 using System.Collections.Generic;
30 using System.Data.Services.Providers;
31
32 using NUnit.Framework;
33 using MonoTests.Common;
34
35 namespace MonoTests.System.Data.Services.Providers
36 {
37         [TestFixture]
38         public class DataServiceProviderMethodsTest
39         {
40                 [Test]
41                 public void TypeIs ()
42                 {
43                         var rt = new ResourceType (typeof (string), ResourceTypeKind.ComplexType, null, "System", "String", false);
44                         AssertExtensions.Throws<NotImplementedException> (() => {
45                                 DataServiceProviderMethods.TypeIs ("test", rt);
46                         }, "#A1");
47
48                         AssertExtensions.Throws<NotImplementedException> (() => {
49                                 DataServiceProviderMethods.TypeIs (null, null);
50                         }, "#A2");
51                 }
52
53                 [Test]
54                 public void Convert ()
55                 {
56                         var rt = new ResourceType (typeof (string), ResourceTypeKind.ComplexType, null, "System", "String", false);
57                         AssertExtensions.Throws<NotImplementedException> (() => {
58                                 DataServiceProviderMethods.Convert ("test", rt);
59                         }, "#A1");
60
61                         AssertExtensions.Throws<NotImplementedException> (() => {
62                                 DataServiceProviderMethods.Convert (null, null);
63                         }, "#A2");
64                 }
65
66                 [Test]
67                 public void GetSequenceValue ()
68                 {
69                         var rt = new ResourceType (typeof (string), ResourceTypeKind.ComplexType, null, "System", "String", false);
70                         var rp = new ResourceProperty ("Length", ResourcePropertyKind.ComplexType, rt);
71                         AssertExtensions.Throws<NotImplementedException> (() => {
72                                 DataServiceProviderMethods.GetSequenceValue<string> ("test", rp);
73                         }, "#A1");
74
75                         AssertExtensions.Throws<NotImplementedException> (() => {
76                                 DataServiceProviderMethods.GetSequenceValue<string> (null, null);
77                         }, "#A2");
78                 }
79
80                 [Test]
81                 public void GetValue ()
82                 {
83                         var rt = new ResourceType (typeof (string), ResourceTypeKind.ComplexType, null, "System", "String", false);
84                         var rp = new ResourceProperty ("Length", ResourcePropertyKind.ComplexType, rt);
85                         AssertExtensions.Throws<NotImplementedException> (() => {
86                                 DataServiceProviderMethods.GetValue ("test", rp);
87                         }, "#A1");
88
89                         AssertExtensions.Throws<NotImplementedException> (() => {
90                                 DataServiceProviderMethods.GetValue (null, null);
91                         }, "#A2");
92                 }
93
94                 [Test]
95                 public void Compare_String_String ()
96                 {
97                         Assert.AreEqual (1, DataServiceProviderMethods.Compare ("right", "left"), "#A1");
98                         Assert.AreEqual (0, DataServiceProviderMethods.Compare ("right", "right"), "#A2");
99                         Assert.AreEqual (0, DataServiceProviderMethods.Compare (String.Empty, String.Empty), "#A3");
100                         Assert.AreEqual (-1, DataServiceProviderMethods.Compare ("left", "right"), "#A4");
101                         Assert.AreEqual (-1, DataServiceProviderMethods.Compare (null, "right"), "#A5");
102                         Assert.AreEqual (1, DataServiceProviderMethods.Compare ("right", null), "#A6");
103                         Assert.AreEqual (0, DataServiceProviderMethods.Compare ((string)null, (string)null), "#A7");
104                 }
105
106                 [Test]
107                 public void Compare_Bool_Bool ()
108                 {
109                         Assert.AreEqual (-1, DataServiceProviderMethods.Compare (false, true), "#A1");
110                         Assert.AreEqual (0, DataServiceProviderMethods.Compare (false, false), "#A2");
111                         Assert.AreEqual (1, DataServiceProviderMethods.Compare (true, false), "#A3");
112                         Assert.AreEqual (0, DataServiceProviderMethods.Compare (true, true), "#A4");
113                 }
114
115                 [Test]
116                 public void Compare_NullableBool_NullableBool ()
117                 {
118                         Assert.AreEqual (-1, DataServiceProviderMethods.Compare ((bool?) false, (bool?) true), "#A1");
119                         Assert.AreEqual (0, DataServiceProviderMethods.Compare ((bool?) false, (bool?) false), "#A2");
120                         Assert.AreEqual (1, DataServiceProviderMethods.Compare ((bool?) true, (bool?) false), "#A3");
121                         Assert.AreEqual (0, DataServiceProviderMethods.Compare ((bool?) true, (bool?) true), "#A4");
122
123                         Assert.AreEqual (1, DataServiceProviderMethods.Compare ((bool?) false, null), "#B1");
124                         Assert.AreEqual (1, DataServiceProviderMethods.Compare ((bool?) true, null), "#B2");
125                         Assert.AreEqual (-1, DataServiceProviderMethods.Compare (null, (bool?)false), "#B3");
126                         Assert.AreEqual (-1, DataServiceProviderMethods.Compare (null, (bool?) true), "#B4");
127                         Assert.AreEqual (0, DataServiceProviderMethods.Compare ((bool?) null, (bool?) null), "#B5");
128                 }
129
130                 [Test]
131                 public void Compare_Guid_Guid ()
132                 {
133                         var guid1 = new Guid ("bdec809c-f8c5-4bc9-8b56-fb34a12a3e1c");
134                         var guid2 = new Guid ("898b2fe2-3530-4f56-85de-79344e59a90f");
135
136                         Assert.AreEqual (1, DataServiceProviderMethods.Compare (guid1, guid2), "#A1");
137                         Assert.AreEqual (0, DataServiceProviderMethods.Compare (guid1, guid1), "#A2");
138                         Assert.AreEqual (-1, DataServiceProviderMethods.Compare (guid2, guid1), "#A3");
139
140                         guid1 = new Guid ("00000000-0000-0000-0000-000000000000");
141                         guid2 = new Guid ("00000000-0000-0000-0000-000000000001");
142                         Assert.AreEqual (-1, DataServiceProviderMethods.Compare (guid1, guid2), "#B1");
143                         Assert.AreEqual (1, DataServiceProviderMethods.Compare (guid2, guid1), "#B2");
144                 }
145
146                 [Test]
147                 public void Compare_NullableGuid_NullableGuid ()
148                 {
149                         var guid1 = new Guid ("bdec809c-f8c5-4bc9-8b56-fb34a12a3e1c");
150                         var guid2 = new Guid ("898b2fe2-3530-4f56-85de-79344e59a90f");
151
152                         Assert.AreEqual (1, DataServiceProviderMethods.Compare (guid1, guid2), "#A1");
153                         Assert.AreEqual (0, DataServiceProviderMethods.Compare (guid1, guid1), "#A2");
154                         Assert.AreEqual (-1, DataServiceProviderMethods.Compare (guid2, guid1), "#A3");
155
156                         guid1 = new Guid ("00000000-0000-0000-0000-000000000000");
157                         guid2 = new Guid ("00000000-0000-0000-0000-000000000001");
158                         Assert.AreEqual (-1, DataServiceProviderMethods.Compare (guid1, guid2), "#B1");
159                         Assert.AreEqual (1, DataServiceProviderMethods.Compare (guid2, guid1), "#B2");
160
161                         Assert.AreEqual (1, DataServiceProviderMethods.Compare ((Guid?)guid1, (Guid?)null), "#C1");
162                         Assert.AreEqual (0, DataServiceProviderMethods.Compare ((Guid?)null, (Guid?)null), "#C2");
163                         Assert.AreEqual (-1, DataServiceProviderMethods.Compare ((Guid?) null, (Guid?)guid1), "#C3");
164                 }
165         }
166 }
167 #endif