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."); }
public void Compress_StreamCannotWrite_ThrowsException() { using (TestStream stream = new TestStream(true, false, true)) { ExceptionAssert.ThrowsArgumentException("stream", () => { Optimizer.Compress(stream); }); } }
public void ShouldThrowExceptionWhenImagesIsMagickImageCollection() { using (var images = new MagickImageCollection(Files.SnakewarePNG)) { ExceptionAssert.ThrowsArgumentException("images", () => { images.AddRange(images); }); } }
public void ShouldThrowExceptionWhenByteArrayIsEmpty() { ExceptionAssert.ThrowsArgumentException("data", () => { using (IMagickImageCollection images = new MagickImageCollection()) { images.AddRange(new byte[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))); }
public void ShouldThrowExceptionWhenFileNameIsEmpty() { ExceptionAssert.ThrowsArgumentException("fileName", () => { using (IMagickImageCollection images = new MagickImageCollection()) { images.AddRange(string.Empty); } }); }
public void ShouldThrowAnExceptionWhenArgumentsIsEmptyAndSettingsIsNot() { using (IMagickImage image = new MagickImage()) { ExceptionAssert.ThrowsArgumentException("arguments", () => { image.Distort(DistortMethod.Perspective, new DistortSettings(), new double[] { }); }); } }
public void ShouldThrowExceptionWhenStreamIsNotReadable() { using (TestStream stream = new TestStream(false, true, true)) { ExceptionAssert.ThrowsArgumentException("stream", () => { StreamWrapper.CreateForReading(stream); }, "readable"); } }
public void LosslessCompress_StreamCannotRead_ThrowsException() { using (TestStream stream = new TestStream(false, true, true)) { ExceptionAssert.ThrowsArgumentException("stream", () => { Optimizer.LosslessCompress(stream); }); } }
public void Constructor_StreamCannotRead_ThrowsException() { using (TestStream stream = new TestStream(false, true, true)) { ExceptionAssert.ThrowsArgumentException("stream", () => { new Bytes(stream); }); } }
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."); }
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."); }
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"); }); }
public void Test_Constructor() { ExceptionAssert.ThrowsArgumentException("shade", () => { new ColorGray(1.01); }); ExceptionAssert.ThrowsArgumentException("shade", () => { new ColorGray(-0.01); }); }
public void Constructor_StreamIsTooLong_ThrowsException() { using (TestStream stream = new TestStream(true, true, true)) { stream.SetLength(long.MaxValue); ExceptionAssert.ThrowsArgumentException("length", () => { new Bytes(stream); }); } }
public void Constructor_StreamPositionIsNotZero_ThrowsException() { using (MemoryStream memStream = new MemoryStream()) { memStream.Position = 10; ExceptionAssert.ThrowsArgumentException("stream", () => { new Bytes(memStream); }); } }
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); }
public void ShouldThrowExceptionWhenArrayIsEmpty() { using (IMagickImage image = new MagickImage(Files.ImageMagickJPG)) { using (IPixelCollection pixels = image.GetPixels()) { ExceptionAssert.ThrowsArgumentException("value", () => { pixels.SetPixel(0, 0, new QuantumType[] { }); }); } } }
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); }); } }
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 }); }); } } }
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); }); } } }
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; }); }
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; }); }
public void ShouldThrowExceptionWhenMappingIsEmpty() { using (IMagickImage image = new MagickImage(Files.ImageMagickJPG)) { using (IPixelCollection pixels = image.GetPixels()) { ExceptionAssert.ThrowsArgumentException("mapping", () => { pixels.ToByteArray(string.Empty); }); } } }
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); }); } } }
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()); }