Exemplo n.º 1
0
 public void ShouldThrowExceptionWhenArgumentsIsEmpty()
 {
     using (IMagickImage image = new MagickImage())
     {
         ExceptionAssert.ThrowsArgumentException("arguments", () =>
         {
             image.Evaluate(Channels.Red, EvaluateFunction.Arcsin, new double[] { });
         });
     }
 }
        public void SettingActivePackageSourceToNonExistantSourceThrows()
        {
            // Arrange
            var userSettingsManager     = new MockUserSettingsManager();
            var registrySettingsManager = new MockPackageSourceSettingsManager();
            var provider = new VsPackageSourceProvider(registrySettingsManager, userSettingsManager);

            // Act
            ExceptionAssert.ThrowsArgumentException(() => provider.ActivePackageSource = new PackageSource("a", "a"), "value", "The package source does not belong to the collection of available sources.");
        }
Exemplo n.º 3
0
 public void Compress_StreamCannotWrite_ThrowsException()
 {
     using (TestStream stream = new TestStream(true, false, true))
     {
         ExceptionAssert.ThrowsArgumentException("stream", () =>
         {
             Optimizer.Compress(stream);
         });
     }
 }
Exemplo n.º 4
0
 public void ShouldThrowExceptionWhenImagesIsMagickImageCollection()
 {
     using (var images = new MagickImageCollection(Files.SnakewarePNG))
     {
         ExceptionAssert.ThrowsArgumentException("images", () =>
         {
             images.AddRange(images);
         });
     }
 }
Exemplo n.º 5
0
 public void ShouldThrowExceptionWhenByteArrayIsEmpty()
 {
     ExceptionAssert.ThrowsArgumentException("data", () =>
     {
         using (IMagickImageCollection images = new MagickImageCollection())
         {
             images.AddRange(new byte[0]);
         }
     });
 }
Exemplo n.º 6
0
        public void ConstructorThrowsWhenTemplateNotFound()
        {
            var templateFile = @"FileNotFound.xml";

            ExceptionAssert.ThrowsArgumentException(() => {
                new Chart(GetContext(), GetVirtualPathProvider(), 100, 100, themePath: templateFile);
            },
                                                    "themePath",
                                                    String.Format("The theme file \"{0}\" could not be found.", VirtualPathUtility.Combine(GetContext().Request.AppRelativeCurrentExecutionFilePath, templateFile)));
        }
Exemplo n.º 7
0
 public void ShouldThrowExceptionWhenFileNameIsEmpty()
 {
     ExceptionAssert.ThrowsArgumentException("fileName", () =>
     {
         using (IMagickImageCollection images = new MagickImageCollection())
         {
             images.AddRange(string.Empty);
         }
     });
 }
Exemplo n.º 8
0
 public void ShouldThrowAnExceptionWhenArgumentsIsEmptyAndSettingsIsNot()
 {
     using (IMagickImage image = new MagickImage())
     {
         ExceptionAssert.ThrowsArgumentException("arguments", () =>
         {
             image.Distort(DistortMethod.Perspective, new DistortSettings(), new double[] { });
         });
     }
 }
Exemplo n.º 9
0
 public void ShouldThrowExceptionWhenStreamIsNotReadable()
 {
     using (TestStream stream = new TestStream(false, true, true))
     {
         ExceptionAssert.ThrowsArgumentException("stream", () =>
         {
             StreamWrapper.CreateForReading(stream);
         }, "readable");
     }
 }
Exemplo n.º 10
0
 public void LosslessCompress_StreamCannotRead_ThrowsException()
 {
     using (TestStream stream = new TestStream(false, true, true))
     {
         ExceptionAssert.ThrowsArgumentException("stream", () =>
         {
             Optimizer.LosslessCompress(stream);
         });
     }
 }
Exemplo n.º 11
0
 public void Constructor_StreamCannotRead_ThrowsException()
 {
     using (TestStream stream = new TestStream(false, true, true))
     {
         ExceptionAssert.ThrowsArgumentException("stream", () =>
         {
             new Bytes(stream);
         });
     }
 }
Exemplo n.º 12
0
        public void TextAreaWithEmptyNameThrows()
        {
            // Arrange
            HtmlHelper helper = new HtmlHelper(new ModelStateDictionary());

            // Act and assert
            ExceptionAssert.ThrowsArgumentException(() => helper.TextArea(null), "name", "Value cannot be null or an empty string.");

            // Act and assert
            ExceptionAssert.ThrowsArgumentException(() => helper.TextArea(String.Empty), "name", "Value cannot be null or an empty string.");
        }
