📷 A modern, cross-platform, 2D Graphics library for .NET
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 

64 lines
1.7 KiB

// <copyright file="PixelAccessorTests.cs" company="James Jackson-South">
// Copyright (c) James Jackson-South and contributors.
// Licensed under the Apache License, Version 2.0.
// </copyright>
namespace ImageSharp.Tests
{
using System;
using Xunit;
/// <summary>
/// Tests the <see cref="Image"/> class.
/// </summary>
public class ImageTests
{
[Fact]
public void ConstructorByteArray()
{
Assert.Throws<ArgumentNullException>(() =>
{
new Image((byte[])null);
});
TestFile file = TestFile.Create(TestImages.Bmp.Car);
using (Image image = new Image(file.Bytes))
{
Assert.Equal(600, image.Width);
Assert.Equal(450, image.Height);
}
}
[Fact]
public void ConstructorFileSystem()
{
TestFile file = TestFile.Create(TestImages.Bmp.Car);
using (Image image = new Image(file.FilePath))
{
Assert.Equal(600, image.Width);
Assert.Equal(450, image.Height);
}
}
[Fact]
public void ConstructorFileSystem_FileNotFound()
{
System.IO.FileNotFoundException ex = Assert.Throws<System.IO.FileNotFoundException>(
() =>
{
new Image(Guid.NewGuid().ToString());
});
}
[Fact]
public void ConstructorFileSystem_NullPath()
{
ArgumentNullException ex = Assert.Throws<ArgumentNullException>(
() =>
{
new Image(null);
});
}
}
}