DeveelDB  20151217
complete SQL database system, primarly developed for .NET/Mono frameworks
BooleanTypeTest.cs
Go to the documentation of this file.
1 //
2 // Copyright 2010-2014 Deveel
3 //
4 // Licensed under the Apache License, Version 2.0 (the "License");
5 // you may not use this file except in compliance with the License.
6 // You may obtain a copy of the License at
7 //
8 // http://www.apache.org/licenses/LICENSE-2.0
9 //
10 // Unless required by applicable law or agreed to in writing, software
11 // distributed under the License is distributed on an "AS IS" BASIS,
12 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 // See the License for the specific language governing permissions and
14 // limitations under the License.
15 
16 using System;
17 
18 using Deveel.Data.Sql.Objects;
19 
20 using NUnit.Framework;
21 
22 namespace Deveel.Data.Types {
23  [TestFixture]
24  [Category("Booleans")]
25  [Category("Data Types")]
26  public class BooleanTypeTest {
27  [Test]
28  [Category("Comparison")]
29  public void Compare_Booleans() {
30  var type = PrimitiveTypes.Boolean();
31  Assert.IsNotNull(type);
32 
33  Assert.AreEqual(1, type.Compare(SqlBoolean.True, SqlBoolean.False));
34  Assert.AreEqual(-1, type.Compare(SqlBoolean.False, SqlBoolean.True));
35  Assert.AreEqual(0, type.Compare(SqlBoolean.True, SqlBoolean.True));
36  Assert.AreEqual(0, type.Compare(SqlBoolean.False, SqlBoolean.False));
37  }
38 
39  [Test]
40  [Category("Numbers")]
41  [Category("Comparison")]
42  public void Compare_BooleanToNumeric() {
43  var type = PrimitiveTypes.Boolean();
44  Assert.IsNotNull(type);
45 
46  Assert.AreEqual(0, type.Compare(SqlBoolean.True, SqlNumber.One));
47  Assert.AreEqual(0, type.Compare(SqlBoolean.False, SqlNumber.Zero));
48  }
49 
50  [Test]
51  [Category("Numbers")]
52  [Category("Comparison")]
54  var type = PrimitiveTypes.Boolean();
55  Assert.IsNotNull(type);
56 
57  int result = -2;
58  Assert.DoesNotThrow(() => result = type.Compare(SqlBoolean.True, new SqlNumber(22)));
59  Assert.AreEqual(1, result);
60  }
61  }
62 }
Provides some helper functions for resolving and creating SqlType instances that are primitive to the...
static BooleanType Boolean()
static readonly SqlNumber Zero
Definition: SqlNumber.cs:29
static readonly SqlNumber One
Definition: SqlNumber.cs:30