public void ShouldCreateTest() { DependencyException exception; string expected; expected = string.Format("Exception of type '{0}' was thrown.", typeof(DependencyException).FullName); exception = new DependencyException(); Assert.IsNotNull(exception); Assert.IsNotNull(exception.Message); Assert.IsNull(exception.InnerException); Assert.AreEqual(expected, exception.Message); expected = "msg"; exception = new DependencyException(expected); Assert.IsNotNull(exception); Assert.IsNotNull(exception.Message); Assert.IsNull(exception.InnerException); Assert.AreEqual(expected, exception.Message); expected = "msg"; exception = new DependencyException(expected, exception); Assert.IsNotNull(exception); Assert.IsNotNull(exception.Message); Assert.IsNotNull(exception.InnerException); Assert.AreEqual(expected, exception.Message); }
public void ShouldCreateTest() { DependencyException exception; exception = new DependencyException("msg"); Assert.IsNotNull(exception); Assert.IsNotNull(exception.Message); Assert.AreEqual("msg", exception.Message); }
public void Describe(Type type, string expected) { ParameterInfo[] parameters = null; // find simplest constructor foreach (var ctor in type.GetConstructors()) { var current = ctor.GetParameters(); if (parameters == null || current.Length < parameters.Length) { parameters = current; } } if (parameters == null) { throw new Exception("bad test " + type.Name); } Assert.Equal(expected, DependencyException.DescribeConstructor(type, parameters)); }
//internal bool IsCheckedOut() //{ // return !((File.Attributes & System.IO.FileAttributes.ReadOnly) == System.IO.FileAttributes.ReadOnly); //} void ExecuteProcs(string[] scripts) { SqlTransaction trans = null; string commandText = null; SqlConnection conn = new SqlConnection(Global.ConnectionString + ";Connection Timeout=0"); try { conn.Open(); trans = conn.BeginTransaction(); for (int i=0;i<scripts.Count();i++) { commandText = scripts[i]; if (commandText.Trim() != "") { try { SqlCommand cmd = new SqlCommand(commandText, conn, trans); cmd.CommandTimeout = 0; cmd.ExecuteNonQuery(); } catch (SqlException ex) { if (ex.Message.Contains("@WorkingDirectory")) { string workingDirectoryDef = "DECLARE @WorkingDirectory VARCHAR(MAX) SET @WorkingDirectory = '" + Directory.GetCurrentDirectory() + "' \r\n"; var cmd2 = new SqlCommand(workingDirectoryDef + commandText, conn, trans); cmd2.CommandTimeout = 0; cmd2.ExecuteNonQuery(); } else { throw ex; } } } } trans.Commit(); } catch (System.Data.SqlClient.SqlException ex) { trans.Rollback(); ScriptExecutionException scriptEx = new ScriptExecutionException(this, ex); ArrayList missingObjectNames = MissingObjectExceptionMessage.GetMissingObjectNames(ex.Message); if (missingObjectNames.Count == 0) { LogTable.Write(this, Time.Now, "Failure: " + ex.ToString()); throw scriptEx; } else { DependencyException depEx = new DependencyException(scriptEx); foreach (string missingObjectName in missingObjectNames) { depEx.addDependency(missingObjectName); } throw depEx; } } finally { conn.Close(); } LogTable.Write(this, Time.Now, "Success"); }