public void IsNull_Fail() { MockAssertResultHandler mockAssert = new MockAssertResultHandler(); ServiceLocator.AssertResultHandler = mockAssert; ApplicationPathFinder finder = new ApplicationPathFinder("foo"); MWTAssert.IsNull(finder, "This is a message '{0}'.", "foo"); UnitTestAssert.AreEqual("This is a message 'foo'.", mockAssert.LastMessage); }
public void IsInstanceOfType_Pass() { MockAssertResultHandler mockAssert = new MockAssertResultHandler(); ServiceLocator.AssertResultHandler = mockAssert; ApplicationPathFinder finder = new ApplicationPathFinder("foo"); MWTAssert.IsInstanceOfType(finder, typeof(ApplicationPathFinder), "Error Message"); UnitTestAssert.AreEqual("Assert.IsInstanceOfType: Expected Type <LTAF.ApplicationPathFinder>, Value <LTAF.ApplicationPathFinder>!", mockAssert.LastMessage); }
public void IsNotNull_Pass() { MockAssertResultHandler mockAssert = new MockAssertResultHandler(); ServiceLocator.AssertResultHandler = mockAssert; ApplicationPathFinder finder = new ApplicationPathFinder("foo"); MWTAssert.IsNotNull(finder, "Error Message"); UnitTestAssert.AreEqual("Assert.IsNotNull", mockAssert.LastMessage); }
public static ViewDocumentResponse ViewDocument(string path) { string request = path; GroupDocs.Annotation.License lic = new GroupDocs.Annotation.License(); lic.SetLicense("C:/Users/SharePoint/Documents/Aspose/GroupDocs.Total.lic"); string fileName = Path.GetFileName(request); var pathFinder = new ApplicationPathFinder(); string _appPath = HttpContext.Current.Server.MapPath("~/_layouts/15/GroupDocs_Annotation_SharePoint_WebPart/"); ViewDocumentResponse result = new ViewDocumentResponse { pageCss = new string[] { }, lic = true, pdfDownloadUrl = _appPath + "App_Data/" + request, url = _appPath + "App_Data/" + request, path = request, name = fileName }; DocumentInfoContainer docInfo = null; try { docInfo = annotator.GetDocumentInfo(request); } catch (Exception ex) { throw; } result.documentDescription = new FileDataJsonSerializer(docInfo.Pages).Serialize(true); result.docType = docInfo.DocumentType; result.fileType = docInfo.FileType; List <PageImage> imagePages = annotator.GetPages(request); // Provide images urls List <string> urls = new List <string>(); // If no cache - save images to temp folder string tempFolderPath = HttpContext.Current.Server.MapPath("~/_layouts/15/GroupDocs_Annotation_SharePoint_WebPart/Content/TempStorage"); foreach (PageImage pageImage in imagePages) { string docFoldePath = Path.Combine(tempFolderPath, request); if (!Directory.Exists(docFoldePath)) { Directory.CreateDirectory(docFoldePath); } string pageImageName = string.Format("{0}\\{1}.png", docFoldePath, pageImage.PageNumber); using (Stream stream = pageImage.Stream) using (FileStream fileStream = new FileStream(pageImageName, FileMode.Create)) { stream.Seek(0, SeekOrigin.Begin); stream.CopyTo(fileStream); } string baseUrl = HttpContext.Current.Request.Url.Scheme + "://" + HttpContext.Current.Request.Url.Authority + HttpContext.Current.Request.ApplicationPath + "_layouts/15/GroupDocs_Annotation_SharePoint_WebPart/"; urls.Add(string.Format("{0}Content/TempStorage/{1}/{2}.png", baseUrl, request, pageImage.PageNumber)); } result.imageUrls = urls.ToArray(); // invoke event new DocumentOpenSubscriber().HandleEvent(request, _annotationSvc); return(result); }