diff --git a/tests/Shared.LibraryTests/Classes/Images/DDSImageTests.cs b/tests/Shared.LibraryTests/Classes/Images/DDSImageTests.cs index 6bb9b3a..ae3180e 100644 --- a/tests/Shared.LibraryTests/Classes/Images/DDSImageTests.cs +++ b/tests/Shared.LibraryTests/Classes/Images/DDSImageTests.cs @@ -1,26 +1,29 @@ using Shared.Library.Factories; using Shared.Library.Interfaces; -using TC = Shared.LibraryTests.TestConstants; - namespace Shared.LibraryTests.Classes.Images; [TestClass] -[SuppressMessage("Style", "IDE0058", Justification = "UnitTest")] +[DeploymentItem(TestConstants.DdsImage, TestConstants.SourceFolder)] public class DDSImageTests { + private readonly string _sourcePath; + private readonly string _targetPath; + public DDSImageTests() { - Directory.CreateDirectory(TC.SourceFolder); - Directory.CreateDirectory(TC.TargetFolder); + _sourcePath = Path.Combine(AppContext.BaseDirectory, TestConstants.SourceFolder); + _targetPath = Path.Combine(AppContext.BaseDirectory, TestConstants.TargetFolder); + + Directory.CreateDirectory(_sourcePath); + Directory.CreateDirectory(_targetPath); } [TestMethod] - [DeploymentItem(TC.DdsImage, TC.SourceFolder)] public void SaveTest() { - string sourceFolder = $"{TC.SourceFolder}\\{TC.DdsImage}"; - string targetFolder = $"{TC.TargetFolder}\\{TC.PngImageSave}"; + string sourceFolder = Path.Combine(_sourcePath, TestConstants.DdsImage); + string targetFolder = Path.Combine(_targetPath, TestConstants.PngImageSave); IImage image = ImageFactory.CreateDdsImage(sourceFolder); image.Save(targetFolder); @@ -36,25 +39,23 @@ public void SaveTest() } [TestMethod] - [DeploymentItem(TC.DdsImage, TC.SourceFolder)] [ExpectedException(typeof(ArgumentOutOfRangeException))] public void SaveWithCompressionExceptionTest() { int compressionLevel = 99; - string sourceFolder = $"{TC.SourceFolder}\\{TC.DdsImage}"; - string targetFolder = $"{TC.TargetFolder}\\{TC.PngImageSave}"; + string sourceFolder = Path.Combine(_sourcePath, TestConstants.DdsImage); + string targetFolder = Path.Combine(_targetPath, TestConstants.PngImageSave); IImage image = ImageFactory.CreateDdsImage(sourceFolder); image.Save(targetFolder, compressionLevel); } [TestMethod] - [DeploymentItem(TC.DdsImage, TC.SourceFolder)] public void SaveWithCompressionTest() { int compressionLevel = 9; - string sourceFolder = $"{TC.SourceFolder}\\{TC.DdsImage}"; - string targetFolder = $"{TC.TargetFolder}\\{compressionLevel}_{TC.PngImageSave}"; + string sourceFolder = Path.Combine(_sourcePath, TestConstants.DdsImage); + string targetFolder = Path.Combine(_targetPath, $"{compressionLevel}_{TestConstants.PngImageSave}"); IImage image = ImageFactory.CreateDdsImage(sourceFolder); image.Save(targetFolder, compressionLevel); diff --git a/tests/Shared.LibraryTests/Classes/Images/PNGImageTests.cs b/tests/Shared.LibraryTests/Classes/Images/PNGImageTests.cs index d42b29c..b7e7728 100644 --- a/tests/Shared.LibraryTests/Classes/Images/PNGImageTests.cs +++ b/tests/Shared.LibraryTests/Classes/Images/PNGImageTests.cs @@ -1,26 +1,30 @@ using Shared.Library.Factories; using Shared.Library.Interfaces; -using TC = Shared.LibraryTests.TestConstants; - namespace Shared.LibraryTests.Classes.Images; [TestClass] -[SuppressMessage("Style", "IDE0058", Justification = "UnitTest")] +[DeploymentItem(TestConstants.PngImage, TestConstants.SourceFolder)] public class PNGImageTests { + private readonly string _sourcePath; + private readonly string _targetPath; + public PNGImageTests() { - Directory.CreateDirectory(TC.SourceFolder); - Directory.CreateDirectory(TC.TargetFolder); + _sourcePath = Path.Combine(AppContext.BaseDirectory, TestConstants.SourceFolder); + _targetPath = Path.Combine(AppContext.BaseDirectory, TestConstants.TargetFolder); + + Directory.CreateDirectory(_sourcePath); + Directory.CreateDirectory(_targetPath); } [TestMethod] - [DeploymentItem(TC.PngImage, TC.SourceFolder)] + [DeploymentItem(TestConstants.PngImage, TestConstants.SourceFolder)] public void SaveTest() { - string sourceFolder = $"{TC.SourceFolder}\\{TC.PngImage}"; - string targetFolder = $"{TC.TargetFolder}\\{TC.DdsImageSave}"; + string sourceFolder = Path.Combine(_sourcePath, TestConstants.PngImage); + string targetFolder = Path.Combine(_targetPath, TestConstants.DdsImageSave); IImage image = ImageFactory.CreatePngImage(sourceFolder); image.Save(targetFolder); @@ -36,25 +40,25 @@ public void SaveTest() } [TestMethod] - [DeploymentItem(TC.PngImage, TC.SourceFolder)] + [DeploymentItem(TestConstants.PngImage, TestConstants.SourceFolder)] [ExpectedException(typeof(ArgumentOutOfRangeException))] public void SaveWithCompressionExceptionTest() { int compressionLevel = 99; - string sourceFolder = $"{TC.SourceFolder}\\{TC.PngImage}"; - string targetFolder = $"{TC.TargetFolder}\\{TC.DdsImageSave}"; + string sourceFolder = Path.Combine(_sourcePath, TestConstants.PngImage); + string targetFolder = Path.Combine(_targetPath, TestConstants.DdsImageSave); IImage image = ImageFactory.CreatePngImage(sourceFolder); image.Save(targetFolder, compressionLevel); } [TestMethod] - [DeploymentItem(TC.PngImage, TC.SourceFolder)] + [DeploymentItem(TestConstants.PngImage, TestConstants.SourceFolder)] public void SaveWithCompressionTest() { int compressionLevel = 0; - string sourceFolder = $"{TC.SourceFolder}\\{TC.PngImage}"; - string targetFolder = $"{TC.TargetFolder}\\{compressionLevel}_{TC.DdsImageSave}"; + string sourceFolder = Path.Combine(_sourcePath, TestConstants.PngImage); + string targetFolder = Path.Combine(_targetPath, $"{compressionLevel}_{TestConstants.DdsImageSave}"); IImage image = ImageFactory.CreatePngImage(sourceFolder); image.Save(targetFolder, compressionLevel); diff --git a/tests/Shared.LibraryTests/Shared.LibraryTests.csproj b/tests/Shared.LibraryTests/Shared.LibraryTests.csproj index 1ca20f1..edc6e40 100644 --- a/tests/Shared.LibraryTests/Shared.LibraryTests.csproj +++ b/tests/Shared.LibraryTests/Shared.LibraryTests.csproj @@ -6,7 +6,7 @@ - +