2 * Firebird ADO.NET Data provider for .NET and Mono
4 * The contents of this file are subject to the Initial
5 * Developer's Public License Version 1.0 (the "License");
6 * you may not use this file except in compliance with the
7 * License. You may obtain a copy of the License at
8 * http://www.firebirdsql.org/index.php?op=doc&id=idpl
10 * Software distributed under the License is distributed on
11 * an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, either
12 * express or implied. See the License for the specific
13 * language governing rights and limitations under the License.
15 * Copyright (c) 2002, 2005 Carlos Guzman Alvarez
16 * All Rights Reserved.
21 using FirebirdSql.Data.Firebird;
22 using NUnit.Framework;
24 namespace FirebirdSql.Data.Firebird.Tests
27 /// All the test in this TestFixture are using implicit transaction support.
30 public class GuidTest : BaseTest
32 public GuidTest() : base()
37 public void InsertGuidTest()
39 FbCommand createTable = new FbCommand("CREATE TABLE GUID_TEST (GUID_FIELD CHAR(16) CHARACTER SET OCTETS)", Connection);
40 createTable.ExecuteNonQuery();
41 createTable.Dispose();
43 Guid newGuid = Guid.Empty;
44 Guid guidValue = Guid.NewGuid();
47 FbCommand insert = new FbCommand("INSERT INTO GUID_TEST (GUID_FIELD) VALUES (@GuidValue)", Connection);
48 insert.Parameters.Add("@GuidValue", FbDbType.Guid).Value = guidValue;
49 insert.ExecuteNonQuery();
53 FbCommand select = new FbCommand("SELECT * FROM GUID_TEST", Connection);
54 FbDataReader r = select.ExecuteReader();
57 newGuid = r.GetGuid(0);
60 Assert.AreEqual(guidValue, newGuid);
64 public void InsertNullGuidTest()
66 FbCommand createTable = new FbCommand("CREATE TABLE GUID_TEST (INT_FIELD INTEGER, GUID_FIELD CHAR(16) CHARACTER SET OCTETS)", Connection);
67 createTable.ExecuteNonQuery();
68 createTable.Dispose();
71 FbCommand insert = new FbCommand("INSERT INTO GUID_TEST (INT_FIELD, GUID_FIELD) VALUES (@IntField, @GuidValue)", Connection);
72 insert.Parameters.Add("@IntField", FbDbType.Integer).Value = this.GetId();
73 insert.Parameters.Add("@GuidValue", FbDbType.Guid).Value = DBNull.Value;
74 insert.ExecuteNonQuery();
78 FbCommand select = new FbCommand("SELECT * FROM GUID_TEST", Connection);
79 FbDataReader r = select.ExecuteReader();
84 throw new Exception();