public virtual void CreateInstanceTest()
        {
            PdfDictionary dictionary = new PdfDictionary();
            PdfTarget     target     = PdfTarget.Create(dictionary);

            NUnit.Framework.Assert.AreEqual(dictionary, target.GetPdfObject());
        }
        public virtual void IsWrappedObjectMustBeIndirectTest()
        {
            PdfDictionary pdfObject = new PdfDictionary();
            PdfTarget     target    = PdfTarget.Create(pdfObject);

            NUnit.Framework.Assert.IsFalse(target.IsWrappedObjectMustBeIndirect());
        }
        public virtual void NamePropertyTest()
        {
            String    name   = "Name";
            PdfTarget target = PdfTarget.Create(new PdfDictionary());

            target.SetName(name);
            NUnit.Framework.Assert.AreEqual(name, target.GetName());
            NUnit.Framework.Assert.AreEqual(new PdfString(name), target.GetPdfObject().Get(PdfName.N));
        }
        public virtual void PutTest()
        {
            PdfName       key1       = new PdfName("Key1");
            PdfName       key2       = new PdfName("Key2");
            PdfDictionary dictionary = new PdfDictionary();
            PdfTarget     target     = PdfTarget.Create(dictionary);

            target.Put(key1, new PdfNumber(23)).Put(key2, new PdfString("Hello, world!"));
            NUnit.Framework.Assert.AreEqual(23, dictionary.GetAsNumber(key1).IntValue());
            NUnit.Framework.Assert.AreEqual("Hello, world!", dictionary.GetAsString(key2).GetValue());
        }
 public virtual void GetAnnotationSetAsAnnotationTest()
 {
     using (PdfDocument document = new PdfDocument(new PdfWriter(new MemoryStream()))) {
         PdfFileAttachmentAnnotation annotation = new PdfFileAttachmentAnnotation(new Rectangle(0, 0, 20, 20));
         document.AddNewPage();
         document.GetPage(1).AddAnnotation(annotation);
         PdfDictionary content = new PdfDictionary();
         content.Put(new PdfName("Key"), new PdfString("Value"));
         PdfTarget target = PdfTarget.Create(new PdfDictionary());
         target.SetAnnotation(annotation, document);
         NUnit.Framework.Assert.AreEqual(annotation.GetPdfObject(), target.GetAnnotation(document).GetPdfObject());
     }
 }
 public virtual void SetAnnotationWithoutPageTest()
 {
     NUnit.Framework.Assert.That(() => {
         using (PdfDocument document = new PdfDocument(new PdfWriter(new MemoryStream()))) {
             document.AddNewPage();
             PdfFileAttachmentAnnotation annotation = new PdfFileAttachmentAnnotation(new Rectangle(0, 0, 20, 20));
             PdfTarget target = PdfTarget.Create(new PdfDictionary());
             target.SetAnnotation(annotation, document);
         }
     }
                                 , NUnit.Framework.Throws.InstanceOf <PdfException>().With.Message.EqualTo(PdfException.AnnotationShallHaveReferenceToPage))
     ;
 }
        public virtual void TargetPropertyTest()
        {
            PdfDictionary oldDictionary = new PdfDictionary();

            oldDictionary.Put(new PdfName("Id"), new PdfString("Old"));
            PdfDictionary newDictionary = new PdfDictionary();

            newDictionary.Put(new PdfName("Id"), new PdfString("New"));
            PdfTarget target = PdfTarget.Create(oldDictionary);

            target.SetTarget(PdfTarget.Create(newDictionary));
            NUnit.Framework.Assert.AreEqual(newDictionary, target.GetTarget().GetPdfObject());
            NUnit.Framework.Assert.AreEqual(newDictionary, target.GetPdfObject().Get(PdfName.T));
        }
 public virtual void SetAnnotationTest()
 {
     using (PdfDocument document = new PdfDocument(new PdfWriter(new MemoryStream()))) {
         PdfFileAttachmentAnnotation annotation0 = new PdfFileAttachmentAnnotation(new Rectangle(0, 0, 20, 20));
         PdfFileAttachmentAnnotation annotation1 = new PdfFileAttachmentAnnotation(new Rectangle(1, 1, 21, 21));
         PdfFileAttachmentAnnotation annotation2 = new PdfFileAttachmentAnnotation(new Rectangle(2, 2, 22, 22));
         document.AddNewPage();
         document.GetPage(1).AddAnnotation(annotation0);
         document.GetPage(1).AddAnnotation(annotation1);
         document.GetPage(1).AddAnnotation(annotation2);
         PdfTarget target = PdfTarget.Create(new PdfDictionary());
         target.SetAnnotation(annotation2, document);
         PdfDictionary dictionary = target.GetPdfObject();
         NUnit.Framework.Assert.AreEqual(0, dictionary.GetAsNumber(PdfName.P).IntValue());
         NUnit.Framework.Assert.AreEqual(2, dictionary.GetAsNumber(PdfName.A).IntValue());
     }
 }