Example #1
0
        public OutboundVoucherFile Execute(Batch batch)
        {
            var outboundVoucherFile = new OutboundVoucherFile
            {
                EndpointShortName = batch.ShortTargetEndpoint,
                EndpointLongName = batch.LongTargetEndPoint,
                ProcessingDate = batch.ProcessingDate,
                BatchNumber = batch.BatchNumber,
                FileLocation = batch.FileLocation,
                SequenceNumber = batch.SequenceNumber,
                OperationType = batch.OperationType,
                 ZipPassword = batch.ZipPassword
                
            };

            var fileName = fileNameCreator.Execute(outboundVoucherFile);
            var zipFilename = string.Empty;
            if (outboundVoucherFile.OperationType == ImageExchangeType.Cuscal.ToString())
            {
                var filenameArray = fileName.Split(';');
                if (filenameArray.Length != 2)
                    Log.Warning("{BatchCreator:Execute} Filename may be incorrect. An error may be expected in the next execution.");
                else
                {
                    fileName = filenameArray[0];
                    zipFilename = filenameArray[1];
                }
                
            }
            else if (outboundVoucherFile.OperationType == ImageExchangeType.ImageExchange.ToString())
            {
                zipFilename = fileName.Replace(".xml", ".zip");
            }
         

            outboundVoucherFile.FileName = fileName;
            outboundVoucherFile.ZipFileName = zipFilename;
   
            return outboundVoucherFile;
        }
Example #2
0
        public void Execute_SavesBatch_ThenEnsureVoucherBatchNumberIsSameAsBatchId()
        {
            var batchCreator = GetBatchCreator();
            
            var someVoucherItems = new List<OutboundVoucher> { new OutboundVoucher() };

            var someBatch = new Batch
            {
                BatchNumber = FakeBatchNumber,
                OutboundVouchers = someVoucherItems,
                ProcessingDate = DateTime.Today,
                ShortTargetEndpoint = FakeEndpointShortName
            };
            
            ExpectCoinFileNameToReturnForOutboundImageExchangeFile();

            var result = batchCreator.Execute(someBatch);

            Assert.AreEqual("someFileName", result.FileName);
            
            coinFileName.VerifyAll();
        }