Exemplo n.º 13
0
 public void Test_Image_Exceptions()
 {
     ExceptionAssert.ThrowsArgumentException("readSettings", () =>
     {
         MagickReadSettings settings = new MagickReadSettings
         {
             FrameCount = 2,
         };
         new MagickImage(Files.RoseSparkleGIF, settings);
     });
 }
        public void SettingActivePackageSourceToNonExistantSourceThrows()
        {
            // Arrange
            var userSettings          = new Mock <ISettings>();
            var packageSourceProvider = CreateDefaultSourceProvider(userSettings.Object);
            var provider = new VsPackageSourceProvider(userSettings.Object, packageSourceProvider, new Mock <IVsShellInfo>().Object);

            // Act
            ExceptionAssert.ThrowsArgumentException(() => provider.ActivePackageSource = new PackageSource("a", "a"), "value",
                                                    "The package source does not belong to the collection of available sources.");
        }
Exemplo n.º 15
0
            public void ShouldThrowExceptionWhenValueIsInvalid()
            {
                ExceptionAssert.ThrowsArgumentException("value", () => { new Density("1.0x"); });

                ExceptionAssert.ThrowsArgumentException("value", () => { new Density("x1.0"); });

                ExceptionAssert.ThrowsArgumentException("value", () => { new Density("ax1.0"); });

                ExceptionAssert.ThrowsArgumentException("value", () => { new Density("1.0xb"); });

                ExceptionAssert.ThrowsArgumentException("value", () => { new Density("1.0x6 magick"); });
            }
Exemplo n.º 16
0
        public void Test_Constructor()
        {
            ExceptionAssert.ThrowsArgumentException("shade", () =>
            {
                new ColorGray(1.01);
            });

            ExceptionAssert.ThrowsArgumentException("shade", () =>
            {
                new ColorGray(-0.01);
            });
        }
Exemplo n.º 17
0
        public void Constructor_StreamIsTooLong_ThrowsException()
        {
            using (TestStream stream = new TestStream(true, true, true))
            {
                stream.SetLength(long.MaxValue);

                ExceptionAssert.ThrowsArgumentException("length", () =>
                {
                    new Bytes(stream);
                });
            }
        }
Exemplo n.º 18
0
        public void Constructor_StreamPositionIsNotZero_ThrowsException()
        {
            using (MemoryStream memStream = new MemoryStream())
            {
                memStream.Position = 10;

                ExceptionAssert.ThrowsArgumentException("stream", () =>
                {
                    new Bytes(memStream);
                });
            }
        }
Exemplo n.º 19
0
            public void ShouldThrowExceptionWhenGeometryIsPercentage()
            {
                using (IMagickImage image = new MagickImage())
                {
                    ExceptionAssert.ThrowsArgumentException("geometry", () =>
                    {
                        var geometry = new MagickGeometry(new Percentage(100), new Percentage(100));

                        image.Evaluate(Channels.Red, geometry, EvaluateOperator.Set, 0.0);
                    });
                }
            }
                public void ShouldThrowExceptionWhenStreamCannotSeek()
                {
                    var optimizer = new ImageOptimizer();

                    using (TestStream stream = new TestStream(true, true, false))
                    {
                        ExceptionAssert.ThrowsArgumentException("stream", () =>
                        {
                            optimizer.Compress(stream);
                        });
                    }
                }
 private void Test_SetCoordinates(string paramName, PointD topLeft, PointD topRight, PointD bottomLeft, PointD bottomRight)
 {
     ExceptionAssert.ThrowsArgumentException <ArgumentOutOfRangeException>(delegate()
     {
         using (var logo = Images.Logo)
         {
             var script = new WhiteboardScript();
             script.SetCoordinates(topLeft, topRight, bottomLeft, bottomRight);
             script.Execute(logo);
         }
     }, paramName);
 }
Exemplo n.º 22
0
 public void ShouldThrowExceptionWhenArrayIsEmpty()
 {
     using (IMagickImage image = new MagickImage(Files.ImageMagickJPG))
     {
         using (IPixelCollection pixels = image.GetPixels())
         {
             ExceptionAssert.ThrowsArgumentException("value", () =>
             {
                 pixels.SetPixel(0, 0, new QuantumType[] { });
             });
         }
     }
 }
