コード例 #1
0
 public void GetTinyImage_DoesNotChangeSize()
 {
     using (var cache = new RuntimeImageProcessor(new BookRenamedEvent())
     {
         TargetDimension = 100
     })
         using (var file = MakeTempPNGImage(10, 10))
         {
             using (var img = ImageUtils.GetImageFromFile(cache.GetPathToResizedImage(file.Path)))
             {
                 Assert.AreEqual(10, img.Width);
             }
         }
 }
コード例 #2
0
 public void GetWideImage_ReturnsShrunkImageWithCorrectProportions()
 {
     using (var cache = new RuntimeImageProcessor(new BookRenamedEvent())
     {
         TargetDimension = 100
     })
         using (var file = MakeTempPNGImage(200, 80))
         {
             using (var img = ImageUtils.GetImageFromFile(cache.GetPathToResizedImage(file.Path)))
             {
                 Assert.AreEqual(100, img.Width);
                 Assert.AreEqual(40, img.Height);
             }
         }
 }
コード例 #3
0
        public void GetJPG_ReturnsShrunkJPG()
        {
            using (var cache = new RuntimeImageProcessor(new BookRenamedEvent())
            {
                TargetDimension = 100
            })
                using (var file = MakeTempJPGImage(200, 80))
                {
                    var pathToResizedImage = cache.GetPathToResizedImage(file.Path);
                    using (var img = ImageUtils.GetImageFromFile(pathToResizedImage))
                    {
                        Assert.AreEqual(".jpg", Path.GetExtension(pathToResizedImage));

                        //TODO: why does this always report PNG format? Checks by hand of the file show it as jpg
                        //Assert.AreEqual(ImageFormat.Jpeg.Guid, img.RawFormat.Guid);

                        Assert.AreEqual(100, img.Width);
                        Assert.AreEqual(40, img.Height);
                    }
                }
        }