PdfThumbnailProviderTests.cs
1 // Copyright (c) Microsoft Corporation 2 // The Microsoft Corporation licenses this file to you under the MIT license. 3 // See the LICENSE file in the project root for more information. 4 5 using System; 6 using System.Drawing; 7 using System.IO; 8 using System.Runtime.InteropServices; 9 using System.Runtime.InteropServices.ComTypes; 10 11 using Common.ComInterlop; 12 using Microsoft.PowerToys.ThumbnailHandler.Pdf; 13 using Microsoft.VisualStudio.TestTools.UnitTesting; 14 using Moq; 15 16 namespace PdfThumbnailProviderUnitTests 17 { 18 [STATestClass] 19 public class PdfThumbnailProviderTests 20 { 21 [TestMethod] 22 public void GetThumbnailValidStreamPDF() 23 { 24 // Act 25 var filePath = System.IO.Path.GetFullPath("HelperFiles/sample.pdf"); 26 27 PdfThumbnailProvider provider = new PdfThumbnailProvider(filePath); 28 29 Bitmap bitmap = provider.GetThumbnail(256); 30 31 Assert.IsTrue(bitmap != null); 32 } 33 34 [TestMethod] 35 public void GetThumbnailInValidSizePDF() 36 { 37 // Act 38 var filePath = System.IO.Path.GetFullPath("HelperFiles/sample.pdf"); 39 40 PdfThumbnailProvider provider = new PdfThumbnailProvider(filePath); 41 42 Bitmap bitmap = provider.GetThumbnail(0); 43 44 Assert.IsTrue(bitmap == null); 45 } 46 47 [TestMethod] 48 public void GetThumbnailToBigPDF() 49 { 50 // Act 51 var filePath = System.IO.Path.GetFullPath("HelperFiles/sample.pdf"); 52 53 PdfThumbnailProvider provider = new PdfThumbnailProvider(filePath); 54 55 Bitmap bitmap = provider.GetThumbnail(10001); 56 57 Assert.IsTrue(bitmap == null); 58 } 59 } 60 }