Esempio n. 1
0
        public async Task RendererCreatesNecessaryDirectories()
        {
            var input = await SvgUtilities.CreateTempImage();

            var output = Path.Combine(
                Path.GetDirectoryName(input),
                Guid.NewGuid().ToString(),
                Path.ChangeExtension(Path.GetFileNameWithoutExtension(input), ".png"));

            Renderer.Render(input, output);
        }
Esempio n. 2
0
        public async Task SvgBuildTaskThrowsArgumentExceptionIfOnlyOneDimensionIfDefined()
        {
            var path = await SvgUtilities.CreateTempImage();

            var output = Path.ChangeExtension(Path.GetTempFileName(), "png");
            var task   = new SvgBuildTask {
                InputPath = path, OutputPath = output, Width = "123"
            };

            Assert.Throws <ArgumentException>(() => task.Execute());
        }
Esempio n. 3
0
        private async Task AssertRenderedImageFormat(string outputFileExtension, ImageFormat format)
        {
            var input = await SvgUtilities.CreateTempImage();

            var output = Path.ChangeExtension(Path.GetTempFileName(), outputFileExtension);

            Renderer.Render(input, output);

            var image = Image.FromFile(output);

            Assert.Equal(format, image.RawFormat);
        }
Esempio n. 4
0
        public async Task SavedImageHasRequiredSize()
        {
            var input = await SvgUtilities.CreateTempImage();

            var output = Path.ChangeExtension(Path.GetTempFileName(), "png");
            var size   = new Size(32, 32);

            Renderer.Render(input, output, size);

            var image = Image.FromFile(output);

            Assert.Equal(size, image.Size);
        }
Esempio n. 5
0
        public async Task SvgBuildTaskRendersTheProperSize()
        {
            var path = await SvgUtilities.CreateTempImage();

            var output = Path.ChangeExtension(Path.GetTempFileName(), "png");
            var task   = new SvgBuildTask {
                InputPath = path, OutputPath = output, Width = "32", Height = "32"
            };

            Assert.True(task.Execute());

            var image = Image.FromFile(output);

            Assert.Equal(32, image.Width);
            Assert.Equal(32, image.Height);
        }
Esempio n. 6
0
        public async Task SvgBuildTaskRendersTheFileWithDefaultSize()
        {
            var path = await SvgUtilities.CreateTempImage();

            var output = Path.ChangeExtension(Path.GetTempFileName(), "png");
            var task   = new SvgBuildTask {
                InputPath = path, OutputPath = output
            };

            Assert.True(task.Execute());

            var image = Image.FromFile(output);

            Assert.IsType <Bitmap>(image);
            Assert.Equal(101, image.Height);
            Assert.Equal(101, image.Width);
        }