Пример #1
0
        private void VerifyFileDetails(FileDetails source,
                                       DataTransferObjects.Responses.FileDetails fileDetails)
        {
            fileDetails.FileImportLogId.ShouldBe(source.FileImportLogId);
            fileDetails.EstateId.ShouldBe(source.EstateId);
            fileDetails.FileId.ShouldBe(source.FileId);
            fileDetails.FileLocation.ShouldBe(source.FileLocation);
            fileDetails.FileProfileId.ShouldBe(source.FileProfileId);
            fileDetails.MerchantId.ShouldBe(source.MerchantId);
            fileDetails.UserId.ShouldBe(source.UserId);
            fileDetails.ProcessingCompleted.ShouldBe(source.ProcessingCompleted);

            if (source.ProcessingSummary != null)
            {
                fileDetails.ProcessingSummary.ShouldNotBeNull();
                fileDetails.ProcessingSummary.FailedLines.ShouldBe(source.ProcessingSummary.FailedLines);
                fileDetails.ProcessingSummary.TotalLines.ShouldBe(source.ProcessingSummary.TotalLines);
                fileDetails.ProcessingSummary.IgnoredLines.ShouldBe(source.ProcessingSummary.IgnoredLines);
                fileDetails.ProcessingSummary.NotProcessedLines.ShouldBe(source.ProcessingSummary.NotProcessedLines);
                fileDetails.ProcessingSummary.SuccessfullyProcessedLines.ShouldBe(source.ProcessingSummary.SuccessfullyProcessedLines);
            }

            foreach (FileLine sourceFileLine in source.FileLines)
            {
                DataTransferObjects.Responses.FileLine?fileLineToVerify = fileDetails.FileLines.SingleOrDefault(l => l.LineNumber == sourceFileLine.LineNumber);

                fileLineToVerify.ShouldNotBeNull();
                fileLineToVerify.LineData.ShouldBe(sourceFileLine.LineData);
                fileLineToVerify.TransactionId.ShouldBe(sourceFileLine.TransactionId);

                if (sourceFileLine.ProcessingResult == ProcessingResult.Failed)
                {
                    fileLineToVerify.ProcessingResult.ShouldBe(FileLineProcessingResult.Failed);
                }
                if (sourceFileLine.ProcessingResult == ProcessingResult.Successful)
                {
                    fileLineToVerify.ProcessingResult.ShouldBe(FileLineProcessingResult.Successful);
                }
                if (sourceFileLine.ProcessingResult == ProcessingResult.Ignored)
                {
                    fileLineToVerify.ProcessingResult.ShouldBe(FileLineProcessingResult.Ignored);
                }
                if (sourceFileLine.ProcessingResult == ProcessingResult.NotProcessed)
                {
                    fileLineToVerify.ProcessingResult.ShouldBe(FileLineProcessingResult.NotProcessed);
                }
                if (sourceFileLine.ProcessingResult == ProcessingResult.Rejected)
                {
                    fileLineToVerify.ProcessingResult.ShouldBe(FileLineProcessingResult.Rejected);
                    fileLineToVerify.RejectionReason.ShouldBe(sourceFileLine.RejectedReason);
                }
            }
        }
Пример #2
0
        public FileDetailsResponse ConvertFrom(FileDetails fileDetails)
        {
            FileDetailsResponse fileDetailsResponse = new FileDetailsResponse
            {
                EstateId            = fileDetails.EstateId,
                FileId              = fileDetails.FileId,
                FileImportLogId     = fileDetails.FileImportLogId,
                UserId              = fileDetails.UserId,
                MerchantId          = fileDetails.MerchantId,
                FileProfileId       = fileDetails.FileProfileId,
                FileLocation        = fileDetails.FileLocation,
                ProcessingCompleted = fileDetails.ProcessingCompleted,
                FileProfileName     = fileDetails.FileProfileName,
                MerchantName        = fileDetails.MerchantName,
                UserEmailAddress    = fileDetails.UserEmailAddress,
                FileLines           = new List <FileLineResponse>()
            };

            foreach (FileLine fileDetailsFileLine in fileDetails.FileLines)
            {
                fileDetailsResponse.FileLines.Add(new FileLineResponse
                {
                    LineData         = fileDetailsFileLine.LineData,
                    LineNumber       = fileDetailsFileLine.LineNumber,
                    ProcessingResult = this.TranslateProcessingResult(fileDetailsFileLine.ProcessingResult),
                    TransactionId    = fileDetailsFileLine.TransactionId
                });
            }

            fileDetailsResponse.ProcessingSummary = new FileProcessingSummary
            {
                FailedLines                = fileDetails.ProcessingSummary.FailedLines,
                IgnoredLines               = fileDetails.ProcessingSummary.IgnoredLines,
                NotProcessedLines          = fileDetails.ProcessingSummary.NotProcessedLines,
                SuccessfullyProcessedLines = fileDetails.ProcessingSummary.SuccessfullyProcessedLines,
                TotalLines    = fileDetails.ProcessingSummary.TotalLines,
                RejectedLines = fileDetails.ProcessingSummary.RejectedLines
            };

            return(fileDetailsResponse);
        }