Ejemplo n.º 1
0
        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();
              }
        }
Ejemplo n.º 2
0
        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);
              }
        }