SqlCommand_ExecuteXmlReader_.cs 2.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990
  1. using System;
  2. using System.Data;
  3. using System.Data.SqlClient;
  4. using System.Xml;
  5. using System.Text;
  6. using System.IO;
  7. using MonoTests.System.Data.Utils;
  8. using NUnit.Framework;
  9. namespace MonoTests.System.Data.SqlClient
  10. {
  11. [TestFixture]
  12. public class SqlCommand_ExecuteXmlReader_ : ADONetTesterClass
  13. {
  14. public static void Main()
  15. {
  16. SqlCommand_ExecuteXmlReader_ tc = new SqlCommand_ExecuteXmlReader_();
  17. Exception exp = null;
  18. try
  19. {
  20. // Every Test must begin with BeginTest
  21. tc.BeginTest("SqlCommand_ExecuteXmlReader");
  22. //testing only on SQLServer
  23. if (ConnectedDataProvider.GetDbType() != DataBaseServer.SQLServer) return ;
  24. tc.run();
  25. }
  26. catch(Exception ex)
  27. {
  28. exp = ex;
  29. }
  30. finally
  31. {
  32. // Every Test must End with EndTest
  33. tc.EndTest(exp);
  34. }
  35. }
  36. [Test]
  37. [Category("NotWorking")]
  38. public void run()
  39. {
  40. Exception exp = null;
  41. // Start Sub Test
  42. try
  43. {
  44. // Every Sub Test must begin with BeginCase
  45. BeginCase("ExecuteXmlReader 1");
  46. SqlConnection con = new SqlConnection(ConnectedDataProvider.ConnectionStringSQLClient);
  47. con.Open();
  48. string selectStr = "SELECT * FROM Products WHERE PRODUCTID=1 FOR XML AUTO, XMLDATA;" +
  49. "SELECT * FROM Orders WHERE ORDERID=1 FOR XML AUTO, XMLDATA;" +
  50. "SELECT * FROM Customers WHERE CustomerID like 'A%' FOR XML AUTO, XMLDATA";
  51. SqlCommand comm = new SqlCommand(selectStr,con);
  52. // ExecuteXmlReader is not supported yet
  53. XmlReader xr = null; // = comm.ExecuteXmlReader();
  54. StringBuilder sb = new StringBuilder();
  55. while(xr.Read())
  56. {
  57. sb.Append(xr.ReadOuterXml());
  58. }
  59. // Every Sub Test must have a Compare
  60. string strXml = null;
  61. Compare(sb.ToString().Length,4391);
  62. }
  63. catch(Exception ex)
  64. {
  65. exp = ex;
  66. }
  67. finally
  68. {
  69. // Every Sub Test must end with EndCase
  70. EndCase(exp);
  71. exp = null;
  72. }
  73. // End Sub Test
  74. }
  75. }
  76. }