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(); } }
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); } }