5 // Copyright (c) 2007-2008 Jiri Moudry
\r
7 // Permission is hereby granted, free of charge, to any person obtaining a copy
\r
8 // of this software and associated documentation files (the "Software"), to deal
\r
9 // in the Software without restriction, including without limitation the rights
\r
10 // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
\r
11 // copies of the Software, and to permit persons to whom the Software is
\r
12 // furnished to do so, subject to the following conditions:
\r
14 // The above copyright notice and this permission notice shall be included in
\r
15 // all copies or substantial portions of the Software.
\r
17 // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
\r
18 // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
\r
19 // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
\r
20 // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
\r
21 // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
\r
22 // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
\r
30 using NUnit.Framework;
\r
32 namespace DbMetal_Test_Sqlite
\r
34 class DbMetalAppDomainSetup : MarshalByRefObject
\r
36 public void SetStandardError(TextWriter stderr)
\r
38 Console.SetError(stderr);
\r
41 public void Run(string[] args)
\r
48 public class CreateEntitiesFromSqliteDbTest
\r
51 public void CreateViaProvider()
\r
54 var app = "sqlmetal";
\r
56 var app = "DbMetal";
\r
58 var bd = AppDomain.CurrentDomain.BaseDirectory;
\r
59 var info = new AppDomainSetup()
\r
61 ApplicationBase = bd,
\r
62 ApplicationName = app + ".exe",
\r
63 ConfigurationFile = app + ".exe.config",
\r
65 AppDomain ad = AppDomain.CreateDomain("DbMetal Sqlite Test", null, info);
\r
66 var t = typeof(DbMetalAppDomainSetup);
\r
67 var s = (DbMetalAppDomainSetup)ad.CreateInstanceAndUnwrap(t.Assembly.GetName().Name, t.FullName);
\r
68 var stderr = new StringWriter();
\r
69 s.SetStandardError(stderr);
\r
70 var testdir = Path.Combine(bd, Path.Combine("..", "tests"));
\r
71 var db = Path.Combine(bd, Path.Combine("..", Path.Combine("tests", "Northwind.db3")));
\r
73 "/code:Northwind.Sqlite.cs",
\r
74 "/conn:Data Source=" + Path.Combine(testdir, "Northwind.db3"),
\r
75 "/database:Northwind",
\r
76 "--generate-timestamps-",
\r
81 AppDomain.Unload(ad);
\r
82 if (stderr.GetStringBuilder().Length != 0)
\r
83 Console.Error.Write(stderr.GetStringBuilder().ToString());
\r
84 Assert.AreEqual(0, stderr.GetStringBuilder().Length);
\r
85 FileAssert.AreEqual(Path.Combine(testdir, "Northwind.Expected.Sqlite-" + app + ".cs"), "Northwind.Sqlite.cs");
\r
86 File.Delete("Northwind.Sqlite.cs");
\r
90 public void CreateViaDbSchemaLoader()
\r
93 var app = "sqlmetal";
\r
94 var dbConnectionProvider = "Mono.Data.Sqlite.SqliteConnection, Mono.Data.Sqlite";
\r
95 var dbLinqSchemaLoader = "DbLinq.Vendor.DbSchemaLoader, System.Data.Linq";
\r
96 var sqlDialect = "DbLinq.Sqlite.SqliteVendor, System.Data.Linq";
\r
98 var app = "DbMetal";
\r
99 var dbConnectionProvider = "System.Data.SQLite.SQLiteConnection, System.Data.SQLite";
\r
100 var dbLinqSchemaLoader = "DbLinq.Vendor.DbSchemaLoader, DbLinq";
\r
101 var sqlDialect = "DbLinq.Sqlite.SqliteVendor, DbLinq.Sqlite";
\r
103 var bd = AppDomain.CurrentDomain.BaseDirectory;
\r
104 var testdir = Path.Combine(bd, Path.Combine("..", "tests"));
\r
105 var expectedDir = Path.Combine(testdir, "expected");
\r
107 Program.Main(new string[]{
\r
108 "/code:Northwind.Sqlite.cs",
\r
109 "/conn:Data Source=" + Path.Combine(testdir, "Northwind.db3"),
\r
110 "/database:Northwind",
\r
111 "/databaseConnectionProvider=" + dbConnectionProvider,
\r
112 "/dbLinqSchemaLoaderProvider=" + dbLinqSchemaLoader,
\r
113 "--generate-timestamps-",
\r
114 "/namespace:nwind",
\r
116 "/sqlDialectType=" + sqlDialect,
\r
119 FileAssert.AreEqual(Path.Combine(expectedDir, "Northwind.Sqlite+DbSchemaLoader-" + app + ".cs"), "Northwind.Sqlite.cs");
\r
120 File.Delete("Northwind.Sqlite.cs");
\r