Exemplo n.º 23
0
        public void Test_Collection_Exceptions()
        {
            using (IMagickImageCollection collection = new MagickImageCollection())
            {
                MagickReadSettings settings = new MagickReadSettings();
                settings.PixelStorage = new PixelStorageSettings();

                ExceptionAssert.ThrowsArgumentException("readSettings", () =>
                {
                    collection.Read(Files.RoseSparkleGIF, settings);
                });
            }
        }
Exemplo n.º 24
0
 public void ShouldThrowExceptionWhenByteArrayHasInvalidSize()
 {
     using (IMagickImage image = new MagickImage(Files.ImageMagickJPG))
     {
         using (IPixelCollection pixels = image.GetPixels())
         {
             ExceptionAssert.ThrowsArgumentException("values", () =>
             {
                 pixels.SetArea(10, 10, 1000, 1000, new byte[] { 0, 0, 0, 0 });
             });
         }
     }
 }
Exemplo n.º 25
0
 public void ShouldThrowExceptionWhenGeometryIsSpecifiedAndMappingIsEmpty()
 {
     using (IMagickImage image = new MagickImage(Files.ImageMagickJPG))
     {
         using (IPixelCollection pixels = image.GetPixels())
         {
             ExceptionAssert.ThrowsArgumentException("mapping", () =>
             {
                 pixels.ToShortArray(new MagickGeometry(1, 2, 3, 4), string.Empty);
             });
         }
     }
 }
Exemplo n.º 26
0
            public void ShouldThrowExceptionWhenValueIsInvalidDataType1()
            {
                var profile = new ExifProfile();

                profile.SetValue(ExifTag.Software, "Magick.NET");

                var value = profile.GetValue(ExifTag.Software);

                ExceptionAssert.ThrowsArgumentException("value", () =>
                {
                    value.Value = 15;
                });
            }
Exemplo n.º 27
0
            public void ShouldThrowExceptionWhenValueIsInvalidDataType2()
            {
                var profile = new ExifProfile();

                profile.SetValue(ExifTag.ShutterSpeedValue, new SignedRational(75.55));

                var value = profile.GetValue(ExifTag.ShutterSpeedValue);

                ExceptionAssert.ThrowsArgumentException("value", () =>
                {
                    value.Value = 75;
                });
            }
Exemplo n.º 28
0
 public void ShouldThrowExceptionWhenMappingIsEmpty()
 {
     using (IMagickImage image = new MagickImage(Files.ImageMagickJPG))
     {
         using (IPixelCollection pixels = image.GetPixels())
         {
             ExceptionAssert.ThrowsArgumentException("mapping", () =>
             {
                 pixels.ToByteArray(string.Empty);
             });
         }
     }
 }
Exemplo n.º 29
0
 public void ShouldThrowExceptionWhenByteArrayHasTooManyValues()
 {
     using (IMagickImage image = new MagickImage(Files.ImageMagickJPG))
     {
         using (IPixelCollection pixels = image.GetPixels())
         {
             ExceptionAssert.ThrowsArgumentException("values", () =>
             {
                 var values = new byte[(113 * 108 * image.ChannelCount) + image.ChannelCount];
                 pixels.SetArea(10, 10, 113, 108, values);
             });
         }
     }
 }
Exemplo n.º 30
0
        public void Test_Constructor()
        {
            PointD point = default(PointD);

            Assert.AreEqual(0.0, point.X);
            Assert.AreEqual(0.0, point.Y);

            point = new PointD(5);
            Assert.AreEqual(5.0, point.X);
            Assert.AreEqual(5.0, point.Y);

            point = new PointD(5, 10);
            Assert.AreEqual(5.0, point.X);
            Assert.AreEqual(10.0, point.Y);

            ExceptionAssert.ThrowsArgumentNullException("value", () =>
            {
                new PointD(null);
            });

            ExceptionAssert.ThrowsArgumentException("value", () =>
            {
                new PointD(string.Empty);
            });

            ExceptionAssert.ThrowsArgumentException("value", () =>
            {
                new PointD("1.0x");
            });

            ExceptionAssert.ThrowsArgumentException("value", () =>
            {
                new PointD("x1.0");
            });

            ExceptionAssert.ThrowsArgumentException("value", () =>
            {
                new PointD("ax1.0");
            });

            ExceptionAssert.ThrowsArgumentException("value", () =>
            {
                new PointD("1.0xb");
            });

            point = new PointD("1.0x2.5");
            Assert.AreEqual(1.0, point.X);
            Assert.AreEqual(2.5, point.Y);
            Assert.AreEqual("1x2.5", point.ToString());
        }