public FetchDataReturnForSubmissionHandler( IWeeeAuthorization authorization, IFetchDataReturnForSubmissionDataAccess dataAccess) { this.authorization = authorization; this.dataAccess = dataAccess; }
public SubmitDataReturnUploadHandler(IWeeeAuthorization authorization, ISubmitReturnVersionDataAccess submitReturnVersionDataAccess, IFetchDataReturnForSubmissionDataAccess fetchDataReturnForSubmissionDataAccess) { this.authorization = authorization; this.submitReturnVersionDataAccess = submitReturnVersionDataAccess; this.fetchDataReturnForSubmissionDataAccess = fetchDataReturnForSubmissionDataAccess; }
private static IFetchDataReturnForSubmissionDataAccess FetchDummyDataReturnWithError(DataReturnUploadError dataReturnsUploadError) { DataReturnUpload dataReturnsUpload = new DataReturnUpload( A.Dummy <Scheme>(), A.Dummy <string>(), new List <DataReturnUploadError>() { dataReturnsUploadError }, A.Dummy <string>(), null, null); IFetchDataReturnForSubmissionDataAccess dataAccess = A.Fake <IFetchDataReturnForSubmissionDataAccess>(); A.CallTo(() => dataAccess.FetchDataReturnUploadAsync(A <Guid> ._)).Returns(dataReturnsUpload); A.CallTo(() => dataAccess.CheckForExistingSubmissionAsync(A <Guid> ._, A <int> ._, A <int> ._)).Returns(false); return(dataAccess); }
public async Task HandleAsync_ForDataReturnWithMultipleErrors_ReturnsErrorsByLineNumberOrder() { // Arrange DataReturnUpload dataReturnsUpload = new DataReturnUpload( A.Dummy <Scheme>(), A.Dummy <string>(), new List <DataReturnUploadError>() { new DataReturnUploadError(ErrorLevel.Error, UploadErrorType.Schema, "Error on 55 line no", 55), new DataReturnUploadError(ErrorLevel.Error, UploadErrorType.Schema, "Error on 5 line no", 5), new DataReturnUploadError(ErrorLevel.Error, UploadErrorType.Schema, "Error on 75 line no", 75), new DataReturnUploadError(ErrorLevel.Error, UploadErrorType.Schema, "Error without line no") }, A.Dummy <string>(), A.Dummy <int>(), A.Dummy <int>()); IFetchDataReturnForSubmissionDataAccess dataAccess = A.Fake <IFetchDataReturnForSubmissionDataAccess>(); A.CallTo(() => dataAccess.FetchDataReturnUploadAsync(A <Guid> ._)).Returns(dataReturnsUpload); FetchDataReturnForSubmissionHandler handler = new FetchDataReturnForSubmissionHandler( A.Dummy <IWeeeAuthorization>(), dataAccess); Requests.DataReturns.FetchDataReturnForSubmission request = new Requests.DataReturns.FetchDataReturnForSubmission( A.Dummy <Guid>()); // Act DataReturnForSubmission result = await handler.HandleAsync(request); // Assert Assert.Equal(4, result.Errors.Count); Assert.True(result.Errors.ElementAt(0).Description == "Error without line no" && result.Errors.ElementAt(1).Description == "Error on 5 line no" && result.Errors.ElementAt(2).Description == "Error on 55 line no" && result.Errors.ElementAt(3).Description == "Error on 75 line no"); }
public async Task HandleAsync_ForDataReturnWithOneErrorWithErrorLevelWarning_ReturnsDtoWithOneWarning() { // Arrange DataReturnUploadError dataReturnsUploadWarning = new DataReturnUploadError( ErrorLevel.Warning, UploadErrorType.Business, A.Dummy <string>()); IFetchDataReturnForSubmissionDataAccess dataAccess = FetchDummyDataReturnWithWarning(dataReturnsUploadWarning); FetchDataReturnForSubmissionHandler handler = new FetchDataReturnForSubmissionHandler( A.Dummy <IWeeeAuthorization>(), dataAccess); Requests.DataReturns.FetchDataReturnForSubmission request = new Requests.DataReturns.FetchDataReturnForSubmission( A.Dummy <Guid>()); // Act DataReturnForSubmission result = await handler.HandleAsync(request); // Assert Assert.Equal(1, result.Warnings.Count); }