| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122 |
- using System;
- using System.Data;
- using System.Data.OleDb;
- using System.Data.SqlClient;
- using MonoTests.System.Data.Utils;
- using NUnit.Framework;
- namespace MonoTests.System.Data.SqlClient
- {
- [TestFixture]
- public class SqlConnection_BeginTransaction_S : ADONetTesterClass
- {
- SqlConnection con;
- [SetUp]
- public void SetUp()
- {
- if (ConnectedDataProvider.GetDbType() != DataBaseServer.SQLServer) {
- //All tests in this class are only for MSSQLServer.
- Log(string.Format("All tests in this class are only for MSSQLServer and cannot be tested on {0}", ConnectedDataProvider.GetDbType()));
- return;
- }
- Exception exp = null;
- BeginCase("Setup");
- try
- {
- con = new SqlConnection(ConnectedDataProvider.ConnectionStringSQLClient);
- con.Open();
- Compare("Setup", "Setup");
- }
- catch(Exception ex) {exp = ex;}
- finally {EndCase(exp); exp = null;}
- }
- [TearDown]
- public void TearDown()
- {
- if (ConnectedDataProvider.GetDbType() != DataBaseServer.SQLServer) {
- //All tests in this class are only for MSSQLServer.
- Log(string.Format("All tests in this class are only for MSSQLServer and cannot be tested on {0}", ConnectedDataProvider.GetDbType()));
- return;
- }
- if (con != null)
- {
- if (con.State == ConnectionState.Open) con.Close();
- }
- }
- public static void Main()
- {
- SqlConnection_BeginTransaction_S tc = new SqlConnection_BeginTransaction_S();
- Exception exp = null;
- try
- {
- tc.BeginTest("SqlConnection_BeginTransaction_S");
- //testing only on SQLServer
- if (ConnectedDataProvider.GetDbType(ConnectedDataProvider.ConnectionStringSQLClient) != DataBaseServer.SQLServer) return ;
- tc.SetUp();
- tc.run();
- tc.TearDown();
- }
- catch(Exception ex)
- {
- exp = ex;
- }
- finally
- {
- tc.EndTest(exp);
- }
- }
- [Test]
- public void run()
- {
- if (ConnectedDataProvider.GetDbType() != DataBaseServer.SQLServer) {
- //All tests in this class are only for MSSQLServer.
- Log(string.Format("All tests in this class are only for MSSQLServer and cannot be tested on {0}", ConnectedDataProvider.GetDbType()));
- return;
- }
- Exception exp = null;
- #region ---- Bug 2716 - MSSQL - SqlCommand.Transaction ----
- // testing only SQLServerr
- if (ConnectedDataProvider.GetDbType(con.ConnectionString) != DataBaseServer.SQLServer)
- {
- try
- {
- BeginCase("Bug 2716 - MSSQL - SqlCommand.Transaction");
- SqlCommand comm = new SqlCommand("SELECT * FROM Customers",con);
- SqlTransaction trans = con.BeginTransaction("transaction");
- comm.Transaction = trans;
- con.Close();
- Compare(con.State,ConnectionState.Closed);
- }
- catch(Exception ex)
- {
- exp = ex;
- }
- finally
- {
- if (con != null)
- {if (con.State == ConnectionState.Open) con.Close();}
- EndCase(exp);
- exp = null;
- }
- }
- #endregion
- }
- }
- }
|