// Copyright (c) Six Labors and contributors. // Licensed under the Apache License, Version 2.0. using System; using SixLabors.ImageSharp.Formats; using SixLabors.ImageSharp.PixelFormats; using Xunit; namespace SixLabors.ImageSharp.Tests { public partial class ImageTests { public class Load_FileSystemPath_PassLocalConfiguration : ImageLoadTestBase { [Fact] public void Configuration_Path_Specific() { var img = Image.Load(this.TopLevelConfiguration, this.MockFilePath); Assert.NotNull(img); Assert.Equal(this.TestFormat.Sample(), img); this.TestFormat.VerifySpecificDecodeCall(this.Marker, this.TopLevelConfiguration); } [Fact] public void Configuration_Path_Agnostic() { var img = Image.Load(this.TopLevelConfiguration, this.MockFilePath); Assert.NotNull(img); Assert.Equal(this.TestFormat.SampleAgnostic(), img); this.TestFormat.VerifyAgnosticDecodeCall(this.Marker, this.TopLevelConfiguration); } [Fact] public void Configuration_Path_Decoder_Specific() { var img = Image.Load(this.TopLevelConfiguration, this.MockFilePath, this.localDecoder.Object); Assert.NotNull(img); this.localDecoder.Verify(x => x.Decode(this.TopLevelConfiguration, this.DataStream)); } [Fact] public void Configuration_Path_Decoder_Agnostic() { var img = Image.Load(this.TopLevelConfiguration, this.MockFilePath, this.localDecoder.Object); Assert.NotNull(img); this.localDecoder.Verify(x => x.Decode(this.TopLevelConfiguration, this.DataStream)); } [Fact] public void Configuration_Path_OutFormat_Specific() { var img = Image.Load(this.TopLevelConfiguration, this.MockFilePath, out IImageFormat format); Assert.NotNull(img); Assert.Equal(this.TestFormat, format); this.TestFormat.VerifySpecificDecodeCall(this.Marker, this.TopLevelConfiguration); } [Fact] public void Configuration_Path_OutFormat_Agnostic() { var img = Image.Load(this.TopLevelConfiguration, this.MockFilePath, out IImageFormat format); Assert.NotNull(img); Assert.Equal(this.TestFormat, format); this.TestFormat.VerifyAgnosticDecodeCall(this.Marker, this.TopLevelConfiguration); } [Fact] public void WhenFileNotFound_Throws() { Assert.Throws( () => { Image.Load(this.TopLevelConfiguration, Guid.NewGuid().ToString()); }); } [Fact] public void WhenPathIsNull_Throws() { Assert.Throws( () => { Image.Load(this.TopLevelConfiguration, (string)null); }); } } } }