Mercurial > pub > bltoolkit
comparison UnitTests/DataProvider/FireBird/CreateDatabase.cs @ 0:f990fcb411a9
Копия текущей версии из github
| author | cin |
|---|---|
| date | Thu, 27 Mar 2014 21:46:09 +0400 |
| parents | |
| children |
comparison
equal
deleted
inserted
replaced
| -1:000000000000 | 0:f990fcb411a9 |
|---|---|
| 1 using System; | |
| 2 using System.Configuration; | |
| 3 using System.IO; | |
| 4 using BLToolkit.Data; | |
| 5 using FirebirdSql.Data.FirebirdClient; | |
| 6 using NUnit.Framework; | |
| 7 | |
| 8 namespace UnitTests.CS | |
| 9 { | |
| 10 [TestFixture, Explicit, Category("DB setup")] | |
| 11 public class CreateDatabase | |
| 12 { | |
| 13 [Test] | |
| 14 public void Test() | |
| 15 { | |
| 16 FbConnection.CreateDatabase(ConfigurationManager.AppSettings.Get("ConnectionString.Fdp"), true); | |
| 17 | |
| 18 const string path = @"..\..\..\..\Data\Create Scripts\Firebird2.sql"; | |
| 19 | |
| 20 using (DbManager db = new DbManager()) | |
| 21 { | |
| 22 string cmd = string.Empty; | |
| 23 string term = ";"; | |
| 24 | |
| 25 foreach (string s in File.ReadAllLines(path)) | |
| 26 { | |
| 27 string line = s.TrimEnd(); | |
| 28 if (!line.EndsWith(term)) | |
| 29 { | |
| 30 cmd += line + Environment.NewLine; | |
| 31 continue; | |
| 32 } | |
| 33 | |
| 34 line = line.Substring(0, line.Length - term.Length).Trim(); | |
| 35 | |
| 36 if (line.ToUpperInvariant().StartsWith("SET TERM ")) | |
| 37 { | |
| 38 term = line.Substring("SET TERM ".Length).Trim(); | |
| 39 continue; | |
| 40 } | |
| 41 | |
| 42 if (line.ToUpperInvariant().StartsWith("COMMIT")) | |
| 43 { | |
| 44 continue; | |
| 45 } | |
| 46 | |
| 47 Console.WriteLine("Executing script:"); | |
| 48 Console.WriteLine(cmd + line); | |
| 49 | |
| 50 db | |
| 51 .SetCommand(cmd + line) | |
| 52 .ExecuteNonQuery() | |
| 53 ; | |
| 54 | |
| 55 Console.WriteLine("Succeeded."); | |
| 56 | |
| 57 cmd = string.Empty; | |
| 58 } | |
| 59 | |
| 60 } | |
| 61 } | |
| 62 } | |
| 63 } |
