Пример #1
0
        public async Task ProcessAsync_ShouldCreateFile()
        {
            var fixture = new Fixture();
            coinFile = fixture.Create<CoinFile>();

            outboundVoucherFile = fixture.Create<OutboundVoucherFile>();

            outboundVoucherFile.FileLocation = @"c:\someDir";
            outboundVoucherFile.FileName = @"someFileName.xml";

            mapper
                .Setup(m => m.Map(It.IsAny<OutboundVoucherFile>()))
                .Returns(coinFile);

            coinFileWriter
                .Setup(w => w.SaveFile(coinFile, @"c:\someDir\someFileName.xml"))
                .Returns(() => Task.FromResult(string.Empty));

            coinFileCreator = GetCoinFileCreator();

            await coinFileCreator.ProcessAsync(outboundVoucherFile);

            mapper.VerifyAll();
            coinFileWriter.VerifyAll();
        }
Пример #2
0
        public CoinFileToXmlMapperTests()
        {
            header = fixture.Create<CoinHeader>();
            trailer = fixture.Create<CoinTrailer>();
            items = fixture.CreateMany<CoinItem>();

            fixture.Register(() => new XElement(TestItem));

            coinFile = new CoinFile(header, trailer, items);
        }
Пример #3
0
        private async Task<string> CreateImageExchangeFile(OutboundVoucherFile outboundVoucherFile, CoinFile imageExchangeFile)
        {
            var fileFullPath = fileSystem.Path.Combine(outboundVoucherFile.FileLocation, outboundVoucherFile.FileName);

            await writer.SaveFile(imageExchangeFile, fileFullPath);

            Log.Debug("Image exchange file has been created: {file}", fileFullPath);

            if (outboundVoucherFile.OperationType == "ImageExchange")
            {
                var zipFileFullPath = fileFullPath.Replace(".xml", ".zip");
                using (ZipFile zip = new ZipFile())
                {
                    zip.AddFile(fileFullPath, @"\");
                    zip.Save(zipFileFullPath);
                }
            }
            return fileFullPath;
        }
Пример #4
0
        public void Setup()
        {
            stream = new MemoryStream();
            file = new CoinFile(null, null, null);
            
            finalPath = @"c:\coin\NAB\file.xml";
            var xDoc = new XDocument(new XElement("root", new XElement("key", "value")));

            mapper = new Mock<IMapper<CoinFile, XDocument>>();
            
            mapper
                .Setup(m => m.Map(file))
                .Returns(xDoc);

            fileSystem = new Mock<IFileSystem>();

            fileSystem
                .Setup(m => m.File.OpenWrite(finalPath))
                .Returns(stream);
        }