private static string GetFileName(EDITransmissionPackage package)
 {
     var control = package.GetInterchangeControl();
     var partner = package.GetBusinessPartner();
     return   string.Format("{0}{1}{2}.out", control.FunctionalID,
         control.ControlNumber, partner.Code);
 }
 public void SaveAsXml(EDITransmissionPackage ediTransmissionPackage)
 {
     var ediXmlInterchangeControl = ediTransmissionPackage.GetInterchangeControl();
     var fname = GetFileName(ediTransmissionPackage) + ".xml";
     var workingName = _config.WorkingFolder() + fname;
     var uploadName = _config.ArchiveFolder() + fname;
     _fileUtilities.SaveTextAndRename(ediXmlInterchangeControl.ToString(), workingName, uploadName);
 }
 public void Save(EDITransmissionPackage ediTransmissionPackage)
 {
     var ediXmlInterchangeControl = ediTransmissionPackage.GetInterchangeControl();
     var fname = GetFileName(ediTransmissionPackage);
     var workingName = _config.WorkingFolder() + fname;
     //string uploadName = ediTransmissionPackage.GetUploadFolder() + fname;
     var code = ediTransmissionPackage.GetBusinessPartner();
     var pathToUse = TransmissionPath.Edict;
     if (code == BusinessPartner.Initech)
         pathToUse = TransmissionPath.Initech;
     var uploadName = _config.GetUploadFolderFor(pathToUse) + fname;
     _fileUtilities.SaveTextAndRename(ediXmlInterchangeControl.Value, workingName, uploadName);
 }
        public void can_save_edi_documents()
        {
            //ARRANGE
            var document = new Mock<EDIXmlInterchangeControl>(_factory.Object);
            var package = new EDITransmissionPackage(document.Object, BusinessPartner.FedEx);

            //            _configuration.Setup(x => x.WorkingFolder).Returns("WorkingFolder");
            //            _configuration.Setup(x => x.UploadFolder).Returns("UploadFolder");
            document.Setup(x => x.ControlNumber).Returns("1");
            document.SetupGet(x => x.FunctionalID).Returns("SH");

            //ACT
            _sut.Save(package);

            //ASSERT
            //            _configuration.VerifyAll();
            document.VerifyAll();
        }
        public void can_consume_shipped_order_message()
        {
            //ARRANGE
            var message = new InvoicedOrderMessage();
            var ediContentCreator = new Mock<ICreateEdiContentFrom<InvoicedOrderMessage>>();
            _businessPartnerResolver.Setup(x => x.ResolveFrom(message)).Returns(ediContentCreator.Object);
            var package = new EDITransmissionPackage(new EDIXmlInterchangeControl(_seg), BusinessPartner.FedEx);
            _ediDocumentCreator.Setup(x => x.CreateDocumentWith(ediContentCreator.Object, message))
                .Returns(package);
            _acceptMessages.Setup(x => x.Accept(message)).Returns(true);
            _ediDocumentSaver.Setup(x => x.Save(package));

            //ACT
            _sut.Consume(message);

            //ASSERT
            _ediDocumentSaver.VerifyAll();
            _ediDocumentCreator.VerifyAll();
            _businessPartnerResolver.VerifyAll();
        }
        public void can_consume_shipped_order_message()
        {
            //ARRANGE
            var message = new OrderHasBeenShippedMessage();
            message.Add(new ShippedLine());
            var ediContentCreator = new Mock<ICreateEdiContentFrom<OrderHasBeenShippedMessage>>();
            _businessPartnerResolver.Setup(x => x.ResolveFrom(message)).Returns(ediContentCreator.Object);
            var document = new EDIXmlInterchangeControl(_seg);
            var package = new EDITransmissionPackage(document, BusinessPartner.Initech);
            _ediDocumentCreator.Setup(x => x.CreateDocumentWith(ediContentCreator.Object, message))
                .Returns(package);
            _ediDocumentSaver.Setup(x => x.Save(It.IsAny<EDITransmissionPackage>()));
            _acceptMessages.Setup(x => x.Accept(message)).Returns(true);

            //ACT
            _sut.Consume(message);

            //ASSERT
            _executePostConsumeAction.Verify(x => x.Execute(message));
            _ediDocumentSaver.VerifyAll();
            _ediDocumentCreator.VerifyAll();
            _businessPartnerResolver.VerifyAll();
        }