Exemple #1
0
                public async Task ShouldCreateMagickImage()
                {
                    var factory = new MagickImageFactory();
                    var data    = new byte[]
                    {
                        0, 0, 0, 0, 0, 0, 0, 0,
                        0, 0, 0, 0, 0, 0, 0, 0,
                        0, 0, 0, 0, 0, 0, 0, 0,
                        0, 0, 0, 0, 0, 0, 0xf0, 0x3f,
                        0, 0, 0, 0, 0, 0, 0, 0,
                        0, 0, 0, 0, 0, 0, 0xf0, 0x3f,
                        0, 0, 0, 0, 0, 0, 0, 0,
                        0, 0, 0, 0, 0, 0, 0, 0,
                    };

                    var settings = new PixelReadSettings(2, 1, StorageType.Double, PixelMapping.RGBA);

                    using (var temporaryFile = new TemporaryFile(data))
                    {
                        using (var image = await factory.CreateAsync(temporaryFile.FileInfo, settings))
                        {
                            Assert.IsType <MagickImage>(image);
                            Assert.Equal(2, image.Width);
                        }
                    }
                }
Exemple #2
0
                public async Task ShouldThrowExceptionWhenFileInfoIsNull()
                {
                    var factory  = new MagickImageFactory();
                    var settings = new PixelReadSettings();

                    await Assert.ThrowsAsync <ArgumentNullException>("file", () => factory.CreateAsync((FileInfo)null, settings));
                }
Exemple #3
0
                public async Task ShouldThrowExceptionWhenFileNameIsEmpty()
                {
                    var factory  = new MagickImageFactory();
                    var settings = new PixelReadSettings();

                    await Assert.ThrowsAsync <ArgumentException>("fileName", () => factory.CreateAsync(string.Empty, settings));
                }
                public async Task ShouldThrowExceptionWhenStreamIsEmpty()
                {
                    var factory  = new MagickImageFactory();
                    var settings = new PixelReadSettings();

                    await Assert.ThrowsAsync <ArgumentException>("stream", () => factory.CreateAsync(new MemoryStream(), settings));
                }
                public async Task ShouldThrowExceptionWhenStreamIsNull()
                {
                    var factory  = new MagickImageFactory();
                    var settings = new MagickReadSettings();

                    await Assert.ThrowsAsync <ArgumentNullException>("stream", () => factory.CreateAsync((Stream)null, settings));
                }
Exemple #6
0
                public async Task ShouldNotThrowExceptionWhenSettingsIsNull()
                {
                    var factory = new MagickImageFactory();

                    using (var image = await factory.CreateAsync(new FileInfo(Files.CirclePNG), (MagickReadSettings)null))
                    {
                        Assert.IsType <MagickImage>(image);
                    }
                }
Exemple #7
0
                public async Task ShouldCreateMagickImage()
                {
                    var factory = new MagickImageFactory();

                    using (var image = await factory.CreateAsync(Files.ImageMagickJPG))
                    {
                        Assert.IsType <MagickImage>(image);
                        Assert.Equal(123, image.Width);
                    }
                }
Exemple #8
0
                public async Task ShouldThrowExceptionWhenSettingsIsNull()
                {
                    var factory = new MagickImageFactory();

                    await Assert.ThrowsAsync <ArgumentNullException>("settings", () => factory.CreateAsync(new FileInfo(Files.CirclePNG), (PixelReadSettings)null));
                }
Exemple #9
0
                public async Task ShouldThrowExceptionWhenFileInfoIsNull()
                {
                    var factory = new MagickImageFactory();

                    await Assert.ThrowsAsync <ArgumentNullException>("fileName", () => factory.CreateAsync((string)null));
                }
                public async Task ShouldNotThrowExceptionWhenSettingsIsNull()
                {
                    var factory = new MagickImageFactory();

                    using (var fileStream = File.OpenRead(Files.CirclePNG))
                    {
                        await Assert.ThrowsAsync <ArgumentNullException>("settings", () => factory.CreateAsync(fileStream, (PixelReadSettings)null));
                    }
                }