public void GivenMultipleErrorResults_ReportAllErrors() { var result = new TaskResult (); result.Error ("my error"); result.Error ("my error2"); var receiver = new TestTaskResultReceiver (); result.SendSubResultsTo (receiver); receiver.AssertResultCount (2); receiver.AssertMessageAndTypeEquals (1, "Error", "my error"); receiver.AssertMessageAndTypeEquals (2, "Error", "my error2"); }
public void WhenAnErrorIsAdded_ContainsError_ShouldBeTrue() { var result = new TaskResult (); result.Error ("my error"); result.ContainsError ().ShouldBe (true); }
TaskResult IPreparable.Prepare() { var result = new TaskResult (); if (File.Exists (Source) == false) { result.Error ("Source file does not exist!"); return result; } var dest = new FileInfo (Destination); if (dest.Exists) { var sourceMd5 = GetMd5 (Source); var destMd5 = GetMd5 (Destination); _exactFileExists = sourceMd5.SequenceEqual (destMd5); } else { _exactFileExists = false; } if (_exactFileExists) return result; DetectAndAppendCopyErrorsToResult (result, dest); return result; }
TaskResult IExecutable.Execute() { var results = new TaskResult(); Warning[] warnings; var name = ReportRdl.FileNameWithoutExtension; var rs = GetWsClient (); try { rs.CreateCatalogItem ("Report", name, DestinationPathOnServer.Path, true, _rdl, null, out warnings); results.Success ("Report '{0}' was created successfully in server temp directory.", name); } catch (SoapException e) { results.Error ("Report '{0}' not created successfully. Error:\n{1}\n", name, e.Detail.InnerXml); return results; } if (warnings != null) { foreach (var warning in warnings) results.Warning (warning.Message); } return results; }
TaskResult IPreparable.Prepare() { var result = new TaskResult (); if (File.Exists (SourceZip) == false) result.Error ("Zip file not found: " + SourceZip); return result; }
public void GivenAnErrorResult_ReportError() { var result = new TaskResult (); result.Error ("my error"); var receiver = new TestTaskResultReceiver (); result.SendSubResultsTo (receiver); receiver.AssertResultCount (1); receiver.AssertMessageAndTypeEquals (1, "Error", "my error"); }
public void GivenAnErrorAndSuccess_ReportBoth() { var result = new TaskResult (); result.Success ("my success"); result.Error ("my error"); var receiver = new TestTaskResultReceiver (); result.SendSubResultsTo (receiver); receiver.AssertResultCount (2); receiver.AssertMessageAndTypeEquals (1, "Success", "my success"); receiver.AssertMessageAndTypeEquals (2, "Error", "my error"); }
private TaskResult CheckConnectivity() { var results = new TaskResult (); try { var rs = GetWsClient(); rs.GetSystemPermissions(); results.Success ("Verified connection to report server at {0}.", ReportServerUrl); } catch (SoapException e) { results.Error ("Unable to connect to report server ({0}).\n" + "Error details:\n{1}", ReportServerUrl, e.Message); } return results; }
TaskResult IPreparable.Prepare() { var results = new TaskResult(); var rdlPath = ReportRdl.MakeAbsolute(); if (rdlPath.FileInfo.Exists) { try { _rdl = File.ReadAllBytes (rdlPath); } catch (IOException e) { results.Error("Error while loading report file '{0}':\n{1}", ReportRdl, e.Message); } } else { results.Error("Report definition (.rdl) file not found: " + ReportRdl); } return results; }
public void CanAddError() { var result = new TaskResult(); result.Error ("my error"); }
private void DetectAndAppendCopyErrorsToResult(TaskResult result, FileInfo destInfo) { switch (OnDestinationExistsWithDiffContent) { case DestinationExistsAction.Fail: if (destInfo.Exists) result.Error (Destination + " already exists!"); break; case DestinationExistsAction.Overwrite: if (destInfo.Exists && destInfo.IsReadOnly) result.Error("{0} exists and is readonly.", Destination); break; case DestinationExistsAction.OverwriteEvenReadOnly: break; default: result.Error ("Unexpected destination action: " + OnDestinationExistsWithDiffContent); break; } }
TaskResult IExecutable.Execute() { var result = new TaskResult(); result.Success("Executing scripts on server '{0}' database '{1}'.", Server, Database); foreach (var scriptFile in _scripts) { try { ExecuteSql(scriptFile.Script); result.Success("\tExecuted script: {0}", scriptFile.Filename); } catch(Exception e) { var exception = e.InnerException ?? e; result.Error("Error executing script: {0}:\n{1}", scriptFile.Filename, exception.Message); } } return result; }
private SqlConnection OpenConnection(TaskResult results) { var builder = new SqlConnectionStringBuilder { DataSource = Server, InitialCatalog = Database, UserID = Username, Password = Password }; var conn = new SqlConnection (builder.ToString ()); try { conn.Open (); results.Success("Successfully opened connection with SQL Server."); } catch (Exception e) { results.Error (e, "Unable to open connection to SQL Server '{0}'" + " database '{1}'", Server, Database); } return conn; }
TaskResult IPreparable.Prepare() { var results = new TaskResult (); if (_foundSmoAssembly == false) { results.Error ("!!!! IF SQL SERVER NOT INSTALLED, INSTALL SQL SERVER SMO REDISTRIBUTABLE !!!!"); } foreach (var path in ScriptFiles) { try { // obviously not the most memory efficient - consider deferring var script = File.ReadAllText (path, Encoding.Default); _scripts.Enqueue(new ScriptFile { Filename = path, Script = script }); } catch(Exception e) { results.Error(e, "Error reading file: {0}", path); } } _conn = OpenConnection (results); return results; }