protected virtual void OneTimeSetUp() { ImplementationManager.Load <MicrosoftSQLImplementation>(); ImplementationManager.Load <MySqlImplementation>(); ImplementationManager.Load <OracleImplementation>(); ImplementationManager.Load <PostgreSqlImplementation>(); }
public void Setup() { ImplementationManager.Load( typeof(MicrosoftSQLImplementation).Assembly, typeof(MySqlImplementation).Assembly, typeof(OracleImplementation).Assembly); }
public virtual void OneTimeSetUp() { ImplementationManager.Load( typeof(MicrosoftSQLImplementation).Assembly, typeof(MySqlImplementation).Assembly, typeof(OracleImplementation).Assembly); }
public void EqualityTest_DiscoveredServer_AreEqual(string constr1, DatabaseType type1, string constr2, DatabaseType type2) { ImplementationManager.Load( typeof(MicrosoftSQLImplementation).Assembly, typeof(OracleImplementation).Assembly, typeof(MySqlImplementation).Assembly ); var s1 = new DiscoveredServer(constr1, type1); var s2 = new DiscoveredServer(constr2, type2); Assert.AreEqual(s1, s2); Assert.AreEqual(s1.GetHashCode(), s2.GetHashCode()); Assert.AreEqual(s1.ExpectDatabase("MyDb"), s2.ExpectDatabase("MyDb")); Assert.AreEqual(s1.ExpectDatabase("MyDb").GetHashCode(), s2.ExpectDatabase("MyDb").GetHashCode()); Assert.AreEqual(s1.ExpectDatabase("Mydb"), s2.ExpectDatabase("MyDb")); Assert.AreEqual(s1.ExpectDatabase("Mydb").GetHashCode(), s2.ExpectDatabase("MyDb").GetHashCode()); Assert.AreNotEqual(s1.ExpectDatabase("MyDb"), s2.ExpectDatabase("MyDb2")); //This does not affect things since we are expecting a specific database anyway s1.ChangeDatabase("Dave"); Assert.AreNotEqual(s1, s2); Assert.AreEqual(s1.ExpectDatabase("MyDb"), s2.ExpectDatabase("MyDb")); Assert.AreEqual(s1.ExpectDatabase("MyDb").GetHashCode(), s2.ExpectDatabase("MyDb").GetHashCode()); }
public void Test_LoadAssemblies_FromDirectory() { ImplementationManager.Clear(); Assert.IsNull(ImplementationManager.GetImplementations()); ImplementationManager.Load(new DirectoryInfo(TestContext.CurrentContext.TestDirectory)); Assert.GreaterOrEqual(ImplementationManager.GetImplementations().Count, 3); }
public void Test_GetFullyQualifiedName(DatabaseType dbType) { ImplementationManager.Load(new DirectoryInfo(TestContext.CurrentContext.TestDirectory)); var syntaxHelper = ImplementationManager.GetImplementation(dbType).GetQuerySyntaxHelper(); var name = syntaxHelper.EnsureFullyQualified("mydb", null, "Troll", ",,,"); Assert.AreEqual(",,,", syntaxHelper.GetRuntimeName(name)); switch (dbType) { case DatabaseType.MicrosoftSQLServer: Assert.AreEqual("[mydb]..[Troll].[,,,]", name); break; case DatabaseType.MySql: Assert.AreEqual("`mydb`.`Troll`.`,,,`", name); break; case DatabaseType.Oracle: Assert.AreEqual("\"MYDB\".\"TROLL\".\",,,\"", name); break; case DatabaseType.PostgreSql: Assert.AreEqual("\"mydb\".public.\"Troll\".\",,,\"", name); break; default: throw new ArgumentOutOfRangeException(nameof(dbType), dbType, null); } }
public void SyntaxHelperTest_GetRuntimeName(DatabaseType t, bool expectUpper) { ImplementationManager.Load(new DirectoryInfo(TestContext.CurrentContext.TestDirectory)); var syntaxHelper = ImplementationManager.GetImplementation(t).GetQuerySyntaxHelper(); Assert.AreEqual(expectUpper?"CHI":"chi", syntaxHelper.GetRuntimeName("\"TEST_ScratchArea\".public.\"Biochemistry\".\"chi\"")); Assert.AreEqual(expectUpper?"FRANK":"Frank", syntaxHelper.GetRuntimeName("count(*) as Frank")); Assert.AreEqual(expectUpper?"FRANK":"Frank", syntaxHelper.GetRuntimeName("count(cast(1 as int)) as Frank")); Assert.AreEqual(expectUpper?"FRANK":"Frank", syntaxHelper.GetRuntimeName("[mydb].[mytbl].[mycol] as Frank")); Assert.AreEqual(expectUpper?"FRANK":"Frank", syntaxHelper.GetRuntimeName("[mydb].[mytbl].[mycol] as [Frank]")); Assert.AreEqual(expectUpper?"FRANK":"Frank", syntaxHelper.GetRuntimeName("\"Mydb\".\"mytbl\".\"mycol\" as \"Frank\"")); Assert.AreEqual(expectUpper?"FRANK":"Frank", syntaxHelper.GetRuntimeName("[mydb].[mytbl].[mycol] as `Frank`")); Assert.AreEqual(expectUpper?"MYCOL":"mycol", syntaxHelper.GetRuntimeName("[mydb].[mytbl].[mycol]")); Assert.AreEqual(expectUpper?"ZOMBIE":"zombie", syntaxHelper.GetRuntimeName("dbo.GetMyCoolThing(\"Magic Fun Times\") as zombie")); Assert.AreEqual(expectUpper?"FRANK":"Frank", syntaxHelper.GetRuntimeName("`mydb`.`mytbl`.`mycol` as `Frank`")); Assert.AreEqual(expectUpper?"FRANK":"Frank", syntaxHelper.GetRuntimeName("\"mydb\".\"mytbl\".\"mycol\" as \"Frank\"")); Assert.IsTrue(syntaxHelper.TryGetRuntimeName("\"mydb\".\"mytbl\".\"mycol\" as \"Frank\"", out string name)); Assert.AreEqual(expectUpper?"FRANK":"Frank", name); }
public void TestGetDataTable() { //create an Fo-Dicom dataset var ds = new DicomDataset(new List <DicomItem>() { new DicomShortString(DicomTag.PatientName, "Frank"), new DicomAgeString(DicomTag.PatientAge, "032Y"), new DicomDate(DicomTag.PatientBirthDate, new DateTime(2001, 1, 1)) }); var dt = new DataTable(); var row = ds.ToRow(dt); Assert.AreEqual("Frank", row["PatientName"]); Assert.AreEqual("032Y", row["PatientAge"]); Assert.AreEqual(new DateTime(2001, 1, 1), row["PatientBirthDate"]); //load the MySql implementation of FAnsi ImplementationManager.Load <MySqlImplementation>(); //pick the location of the destination table (must exist, see ExampleTableCreation for how to create) var server = new DiscoveredServer(new MySqlConnectionStringBuilder("Server=myServerAddress;Database=myDataBase;Uid=myUsername;Pwd=myPassword;")); var table = server.ExpectDatabase("MyDb").ExpectTable("MyCoolTable"); //using (IBulkCopy bulkInsert = table.BeginBulkInsert()) //{ // bulkInsert.Upload(dt); //} }
public static void Load() { ImplementationManager.Load <MicrosoftSQLImplementation>(); ImplementationManager.Load <MySqlImplementation>(); ImplementationManager.Load <PostgreSqlImplementation>(); ImplementationManager.Load <OracleImplementation>(); }
protected void SetUpDatabaseTypes() { ImplementationManager.Load( typeof(MicrosoftSQLImplementation).Assembly, typeof(MySqlImplementation).Assembly, typeof(OracleImplementation).Assembly); }
public void SyntaxHelperTest_GetRuntimeName_MultipleCalls(DatabaseType dbType, string runtime, string wrapped) { // NOTE: Oracle does not support such shenanigans https://docs.oracle.com/cd/B19306_01/server.102/b14200/sql_elements008.htm // "neither quoted nor nonquoted identifiers can contain double quotation marks or the null character (\0)." ImplementationManager.Load(new DirectoryInfo(TestContext.CurrentContext.TestDirectory)); var syntaxHelper = ImplementationManager.GetImplementation(dbType).GetQuerySyntaxHelper(); var currentName = runtime; for (int i = 0; i < 10; i++) { if (i % 2 == 0) { Assert.AreEqual(runtime, currentName); currentName = syntaxHelper.EnsureWrapped(currentName); currentName = syntaxHelper.EnsureWrapped(currentName); currentName = syntaxHelper.EnsureWrapped(currentName); } else { Assert.AreEqual(wrapped, currentName); currentName = syntaxHelper.GetRuntimeName(currentName); currentName = syntaxHelper.GetRuntimeName(currentName); currentName = syntaxHelper.GetRuntimeName(currentName); } } }
public void TestGetValueString() { var date = new DateTime(2004, 1, 1); Assert.AreEqual("\"2004-01-01\"", CommandLineHelper.GetValueString(date)); var fi = new FileInfo(TestContext.CurrentContext.TestDirectory); Assert.AreEqual($@"""{TestContext.CurrentContext.TestDirectory}""", CommandLineHelper.GetValueString(fi)); const string db = "db-name"; Assert.AreEqual(db, CommandLineHelper.GetValueString(db)); ImplementationManager.Load <MicrosoftSQLImplementation>(); //notice how server and db don't actually exist, thats cool they implement IMightNotExist var dbInfo = new DiscoveredServer(new SqlConnectionStringBuilder() { DataSource = "server" }).ExpectDatabase("db"); Assert.AreEqual("--database-name=db --database-server=server", CommandLineHelper.CreateArgString("DbInfo", dbInfo)); }
public void CheckFiles() { ImplementationManager.Load( typeof(MicrosoftSQLServerHelper).Assembly, typeof(OracleServerHelper).Assembly, typeof(MySqlServerHelper).Assembly); var file = Path.Combine(TestContext.CurrentContext.TestDirectory, TestFilename); Assert.IsTrue(File.Exists(file), "Could not find " + TestFilename); var doc = XDocument.Load(file); var root = doc.Element("TestDatabases"); if (root == null) { throw new Exception("Missing element 'TestDatabases' in " + TestFilename); } var settings = root.Element("Settings"); if (settings == null) { throw new Exception("Missing element 'Settings' in " + TestFilename); } var e = settings.Element("AllowDatabaseCreation"); if (e == null) { throw new Exception("Missing element 'AllowDatabaseCreation' in " + TestFilename); } AllowDatabaseCreation = Convert.ToBoolean(e.Value); e = settings.Element("TestScratchDatabase"); if (e == null) { throw new Exception("Missing element 'TestScratchDatabase' in " + TestFilename); } _testScratchDatabase = e.Value; foreach (XElement element in root.Elements("TestDatabase")) { var type = element.Element("DatabaseType").Value; DatabaseType databaseType; if (!DatabaseType.TryParse(type, out databaseType)) { throw new Exception("Could not parse DatabaseType " + type); } var constr = element.Element("ConnectionString").Value; TestConnectionStrings.Add(databaseType, constr); } }
public void SyntaxHelperTest_GetRuntimeName(DatabaseType dbType, string expected, string forInput) { ImplementationManager.Load(new DirectoryInfo(TestContext.CurrentContext.TestDirectory)); var syntaxHelper = ImplementationManager.GetImplementation(dbType).GetQuerySyntaxHelper(); Assert.AreEqual(expected, syntaxHelper.GetRuntimeName(forInput)); }
/// <summary> /// <para> /// Call before running <see cref="Startup"/>. Sets up basic assembly redirects to the execution directory /// (see <see cref="AssemblyResolver"/>) and FAnsiSql DBMS implementations. /// </para> /// <para>Note that this method can be used even if you do not then go on to use <see cref="Startup"/> e.g. if you /// are performing a low level operation like patching</para> /// </summary> public static void PreStartup() { AssemblyResolver.SetupAssemblyResolver(); ImplementationManager.Load <MicrosoftSQLImplementation>(); ImplementationManager.Load <MySqlImplementation>(); ImplementationManager.Load <OracleImplementation>(); ImplementationManager.Load <PostgreSqlImplementation>(); }
public void WorkedExampleTest() { //pick some tags that we are interested in (determines the table schema created) var toCreate = new ImageTableTemplate() { Columns = new[] { new ImageColumnTemplate(DicomTag.SOPInstanceUID), new ImageColumnTemplate(DicomTag.Modality) { AllowNulls = true }, new ImageColumnTemplate(DicomTag.PatientID) { AllowNulls = true } } }; //load the Sql Server implementation of FAnsi ImplementationManager.Load <MicrosoftSQLImplementation>(); //decide where you want to create the table var server = new DiscoveredServer(@"Server=localhost\sqlexpress;Database=mydb;Integrated Security=true;", FAnsi.DatabaseType.MicrosoftSQLServer); var db = server.ExpectDatabase("test"); //create the table var tbl = db.CreateTable("MyCoolTable", toCreate.GetColumns(FAnsi.DatabaseType.MicrosoftSQLServer)); //add a column for where the image is on disk tbl.AddColumn("FileLocation", new DatabaseTypeRequest(typeof(string), 500), true, 500); //Create a DataTable in memory for the data we read from disk DataTable dt = new DataTable(); dt.Columns.Add("SOPInstanceUID"); dt.Columns.Add("Modality"); dt.Columns.Add("PatientID"); dt.Columns.Add("FileLocation"); //Load some dicom files and copy tag data into DataTable (where tag exists) foreach (string file in Directory.EnumerateFiles(@"C:\temp\TestDicomFiles", "*.dcm", SearchOption.AllDirectories)) { var dcm = DicomFile.Open(file); var ds = dcm.Dataset; dt.Rows.Add( DicomTypeTranslaterReader.GetCSharpValue(dcm.Dataset, DicomTag.SOPInstanceUID), ds.Contains(DicomTag.Modality) ? DicomTypeTranslaterReader.GetCSharpValue(dcm.Dataset, DicomTag.Modality) : DBNull.Value, ds.Contains(DicomTag.PatientID) ? DicomTypeTranslaterReader.GetCSharpValue(dcm.Dataset, DicomTag.PatientID) : DBNull.Value, file); } //put the DataTable into the database using (var insert = tbl.BeginBulkInsert()) insert.Upload(dt); }
public void Test_IsSupportedType(DatabaseType dbType, string sqlDbType, bool expectedOutcome) { ImplementationManager.Load <OracleImplementation>(); ImplementationManager.Load <MicrosoftSQLImplementation>(); ImplementationManager.Load <MySqlImplementation>(); var tt = ImplementationManager.GetImplementation(dbType).GetQuerySyntaxHelper().TypeTranslater; Assert.AreEqual(expectedOutcome, tt.IsSupportedSQLDBType(sqlDbType), $"Unexpected result for IsSupportedSQLDBType with {dbType}. Input was '{sqlDbType}' expected {expectedOutcome}"); }
private static void PreStartup() { AssemblyResolver.SetupAssemblyResolver(); ImplementationManager.Load( typeof(MicrosoftSQLImplementation).Assembly, typeof(MySqlImplementation).Assembly, typeof(OracleImplementation).Assembly ); }
static DatabaseTests() { CatalogueRepository.SuppressHelpLoading = true; ImplementationManager.Load <MicrosoftSQLImplementation>(); ImplementationManager.Load <MySqlImplementation>(); ImplementationManager.Load <OracleImplementation>(); ImplementationManager.Load <PostgreSqlImplementation>(); ReadSettingsFile(); }
private static int Run(RDMPCommandLineOptions opts) { ImplementationManager.Load <MicrosoftSQLImplementation>(); ImplementationManager.Load <MySqlImplementation>(); ImplementationManager.Load <OracleImplementation>(); ImplementationManager.Load <PostgreSqlImplementation>(); PopulateConnectionStringsFromYamlIfMissing(opts); var listener = new NLogIDataLoadEventListener(false); var checker = new NLogICheckNotifier(true, false); var factory = new RunnerFactory(); opts.DoStartup(GetEnvironmentInfo(), opts.LogStartup ? (ICheckNotifier)checker: new IgnoreAllErrorsCheckNotifier()); //if user wants to run checking chances are they don't want checks to fail becasue of errors logged during startup (MEF shows lots of errors!) if (opts.LogStartup && opts.Command == CommandLineActivity.check) { checker.Worst = LogLevel.Info; } var runner = opts is ConsoleGuiOptions g ? new ConsoleGuiRunner(g): factory.CreateRunner(opts); int runExitCode = runner.Run(opts.GetRepositoryLocator(), listener, checker, new GracefulCancellationToken()); if (opts.Command == CommandLineActivity.check) { checker.OnCheckPerformed(checker.Worst <= LogLevel.Warn ? new CheckEventArgs("Checks Passed", CheckResult.Success) : new CheckEventArgs("Checks Failed", CheckResult.Fail)); } if (runExitCode != 0) { return(runExitCode); } //or if either listener reports error if (listener.Worst >= LogLevel.Error || checker.Worst >= LogLevel.Error) { return(-1); } if (opts.FailOnWarnings && (listener.Worst >= LogLevel.Warn || checker.Worst >= LogLevel.Warn)) { return(1); } return(0); }
public void SyntaxHelperTest_GetRuntimeName_Oracle() { ImplementationManager.Load(new DirectoryInfo(TestContext.CurrentContext.TestDirectory)); var syntaxHelper = ImplementationManager.GetImplementation(DatabaseType.Oracle).GetQuerySyntaxHelper(); Assert.AreEqual("FRANK", syntaxHelper.GetRuntimeName("count(*) as Frank")); Assert.AreEqual("FRANK", syntaxHelper.GetRuntimeName("count(cast(1 as int)) as Frank")); Assert.AreEqual("FRANK", syntaxHelper.GetRuntimeName("count(cast(1 as int)) as \"Frank\"")); Assert.AreEqual("FRANK", syntaxHelper.GetRuntimeName("[mydb].[mytbl].[mycol] as Frank")); Assert.AreEqual("MYCOL", syntaxHelper.GetRuntimeName("[mydb].[mytbl].[mycol]")); }
static DatabaseTests() { CatalogueRepository.SuppressHelpLoading = true; ImplementationManager.Load( typeof(MicrosoftSQLImplementation).Assembly, typeof(OracleImplementation).Assembly, typeof(MySqlImplementation).Assembly ); ReadSettingsFile(); }
public void Example_TableCreation() { //Load implementation assemblies that are relevant to your application ImplementationManager.Load( typeof(FAnsi.Implementations.MicrosoftSQL.MicrosoftSQLImplementation).Assembly, typeof(FAnsi.Implementations.Oracle.OracleImplementation).Assembly, typeof(FAnsi.Implementations.MySql.MySqlImplementation).Assembly); //Create some test data DataTable dt = new DataTable(); dt.Columns.Add("Name"); dt.Columns.Add("DateOfBirth"); dt.Rows.Add("Frank", "2001-01-01"); dt.Rows.Add("Dave", "2001-01-01"); //Create a server object //var server = new DiscoveredServer(@"server=localhost\sqlexpress;Trusted_Connection=True;", DatabaseType.MicrosoftSQLServer); var server = new DiscoveredServer(@"Server=localhost;Uid=root;Pwd=zombie;SSL-Mode=None", DatabaseType.MySql); //Find the database var database = server.ExpectDatabase("FAnsiTests"); //Or create it if (!database.Exists()) { database.Create(); } //Create a table that can store the data in dt var table = database.CreateTable("MyTable", dt); //Table has 2 rows in it Console.WriteLine("Table {0} has {1} rows", table.GetFullyQualifiedName(), table.GetRowCount()); Console.WriteLine("Column Name is of type {0}", table.DiscoverColumn("Name").DataType.SQLType); Console.WriteLine("Column DateOfBirth is of type {0}", table.DiscoverColumn("DateOfBirth").DataType.SQLType); using (DbConnection con = server.GetConnection()) { con.Open(); DbCommand cmd = server.GetCommand("Select * from " + table.GetFullyQualifiedName(), con); DbDataReader r = cmd.ExecuteReader(); while (r.Read()) { Console.WriteLine(string.Join(",", r["Name"], r["DateOfBirth"])); } } //Drop the table afterwards table.Drop(); }
public void Test_GetFullyQualifiedName_BacktickMySql() { ImplementationManager.Load(new DirectoryInfo(TestContext.CurrentContext.TestDirectory)); var syntaxHelper = ImplementationManager.GetImplementation(DatabaseType.MySql).GetQuerySyntaxHelper(); //when names have backticks the correct response is to double back tick them Assert.AreEqual("`ff``ff`", syntaxHelper.EnsureWrapped("ff`ff")); Assert.AreEqual("`d``b`.`ta``ble`", syntaxHelper.EnsureFullyQualified("d`b", null, "ta`ble")); //runtime name should still be the actual name of the column Assert.AreEqual("ff`ff", syntaxHelper.GetRuntimeName("ff`ff")); }
static DatabaseTests() { CatalogueRepository.SuppressHelpLoading = true; // Always ignore SSL when running tests DiscoveredServerHelper.AddConnectionStringKeyword(DatabaseType.MicrosoftSQLServer, "TrustServerCertificate", "true", ConnectionStringKeywordPriority.ApiRule); ImplementationManager.Load <MicrosoftSQLImplementation>(); ImplementationManager.Load <MySqlImplementation>(); ImplementationManager.Load <OracleImplementation>(); ImplementationManager.Load <PostgreSqlImplementation>(); ReadSettingsFile(); }
public void SyntaxHelperTest_GetRuntimeName_Impossible(DatabaseType t) { ImplementationManager.Load(new DirectoryInfo(TestContext.CurrentContext.TestDirectory)); var syntaxHelper = ImplementationManager.GetImplementation(t).GetQuerySyntaxHelper(); var ex = Assert.Throws <RuntimeNameException>(() => syntaxHelper.GetRuntimeName("count(*)")); StringAssert.Contains("Could not determine runtime name for Sql:'count(*)'. It had brackets and no alias.", ex.Message); Assert.Throws <RuntimeNameException>(() => syntaxHelper.GetRuntimeName("dbo.GetMyCoolThing(\"Magic Fun Times\")")); Assert.IsFalse(syntaxHelper.TryGetRuntimeName("count(*)", out _)); Assert.IsFalse(syntaxHelper.TryGetRuntimeName("dbo.GetMyCoolThing(\"Magic Fun Times\")", out _)); }
public void Test_NameValidation(DatabaseType dbType) { ImplementationManager.Load(new DirectoryInfo(TestContext.CurrentContext.TestDirectory)); var syntaxHelper = ImplementationManager.GetImplementation(dbType).GetQuerySyntaxHelper(); Assert.Throws <RuntimeNameException>(() => syntaxHelper.ValidateDatabaseName(null)); Assert.Throws <RuntimeNameException>(() => syntaxHelper.ValidateDatabaseName(" ")); Assert.Throws <RuntimeNameException>(() => syntaxHelper.ValidateDatabaseName("db.table")); Assert.Throws <RuntimeNameException>(() => syntaxHelper.ValidateDatabaseName("db(lol)")); Assert.Throws <RuntimeNameException>(() => syntaxHelper.ValidateDatabaseName(new string('A', syntaxHelper.MaximumDatabaseLength + 1))); Assert.DoesNotThrow(() => syntaxHelper.ValidateDatabaseName("A")); Assert.DoesNotThrow(() => syntaxHelper.ValidateDatabaseName(new string('A', syntaxHelper.MaximumDatabaseLength))); }
public void SyntaxHelperTest_SplitLineIntoSelectSQLAndAlias(string line, string expectedSelectSql, string expectedAlias) { ImplementationManager.Load(new DirectoryInfo(TestContext.CurrentContext.TestDirectory)); foreach (DatabaseType t in new [] { DatabaseType.Oracle, DatabaseType.MySql, DatabaseType.MicrosoftSQLServer }) { var syntaxHelper = ImplementationManager.GetImplementation(t).GetQuerySyntaxHelper(); string selectSQL; string alias; Assert.AreEqual(expectedAlias != null, syntaxHelper.SplitLineIntoSelectSQLAndAlias(line, out selectSQL, out alias)); Assert.AreEqual(expectedSelectSql, selectSQL); Assert.AreEqual(expectedAlias, alias); } }
public void ExampleTableCreation() { var toCreate = new ImageTableTemplate() { Columns = new[] { //pick some tags for the schema new ImageColumnTemplate(DicomTag.SOPInstanceUID) { IsPrimaryKey = true, AllowNulls = false }, new ImageColumnTemplate(DicomTag.PatientAge) { AllowNulls = true }, new ImageColumnTemplate(DicomTag.PatientBirthDate) { AllowNulls = true } } }; //load the Sql Server implementation of FAnsi ImplementationManager.Load <MicrosoftSQLImplementation>(); //decide where you want to create the table (these methods will actually attempt to connect to the database) var server = new DiscoveredServer("Server=myServerAddress;Database=myDataBase;User Id=myUsername;Password=myPassword;", FAnsi.DatabaseType.MicrosoftSQLServer); var db = server.ExpectDatabase("MyDb"); var creator = new ImagingTableCreation(db.Server.GetQuerySyntaxHelper()); var sql = creator.GetCreateTableSql(db, "MyCoolTable", toCreate); //the following Sql gets created Assert.AreEqual( @"CREATE TABLE [MyDb]..[MyCoolTable]( [SOPInstanceUID] varchar(64) NOT NULL , [PatientAge] varchar(4) NULL , [PatientBirthDate] datetime2 NULL , CONSTRAINT PK_MyCoolTable PRIMARY KEY ([SOPInstanceUID])) " .Replace("\r", ""), sql.Replace("\r", "")); //actually do it //creator.CreateTable(db.ExpectTable("MyCoolTable")); }
public void Test_LoadAssemblies_OneAfterAnother() { ImplementationManager.Clear(); Assert.IsNull(ImplementationManager.GetImplementations()); ImplementationManager.Load <MicrosoftSQLImplementation>(); Assert.AreEqual(ImplementationManager.GetImplementations().Count, 1); ImplementationManager.Load <OracleImplementation>(); Assert.AreEqual(ImplementationManager.GetImplementations().Count, 2); //repeat loading shouldn't increase the count ImplementationManager.Load <OracleImplementation>(); Assert.AreEqual(ImplementationManager.GetImplementations().Count, 2); ImplementationManager.Load <MySqlImplementation>(); Assert.AreEqual(ImplementationManager.GetImplementations().Count, 3); }