|
@@ -1,6 +1,7 @@
|
|
|
using System;
|
|
|
using System.Windows.Media;
|
|
|
using System.Windows.Media.Imaging;
|
|
|
+using PixiEditor.Exceptions;
|
|
|
using PixiEditor.Models.IO;
|
|
|
using Xunit;
|
|
|
|
|
@@ -9,11 +10,13 @@ namespace PixiEditorTests.ModelsTests.IO
|
|
|
public class ImporterTests
|
|
|
{
|
|
|
private readonly string testImagePath;
|
|
|
+ private readonly string testCorruptedPixiImagePath;
|
|
|
|
|
|
// I am not testing ImportDocument, because it's just a wrapper for BinarySerialization which is tested.
|
|
|
public ImporterTests()
|
|
|
{
|
|
|
testImagePath = $"{Environment.CurrentDirectory}\\..\\..\\..\\ModelsTests\\IO\\TestImage.png";
|
|
|
+ testCorruptedPixiImagePath = $"{Environment.CurrentDirectory}\\..\\..\\..\\ModelsTests\\IO\\CorruptedPixiFile.pixi";
|
|
|
}
|
|
|
|
|
|
[Theory]
|
|
@@ -43,6 +46,21 @@ namespace PixiEditorTests.ModelsTests.IO
|
|
|
Assert.Equal(color, image.GetPixel(2, 2)); // Middle center
|
|
|
}
|
|
|
|
|
|
+ [Fact]
|
|
|
+ public void TestThatImporterThrowsCorruptedFileExceptionOnWrongPixiFileWithSupportedExtension()
|
|
|
+ {
|
|
|
+ Assert.Throws<CorruptedFileException>(() => { Importer.ImportDocument(testCorruptedPixiImagePath); });
|
|
|
+ }
|
|
|
+
|
|
|
+ [Theory]
|
|
|
+ [InlineData("CorruptedPNG.png")]
|
|
|
+ [InlineData("CorruptedJpg.jpg")]
|
|
|
+ public void TestThatImporterThrowsCorruptedFileExceptionOnWrongImageFileWithSupportedExtension(string fileName)
|
|
|
+ {
|
|
|
+ string imagePath = $"{Environment.CurrentDirectory}\\..\\..\\..\\ModelsTests\\IO\\{fileName}";
|
|
|
+ Assert.Throws<CorruptedFileException>(() => { Importer.ImportImage(imagePath); });
|
|
|
+ }
|
|
|
+
|
|
|
[Fact]
|
|
|
public void TestThatImportImageResizes()
|
|
|
{
|