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(); }
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); }
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; }
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); }