2 // DataServiceProviderMethods.cs
5 // Marek Habersack <grendel@twistedcode.net>
7 // Copyright (c) 2011 Novell, Inc
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:
16 // The above copyright notice and this permission notice shall be included in
17 // all copies or substantial portions of the Software.
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
29 using System.Collections.Generic;
30 using System.Data.Services.Providers;
32 using NUnit.Framework;
33 using MonoTests.Common;
35 namespace MonoTests.System.Data.Services.Providers
38 public class DataServiceProviderMethodsTest
43 var rt = new ResourceType (typeof (string), ResourceTypeKind.ComplexType, null, "System", "String", false);
44 AssertExtensions.Throws<NotImplementedException> (() => {
45 DataServiceProviderMethods.TypeIs ("test", rt);
48 AssertExtensions.Throws<NotImplementedException> (() => {
49 DataServiceProviderMethods.TypeIs (null, null);
54 public void Convert ()
56 var rt = new ResourceType (typeof (string), ResourceTypeKind.ComplexType, null, "System", "String", false);
57 AssertExtensions.Throws<NotImplementedException> (() => {
58 DataServiceProviderMethods.Convert ("test", rt);
61 AssertExtensions.Throws<NotImplementedException> (() => {
62 DataServiceProviderMethods.Convert (null, null);
67 public void GetSequenceValue ()
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);
75 AssertExtensions.Throws<NotImplementedException> (() => {
76 DataServiceProviderMethods.GetSequenceValue<string> (null, null);
81 public void GetValue ()
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);
89 AssertExtensions.Throws<NotImplementedException> (() => {
90 DataServiceProviderMethods.GetValue (null, null);
95 public void Compare_String_String ()
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");
107 public void Compare_Bool_Bool ()
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");
116 public void Compare_NullableBool_NullableBool ()
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");
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");
131 public void Compare_Guid_Guid ()
133 var guid1 = new Guid ("bdec809c-f8c5-4bc9-8b56-fb34a12a3e1c");
134 var guid2 = new Guid ("898b2fe2-3530-4f56-85de-79344e59a90f");
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");
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");
147 public void Compare_NullableGuid_NullableGuid ()
149 var guid1 = new Guid ("bdec809c-f8c5-4bc9-8b56-fb34a12a3e1c");
150 var guid2 = new Guid ("898b2fe2-3530-4f56-85de-79344e59a90f");
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");
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");
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");