コード例 #1
0
ファイル: SqlWorkerTest.cs プロジェクト: DarkGraf/STInstaller
        public void SqlCheckConnectionWorkerFault()
        {
            using (ShimsContext.Create())
              {
            System.Data.SqlClient.Fakes.ShimSqlConnection.AllInstances.Open = delegate { };
            System.Data.SqlClient.Fakes.ShimSqlConnection.AllInstances.StateGet = delegate { throw new Exception(); };

            SqlCheckConnectionWorker worker = new SqlCheckConnectionWorker("TESTHOST", AuthenticationType.Sql, "sa", "sa");
            worker.Execute();
              }
        }
コード例 #2
0
ファイル: SqlWorkerTest.cs プロジェクト: DarkGraf/STInstaller
        public void SqlCheckConnectionWorkerSuccess()
        {
            using (ShimsContext.Create())
              {
            bool wasInvoked = false;

            System.Data.SqlClient.Fakes.ShimSqlConnection.AllInstances.Open = delegate { };
            System.Data.SqlClient.Fakes.ShimSqlConnection.AllInstances.StateGet = delegate
            {
              wasInvoked = true;
              return ConnectionState.Open;
            };

            SqlCheckConnectionWorker worker = new SqlCheckConnectionWorker("TESTHOST", "TESTDB", AuthenticationType.Sql, "sa", "sa");
            worker.Execute();
            Assert.IsTrue(wasInvoked);
              }
        }