|
| 1 | +// -------------------------------------------------------------------------------------------------------------------- |
| 2 | +// <copyright company="Aspose Pty Ltd"> |
| 3 | +// Copyright (c) 2003-2019 Aspose Pty Ltd |
| 4 | +// </copyright> |
| 5 | +// <summary> |
| 6 | +// Permission is hereby granted, free of charge, to any person obtaining a copy |
| 7 | +// of this software and associated documentation files (the "Software"), to deal |
| 8 | +// in the Software without restriction, including without limitation the rights |
| 9 | +// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell |
| 10 | +// copies of the Software, and to permit persons to whom the Software is |
| 11 | +// furnished to do so, subject to the following conditions: |
| 12 | +// |
| 13 | +// The above copyright notice and this permission notice shall be included in all |
| 14 | +// copies or substantial portions of the Software. |
| 15 | +// |
| 16 | +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR |
| 17 | +// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, |
| 18 | +// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE |
| 19 | +// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER |
| 20 | +// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, |
| 21 | +// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE |
| 22 | +// SOFTWARE. |
| 23 | +// </summary> |
| 24 | +// -------------------------------------------------------------------------------------------------------------------- |
| 25 | + |
| 26 | +using System.Collections.Generic; |
| 27 | +using System.IO; |
| 28 | +using System.Linq; |
| 29 | +using GroupDocs.Annotation.Cloud.Sdk.Model; |
| 30 | +using GroupDocs.Annotation.Cloud.Sdk.Model.Requests; |
| 31 | +using NUnit.Framework; |
| 32 | + |
| 33 | +namespace GroupDocs.Annotation.Cloud.Sdk.Test.Api |
| 34 | +{ |
| 35 | + public class AnnotationApiTests : BaseApiTest |
| 36 | + { |
| 37 | + [TestCase(@"cells\one-page.xlsx")] |
| 38 | + [TestCase(@"diagram\one-page.vsd")] |
| 39 | + [TestCase(@"email\one-page.emlx")] |
| 40 | + [TestCase(@"images\one-page.png")] |
| 41 | + [TestCase(@"pdf\one-page.pdf")] |
| 42 | + [TestCase(@"slides\one-page.pptx")] |
| 43 | + [TestCase(@"words\one-page.docx")] |
| 44 | + [TestCase(@"cells\ten-pages.xlsx")] |
| 45 | + [TestCase(@"diagram\ten-pages.vsd")] |
| 46 | + [TestCase(@"pdf\ten-pages.pdf")] |
| 47 | + [TestCase(@"slides\ten-pages.pptx")] |
| 48 | + [TestCase(@"words\ten-pages.docx")] |
| 49 | + [TestCase(@"cells\one-page-password.xlsx")] |
| 50 | + [TestCase(@"pdf\one-page-password.pdf")] |
| 51 | + [TestCase(@"slides\one-page-password.pptx")] |
| 52 | + [TestCase(@"words\one-page-password.docx")] |
| 53 | + [Order(1)] |
| 54 | + public void TestGetImport(string filePath) |
| 55 | + { |
| 56 | + var annotations = AnnotateApi.GetImport(new GetImportRequest(filePath)); |
| 57 | + Assert.AreNotEqual(null, annotations); |
| 58 | + Assert.IsInstanceOf(typeof(AnnotationInfo), annotations[0]); |
| 59 | + } |
| 60 | + |
| 61 | + [TestCase(@"cells\one-page.xlsx", Ignore = "")] |
| 62 | + [TestCase(@"diagram\one-page.vsd")] |
| 63 | + [TestCase(@"email\one-page.emlx")] |
| 64 | + [TestCase(@"images\one-page.png")] |
| 65 | + [TestCase(@"pdf\one-page.pdf")] |
| 66 | + [TestCase(@"slides\one-page.pptx")] |
| 67 | + [TestCase(@"words\one-page.docx")] |
| 68 | + [TestCase(@"cells\ten-pages.xlsx", "Area,Point", true, 2, 5, Ignore = "")] |
| 69 | + [TestCase(@"diagram\ten-pages.vsd", "Area,Point", true, 2, 5)] |
| 70 | + [TestCase(@"pdf\ten-pages.pdf", "Area,Point", true, 2, 5)] |
| 71 | + [TestCase(@"slides\ten-pages.pptx", "Area,Point", true, 2, 5)] |
| 72 | + [TestCase(@"words\ten-pages.docx", "Area,Point", true, 2, 5)] |
| 73 | + [TestCase(@"cells\one-page-password.xlsx", null, false, -1, -1, "password", Ignore = "")] |
| 74 | + [TestCase(@"pdf\one-page-password.pdf", null, false, -1, -1, "password")] |
| 75 | + [TestCase(@"slides\one-page-password.pptx", null, false, -1, -1, "password")] |
| 76 | + [TestCase(@"words\one-page-password.docx", null, false, -1, -1, "password")] |
| 77 | + [Order(2)] |
| 78 | + public void TestGetExport(string filePath, string annotationTypes = null, bool annotatedPages = false, int firstPage = -1, int lastPage = -1, string password = null) |
| 79 | + { |
| 80 | + GetExportRequest request = new GetExportRequest(filePath, annotationTypes, annotatedPages, firstPage, lastPage, password); |
| 81 | + var result = AnnotateApi.GetExport(request); |
| 82 | + Assert.IsNotNull(result); |
| 83 | + Assert.IsInstanceOf(typeof(Stream), result); |
| 84 | + } |
| 85 | + |
| 86 | + [TestCase(@"cells\one-page.xlsx")] |
| 87 | + [TestCase(@"diagram\one-page.vsd")] |
| 88 | + [TestCase(@"email\one-page.emlx")] |
| 89 | + [TestCase(@"images\one-page.png")] |
| 90 | + [TestCase(@"pdf\one-page.pdf")] |
| 91 | + [TestCase(@"slides\one-page.pptx")] |
| 92 | + [TestCase(@"words\one-page.docx")] |
| 93 | + [TestCase(@"cells\ten-pages.xlsx")] |
| 94 | + [TestCase(@"diagram\ten-pages.vsd")] |
| 95 | + [TestCase(@"pdf\ten-pages.pdf")] |
| 96 | + [TestCase(@"slides\ten-pages.pptx")] |
| 97 | + [TestCase(@"words\ten-pages.docx")] |
| 98 | + [TestCase(@"cells\one-page-password.xlsx")] |
| 99 | + [TestCase(@"pdf\one-page-password.pdf")] |
| 100 | + [TestCase(@"slides\one-page-password.pptx")] |
| 101 | + [TestCase(@"words\one-page-password.docx")] |
| 102 | + [Order(3)] |
| 103 | + public void TestDeleteAnnotations(string filePath) |
| 104 | + { |
| 105 | + AnnotateApi.DeleteAnnotations(new DeleteAnnotationsRequest(filePath)); |
| 106 | + } |
| 107 | + |
| 108 | + [TestCase(@"cells\one-page.xlsx")] |
| 109 | + [TestCase(@"diagram\one-page.vsd")] |
| 110 | + [TestCase(@"email\one-page.emlx")] |
| 111 | + [TestCase(@"images\one-page.png")] |
| 112 | + [TestCase(@"pdf\one-page.pdf")] |
| 113 | + [TestCase(@"slides\one-page.pptx")] |
| 114 | + [TestCase(@"words\one-page.docx")] |
| 115 | + [TestCase(@"cells\one-page-password.xlsx")] |
| 116 | + [TestCase(@"pdf\one-page-password.pdf")] |
| 117 | + [TestCase(@"slides\one-page-password.pptx")] |
| 118 | + [TestCase(@"words\one-page-password.docx")] |
| 119 | + [Order(0)] |
| 120 | + public void TestPostAnnotations(string filePath) |
| 121 | + { |
| 122 | + var request = new PostAnnotationsRequest(filePath, GetAnnotationsTestBody()); |
| 123 | + AnnotateApi.PostAnnotations(request); |
| 124 | + } |
| 125 | + |
| 126 | + [TestCase(@"cells\ten-pages.xlsx")] |
| 127 | + [TestCase(@"diagram\ten-pages.vsd")] |
| 128 | + [TestCase(@"pdf\ten-pages.pdf")] |
| 129 | + [TestCase(@"slides\ten-pages.pptx")] |
| 130 | + [TestCase(@"words\ten-pages.docx")] |
| 131 | + [Order(0)] |
| 132 | + public void TestPostAnnotationsManyPages(string filePath) |
| 133 | + { |
| 134 | + var request = new PostAnnotationsRequest(filePath, GetAnnotationsTestBodyManyPages()); |
| 135 | + AnnotateApi.PostAnnotations(request); |
| 136 | + } |
| 137 | + |
| 138 | + private List<AnnotationInfo> GetAnnotationsTestBody() |
| 139 | + { |
| 140 | + AnnotationInfo[] annotations = { |
| 141 | + new AnnotationInfo |
| 142 | + { |
| 143 | + AnnotationPosition = new Point { X = 852, Y = 59.388262910798119 }, |
| 144 | + Box = new Rectangle { X = 375.89276123046875, Y = 59.388263702392578, Width = 88.7330551147461, Height = 37.7290153503418 }, |
| 145 | + PageNumber = 0, |
| 146 | + PenColor = 1201033, |
| 147 | + PenStyle = 0, |
| 148 | + PenWidth = 1, |
| 149 | + Type = AnnotationInfo.TypeEnum.Area, |
| 150 | + CreatorName = "Anonym A." |
| 151 | + } |
| 152 | + }; |
| 153 | + return annotations.ToList(); |
| 154 | + } |
| 155 | + |
| 156 | + private List<AnnotationInfo> GetAnnotationsTestBodyManyPages() |
| 157 | + { |
| 158 | + AnnotationInfo[] annotations = { |
| 159 | + new AnnotationInfo |
| 160 | + { |
| 161 | + AnnotationPosition = new Point { X = 852, Y = 59.388262910798119 }, |
| 162 | + Box = new Rectangle { X = 375.89276123046875, Y = 59.388263702392578, Width = 88.7330551147461, Height = 37.7290153503418 }, |
| 163 | + PageNumber = 0, |
| 164 | + PenColor = 1201033, |
| 165 | + PenStyle = 0, |
| 166 | + PenWidth = 1, |
| 167 | + Type = AnnotationInfo.TypeEnum.Distance, |
| 168 | + CreatorName = "Anonym A." |
| 169 | + }, |
| 170 | + new AnnotationInfo |
| 171 | + { |
| 172 | + AnnotationPosition = new Point { X = 852, Y = 59.388262910798119 }, |
| 173 | + Box = new Rectangle { X = 375.89276123046875, Y = 59.388263702392578, Width = 88.7330551147461, Height = 37.7290153503418 }, |
| 174 | + PageNumber = 2, |
| 175 | + PenColor = 1201033, |
| 176 | + PenStyle = 0, |
| 177 | + PenWidth = 1, |
| 178 | + Type = AnnotationInfo.TypeEnum.Area, |
| 179 | + CreatorName = "Anonym A." |
| 180 | + }, |
| 181 | + new AnnotationInfo |
| 182 | + { |
| 183 | + AnnotationPosition = new Point { X = 852, Y = 59.388262910798119 }, |
| 184 | + Box = new Rectangle { X = 375.89276123046875, Y = 59.388263702392578, Width = 88.7330551147461, Height = 37.7290153503418 }, |
| 185 | + PageNumber = 4, |
| 186 | + Type = AnnotationInfo.TypeEnum.Point, |
| 187 | + CreatorName = "Anonym A." |
| 188 | + }, |
| 189 | + new AnnotationInfo |
| 190 | + { |
| 191 | + AnnotationPosition = new Point { X = 852, Y = 59.388262910798119 }, |
| 192 | + Box = new Rectangle { X = 375.89276123046875, Y = 59.388263702392578, Width = 88.7330551147461, Height = 37.7290153503418 }, |
| 193 | + PageNumber = 5, |
| 194 | + PenColor = 1201033, |
| 195 | + PenStyle = 0, |
| 196 | + PenWidth = 1, |
| 197 | + Type = AnnotationInfo.TypeEnum.Arrow, |
| 198 | + CreatorName = "Anonym A." |
| 199 | + } |
| 200 | + }; |
| 201 | + return annotations.ToList(); |
| 202 | + } |
| 203 | + } |
| 204 | +} |
0 commit comments