DbProviderFactoriesConfigurationHandlerTest.cs 4.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116
  1. //
  2. // System.Data.Common.DbProviderFactoriesConfigurationHandlerTest.cs
  3. //
  4. // Author:
  5. // Sureshkumar T ([email protected])
  6. //
  7. //
  8. // Copyright (C) 2005 Novell, Inc (http://www.novell.com)
  9. //
  10. // Permission is hereby granted, free of charge, to any person obtaining
  11. // a copy of this software and associated documentation files (the
  12. // "Software"), to deal in the Software without restriction, including
  13. // without limitation the rights to use, copy, modify, merge, publish,
  14. // distribute, sublicense, and/or sell copies of the Software, and to
  15. // permit persons to whom the Software is furnished to do so, subject to
  16. // the following conditions:
  17. //
  18. // The above copyright notice and this permission notice shall be
  19. // included in all copies or substantial portions of the Software.
  20. //
  21. // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
  22. // EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
  23. // MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
  24. // NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
  25. // LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
  26. // OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
  27. // WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
  28. //
  29. #if NET_2_0
  30. using System.IO;
  31. using System.Xml;
  32. using System.Globalization;
  33. using System.Configuration;
  34. using System.Data;
  35. using System.Data.Common;
  36. using NUnit.Framework;
  37. namespace MonoTests.System.Data.Common
  38. {
  39. [TestFixture]
  40. public class DbProviderFactoriesConfigurationHandlerTest
  41. {
  42. const string configSection = "system.data_test";
  43. [Test]
  44. public void GetConfigTest ()
  45. {
  46. object o = ConfigurationSettings.GetConfig (configSection);
  47. DataSet ds = o as DataSet;
  48. Assert.IsNotNull (ds, "#A1");
  49. Assert.AreEqual ("system.data", ds.DataSetName, "#A2");
  50. Assert.AreEqual (1, ds.Tables.Count, "#A3");
  51. DataTable dt = ds.Tables [0];
  52. Assert.AreEqual ("DbProviderFactories", dt.TableName, "#B1");
  53. Assert.AreEqual (4, dt.Columns.Count, "#B2");
  54. Assert.IsNotNull (dt.Columns ["Name"], "#B3");
  55. Assert.IsNotNull (dt.Columns ["Description"], "#B4");
  56. Assert.IsNotNull (dt.Columns ["InvariantName"], "#B5");
  57. Assert.IsNotNull (dt.Columns ["AssemblyQualifiedName"], "#B6");
  58. DataColumn [] pk = dt.PrimaryKey;
  59. Assert.AreEqual (1, pk.Length, "#C1");
  60. Assert.AreEqual ("InvariantName", pk [0].ColumnName, "#C2");
  61. }
  62. [Test]
  63. public void PopulateTest ()
  64. {
  65. object o = ConfigurationSettings.GetConfig (configSection);
  66. DataSet ds = o as DataSet;
  67. DataTable dt = ds.Tables [0];
  68. Assert.AreEqual (2, dt.Rows.Count, "#A1");
  69. DataRow r = dt.Rows.Find ("ProviderTest.InvariantName");
  70. Assert.AreEqual ("ProviderTest.Name", r ["Name"].ToString (), "#B2");
  71. Assert.AreEqual ("ProviderTest.Description", r ["Description"].ToString (), "#B3");
  72. Assert.AreEqual ("ProviderTest.InvariantName", r ["InvariantName"].ToString (), "#B4");
  73. Assert.AreEqual ("ProviderTest.AssemblyQualifiedName", r ["AssemblyQualifiedName"].ToString (), "#B5");
  74. r = dt.Rows.Find ("ProviderTest4.InvariantName");
  75. Assert.AreEqual ("ProviderTest4.Name", r ["Name"].ToString (), "#A2");
  76. Assert.AreEqual ("ProviderTest4.Description", r ["Description"].ToString (), "#A3");
  77. Assert.AreEqual ("ProviderTest4.InvariantName", r ["InvariantName"].ToString (), "#A4");
  78. Assert.AreEqual ("ProviderTest4.AssemblyQualifiedName", r ["AssemblyQualifiedName"].ToString (), "#A5");
  79. }
  80. [Test]
  81. [Category ("NotWorking")]
  82. public void PopulateTest_Machine ()
  83. {
  84. object o = ConfigurationSettings.GetConfig ("system.data");
  85. DataSet ds = o as DataSet;
  86. DataTable dt = ds.Tables ["DbProviderFactories"];
  87. Assert.IsNotNull (dt, "#B1");
  88. Assert.IsTrue (dt.Rows.Count > 1, "#B2");
  89. DataRow r = dt.Rows.Find ("ProviderTest2.InvariantName");
  90. Assert.AreEqual ("ProviderTest2.Name", r ["Name"].ToString (), "#B3");
  91. Assert.AreEqual ("ProviderTest2.Description", r ["Description"].ToString (), "#B4");
  92. Assert.AreEqual ("ProviderTest2.InvariantName", r ["InvariantName"].ToString (), "#B5");
  93. Assert.AreEqual ("ProviderTest2.AssemblyQualifiedName", r ["AssemblyQualifiedName"].ToString (), "#B6");
  94. }
  95. [Test]
  96. public void PopulateFactoriesTest () // bug #80894
  97. {
  98. DataTable dt = DbProviderFactories.GetFactoryClasses ();
  99. }
  100. }
  101. }
  102. #endif // NET_2_0