[Adapdev-commits] Adapdev/src/Adapdev.Data.Tests SchemaBuilderTest.cs,1.1,1.2
Status: Beta
Brought to you by:
intesar66
From: Trevor L. <tre...@us...> - 2005-04-10 09:59:48
|
Update of /cvsroot/adapdev/Adapdev/src/Adapdev.Data.Tests In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv22225/src/Adapdev.Data.Tests Modified Files: SchemaBuilderTest.cs Log Message: 1. Modifications to support the ProviderConfig file for Database/Provider dynamic customisation 2. Added support classes for Oracle 3. Enhanced UI to support dynamic ProviderConfig Index: SchemaBuilderTest.cs =================================================================== RCS file: /cvsroot/adapdev/Adapdev/src/Adapdev.Data.Tests/SchemaBuilderTest.cs,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** SchemaBuilderTest.cs 25 Mar 2005 02:16:30 -0000 1.1 --- SchemaBuilderTest.cs 10 Apr 2005 09:59:05 -0000 1.2 *************** *** 4,7 **** --- 4,8 ---- namespace Adapdev.Data.Tests { + using Adapdev.Data; using Adapdev.Data.Schema; *************** *** 29,32 **** --- 30,155 ---- Assert.IsTrue(ds.Tables.Contains("Orders")); } + + [Test] + public void ProviderConfig() { + ProviderConfig pc = new ProviderConfig(); + Assert.AreEqual(5 ,pc.ConnectionTypes.Count, "Should have 5 Connection Types in the ProviderConfig collection"); + Assert.IsTrue(pc.ConnectionTypes.Contains("Microsoft Access"),"Could not find Microsoft Access"); + Assert.IsTrue(pc.ConnectionTypes.Contains("SQL Server"),"Could not find SQL Server"); + Assert.IsTrue(pc.ConnectionTypes.Contains("SQL Server - Trusted"), "Could not find SQL Server - Trusted"); + Assert.IsTrue(pc.ConnectionTypes.Contains("Oracle"), "Could not find Oracle"); + Assert.IsTrue(pc.ConnectionTypes.Contains("Oracle - Trusted"), "Could not find Oracle -Trusted"); + } + + [Test] + public void ConnectionTypes() { + DbConnectionTypes ct = new DbConnectionTypes(); + Assert.AreEqual(0, ct.Count, "Should be zero items"); + ct.Add("test", new DbConnectionType()); + Assert.AreEqual(1, ct.Count, "Should be one item"); + Assert.IsTrue(ct.Contains("test"),"Should contain test"); + ct.Remove("test"); + Assert.AreEqual(0, ct.Count, "Should be zero items after deleting the item"); + + ct.Add(new DbConnectionType("zarniwoop",DbType.SQLSERVER, "OLEDB",true, true, true, true)); + ct.Add(new DbConnectionType("beeblebrox",DbType.SQLSERVER, "OLEDB",true, true, true, true)); + ct.Add(new DbConnectionType("magrathea",DbType.SQLSERVER, "OLEDB",true, true, true, true)); + ct.Add(new DbConnectionType("marvin",DbType.SQLSERVER, "OLEDB",true, true, true, true)); + ct.Add(new DbConnectionType("vogon",DbType.SQLSERVER, "OLEDB",true, true, true, true)); + + Assert.AreEqual("beeblebrox", ct.GetByIndex(0).Name); + Assert.AreEqual("magrathea", ct.GetByIndex(1).Name); + Assert.AreEqual("marvin", ct.GetByIndex(2).Name); + Assert.AreEqual("vogon", ct.GetByIndex(3).Name); + Assert.AreEqual("zarniwoop", ct.GetByIndex(4).Name); + + ct.Clear(); + Assert.AreEqual(0, ct.Count, "Should be zero items after clearing the collection"); + } + + [Test] + public void ConnectionType() { + DbConnectionType ct = new DbConnectionType(); + Assert.IsNotNull(ct); + + ct = new DbConnectionType("TestType",DbType.SQLSERVER, "OLEDB", true, true, true, true); + Assert.IsFalse(ct.SupportsFile); + Assert.IsTrue(ct.SupportsServer); + ct.SupportsServer = false; + Assert.IsTrue(ct.SupportsFile); + Assert.IsFalse(ct.SupportsServer); + + ct.DbType = DbType.ACCESS; + Assert.AreEqual("ACCESS", ct.DbTypeName); + } + + [Test] + [ExpectedException(typeof(ApplicationException))] + public void ConnectionTypeInternalFails() { + DbConnectionType ct = new DbConnectionType("TestType",DbType.SQLSERVER, "OLEDB", true, true, true, true); + Assert.AreEqual("OLEDB", ct.InternalProviderName); + Assert.IsNull(ct.InternalProvider); + } + + [Test] + public void ConnectionProviders() { + DbConnectionProviders cp = new DbConnectionProviders(); + Assert.AreEqual(0, cp.Count, "Should be zero items"); + cp.Add("test", new DbConnectionProvider()); + Assert.AreEqual(1, cp.Count, "Should be one item"); + Assert.IsTrue(cp.Contains("test"),"Should contain test"); + cp.Remove("test"); + Assert.AreEqual(0, cp.Count, "Should be zero items after deleting the item"); + + DbConnectionType ct = new DbConnectionType("TestType",DbType.SQLSERVER,"OLEDB", true, true, true, true); + ct.Providers = cp; + + cp.Add(new DbConnectionProvider("zarniwoop","SQLSERVER", "provider=mssqlserver", ct)); + cp.Add(new DbConnectionProvider("beeblebrox","SQLSERVER", "provider=mssqlserver", ct)); + cp.Add(new DbConnectionProvider("magrathea","SQLSERVER", "provider=mssqlserver", ct)); + cp.Add(new DbConnectionProvider("marvin","SQLSERVER", "provider=mssqlserver", ct)); + cp.Add(new DbConnectionProvider("vogon","SQLSERVER", "provider=mssqlserver", ct)); + + Assert.AreEqual("beeblebrox", cp.GetByIndex(0).Name, "Items out of order"); + Assert.AreEqual("magrathea", cp.GetByIndex(1).Name, "Items out of order"); + Assert.AreEqual("marvin", cp.GetByIndex(2).Name, "Items out of order"); + Assert.AreEqual("vogon", cp.GetByIndex(3).Name, "Items out of order"); + Assert.AreEqual("zarniwoop", cp.GetByIndex(4).Name, "Items out of order"); + + cp.Clear(); + Assert.AreEqual(0, cp.Count, "Should be zero items after clearing the collection"); + } + + [Test] + public void ConnectionProvider() { + + DbConnectionType ct = new DbConnectionType("TestType",DbType.SQLSERVER,"OLEDB", true, true, true, true); + DbConnectionProvider cp = new DbConnectionProvider(); + Assert.IsNotNull(cp); + + cp = new DbConnectionProvider("TestProvider1", "SQLSERVER", "provider=mssqlserver", ct); + ct.Providers.Add(cp); + cp = new DbConnectionProvider("TestProvider2", "OLEDB", "provider=mssqlserver", ct); + ct.Providers.Add(cp); + + Assert.AreEqual(2, ct.Providers.Count, "Should be two providers."); + + cp.DbType = DbType.ACCESS; + Assert.AreEqual("ACCESS", cp.DbTypeName); + cp.ProviderType = DbProviderType.OLEDB; + Assert.AreEqual("OLEDB", cp.ProviderTypeName); + + ct.InternalProviderName = "TestProvider2"; + Assert.AreEqual("TestProvider2", ct.InternalProvider.Name, "Internal Provider should be 'TestProvider2'"); + + Assert.IsNotNull(cp.Parent,"Parent should not be Null. Should be 'TestType'"); + Assert.IsNotNull(cp.Parent.InternalProvider,"Internal provider should be defined"); + Assert.AreEqual(cp.Parent.InternalProvider.ConnectionString("TestServer"), cp.ConnectionString("TestServer")); + + cp = new DbConnectionProvider("TestProvider","OLEDB", "{0},{1},{2},{3}", ct); + Assert.AreEqual("A,B,C,D", cp.ConnectionString("A","B","C","D")); + } + + } } |