public int Attach(string doc, string file) { var op = new OpenOption { SaveMemory = false }; var src = GetSource(doc); var r0 = new DocumentReader(src, "", op); var r1 = IO.Get(GetSource(file)); var dest = Path(Args(r0.File.BaseName, r1.BaseName)); using (var w = new DocumentWriter()) { w.Add(r0); w.Add(r0.Attachments); w.Attach(new Attachment(r1.FullName, IO)); w.Attach(new Attachment(r1.FullName, IO)); // Skip duplicated object. w.Save(dest); } using (var r = new DocumentReader(dest, "", op)) { var items = r.Attachments; Assert.That(items.Any(x => x.Name.FuzzyEquals(file)), Is.True); foreach (var obj in items) { Assert.That(obj.Length, Is.AtLeast(1)); } return(items.Count()); } }
public int Attach(string doc, string file) { var src = GetExamplesWith(doc); var r0 = new DocumentReader(src, "", false, IO); var r1 = IO.Get(GetExamplesWith(file)); var dest = Path(Args(r0.File.NameWithoutExtension, r1.NameWithoutExtension)); using (var w = new DocumentWriter()) { w.Add(r0); w.Add(r0.Attachments); w.Attach(new Attachment(r1.FullName, IO)); w.Attach(new Attachment(r1.FullName, IO)); // Skip duplicated object. w.Save(dest); } using (var r = new DocumentReader(dest, "", false, IO)) { var items = r.Attachments; Assert.That(items.Any(x => x.Name.FuzzyEquals(file)), Is.True); foreach (var obj in items) { Assert.That(obj.Length, Is.AtLeast(1)); } return(items.Count()); } }