DeveelDB  20151217
complete SQL database system, primarly developed for .NET/Mono frameworks
DataTypeParseTests.cs
Go to the documentation of this file.
1 using System;
2 
3 using Deveel.Data.Services;
4 using Deveel.Data.Spatial;
5 
6 using NUnit.Framework;
7 
8 namespace Deveel.Data.Types {
9  [TestFixture]
10  public sealed class DataTypeParseTests : ContextBasedTest {
11  protected override void RegisterServices(ServiceContainer container) {
12  container.UseSpatial();
13  }
14 
15  [Test]
17  const string typeString = "GEOMETRY";
18 
19  Assert.Throws<NotSupportedException>(() => SqlType.Parse(typeString));
20  }
21 
22  [Test]
23  public void SimpleGeometry() {
24  const string typeString = "GEOMETRY";
25 
26  SqlType type = null;
27  Assert.DoesNotThrow(() => type = SqlType.Parse(Query.Context, typeString));
28  Assert.IsNotNull(type);
29  Assert.IsInstanceOf<SpatialType>(type);
30  Assert.AreEqual(-1, ((SpatialType)type).Srid);
31  }
32 
33  [Test]
34  public void GeometryWithSrid() {
35  const string typeString = "GEOMETRY(SRID = '2029')";
36 
37  SqlType type = null;
38  Assert.DoesNotThrow(() => type = SqlType.Parse(Query.Context, typeString));
39  Assert.IsNotNull(type);
40  Assert.IsInstanceOf<SpatialType>(type);
41  Assert.AreEqual(2029, ((SpatialType)type).Srid);
42  }
43  }
44 }
IQueryContext Context
Definition: Query.cs:68
override void RegisterServices(ServiceContainer container)
Defines the properties of a specific SQL Type and handles the values compatible.
Definition: SqlType.cs:33
static SqlType Parse(string s)
Parses a SQL formatted string that defines a data-type into a constructed SqlType object equivalent...
Definition: SqlType.cs:321