From 5b81e46e342e980524b845e8dc7e2b509ee52b59 Mon Sep 17 00:00:00 2001 From: Sergio Pedri Date: Sat, 13 Aug 2022 02:41:17 +0200 Subject: [PATCH] Fix failing D2D1 tests due to missing directory --- .../D2D1ResourceTextureManagerTests.cs | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) diff --git a/tests/ComputeSharp.D2D1.Tests/D2D1ResourceTextureManagerTests.cs b/tests/ComputeSharp.D2D1.Tests/D2D1ResourceTextureManagerTests.cs index 5f0ab9e0..cd5e0e87 100644 --- a/tests/ComputeSharp.D2D1.Tests/D2D1ResourceTextureManagerTests.cs +++ b/tests/ComputeSharp.D2D1.Tests/D2D1ResourceTextureManagerTests.cs @@ -82,7 +82,6 @@ public partial class D2D1ResourceTextureManagerTests string assemblyPath = Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location)!; string expectedPath = Path.Combine(assemblyPath, "Assets", "Landscape.png"); - string destinationPath = Path.Combine(assemblyPath, "temp", "IndexedFromResourceTexture2D_After.png"); using Image expected = Image.Load(expectedPath); @@ -108,6 +107,10 @@ public partial class D2D1ResourceTextureManagerTests using ComPtr d2D1Bitmap1Buffer = D2D1Helper.CreateD2D1Bitmap1Buffer(d2D1DeviceContext.Get(), d2D1BitmapTarget.Get(), out D2D1_MAPPED_RECT d2D1MappedRect); + string destinationPath = Path.Combine(assemblyPath, "temp", "IndexedFromResourceTexture2D_After.png"); + + _ = Directory.CreateDirectory(Path.GetDirectoryName(destinationPath)!); + ImageHelper.SaveBitmapToFile(destinationPath, (uint)expected.Width, (uint)expected.Height, d2D1MappedRect.pitch, d2D1MappedRect.bits); TolerantImageComparer.AssertEqual(destinationPath, expectedPath, 0.00001f); @@ -134,7 +137,6 @@ public partial class D2D1ResourceTextureManagerTests string assemblyPath = Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location)!; string expectedPath = Path.Combine(assemblyPath, "Assets", "Landscape.png"); - string destinationPath = Path.Combine(assemblyPath, "temp", "IndexedFromResourceTexture2D_Before.png"); using Image expected = Image.Load(expectedPath); @@ -162,6 +164,10 @@ public partial class D2D1ResourceTextureManagerTests using ComPtr d2D1Bitmap1Buffer = D2D1Helper.CreateD2D1Bitmap1Buffer(d2D1DeviceContext.Get(), d2D1BitmapTarget.Get(), out D2D1_MAPPED_RECT d2D1MappedRect); + string destinationPath = Path.Combine(assemblyPath, "temp", "IndexedFromResourceTexture2D_Before.png"); + + _ = Directory.CreateDirectory(Path.GetDirectoryName(destinationPath)!); + ImageHelper.SaveBitmapToFile(destinationPath, (uint)expected.Width, (uint)expected.Height, d2D1MappedRect.pitch, d2D1MappedRect.bits); TolerantImageComparer.AssertEqual(destinationPath, expectedPath, 0.00001f); @@ -197,7 +203,6 @@ public partial class D2D1ResourceTextureManagerTests string assemblyPath = Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location)!; string expectedPath = Path.Combine(assemblyPath, "Assets", "WallpapersStack.png"); - string destinationPath = Path.Combine(assemblyPath, "temp", "IndexedFromResourceTexture3D.png"); using Image expected = Image.Load(expectedPath); @@ -233,6 +238,10 @@ public partial class D2D1ResourceTextureManagerTests using ComPtr d2D1Bitmap1Buffer = D2D1Helper.CreateD2D1Bitmap1Buffer(d2D1DeviceContext.Get(), d2D1BitmapTarget.Get(), out D2D1_MAPPED_RECT d2D1MappedRect); + string destinationPath = Path.Combine(assemblyPath, "temp", "IndexedFromResourceTexture3D.png"); + + _ = Directory.CreateDirectory(Path.GetDirectoryName(destinationPath)!); + ImageHelper.SaveBitmapToFile(destinationPath, (uint)expected.Width, (uint)expected.Height, d2D1MappedRect.pitch, d2D1MappedRect.bits); TolerantImageComparer.AssertEqual(destinationPath, expectedPath, 0.00001f);