private void FileDownloadError(IDatabaseConnectionService databaseConnection, FileDownloadResult fileDownloadResult) { FilePayload filePayload = fileDownloadResult.FilePayload; DbParameter downloadId = CreateDownloadIdParameter(databaseConnection, filePayload.DownloadId); DbParameter errorMessage = statsDownloadDatabaseParameterService.CreateErrorMessageParameter(databaseConnection, fileDownloadResult); databaseConnection.ExecuteStoredProcedure(Constants.FileDownloadDatabase.FileDownloadErrorProcedureName, new List <DbParameter> { downloadId, errorMessage }); }
CreateErrorMessageParameter_WhenInvokedWithFileDownloadResult_CreatesFileDownloadResultErrorMessageParameter() { var filePayload = new FilePayload(); var fileDownloadResult = new FileDownloadResult(FailedReason.FileDownloadFailedDecompression, filePayload); errorMessageServiceMock .GetErrorMessage(fileDownloadResult.FailedReason, filePayload, StatsDownloadService.FileDownload) .Returns("Error Message"); DbParameter actual = systemUnderTest.CreateErrorMessageParameter(databaseConnectionServiceMock, fileDownloadResult); Assert.That(actual.ParameterName, Is.EqualTo("@ErrorMessage")); Assert.That(actual.DbType, Is.EqualTo(DbType.String)); Assert.That(actual.Direction, Is.EqualTo(ParameterDirection.Input)); Assert.That(actual.Value, Is.EqualTo("Error Message")); }
public void FileDownloadError_WhenInvoked_ParametersAreProvided() { fileDownloadResult = new FileDownloadResult(FailedReason.UnexpectedException, filePayload); List <DbParameter> actualParameters = default; databaseConnectionServiceMock .When(service => service.ExecuteStoredProcedure("[FoldingCoin].[FileDownloadError]", Arg.Any <List <DbParameter> >())) .Do(callback => { actualParameters = callback.Arg <List <DbParameter> >(); }); statsDownloadDatabaseParameterServiceMock .CreateErrorMessageParameter(databaseConnectionServiceMock, fileDownloadResult) .Returns(errorMessageParameterMock); InvokeFileDownloadError(); Assert.That(actualParameters.Count, Is.EqualTo(2)); Assert.That(actualParameters[0], Is.EqualTo(downloadIdParameterMock)); Assert.That(actualParameters[1], Is.EqualTo(errorMessageParameterMock)); }