From 8b7b53a6f7de3db023ac9e8ef7ebf4f644fc8da1 Mon Sep 17 00:00:00 2001 From: alexiscatnip Date: Thu, 20 Jan 2022 23:41:36 +0800 Subject: [PATCH] added test helpers to write image to disk easily --- Assets/Tests/Helper.cs | 22 ++++++++++++++++++++++ Assets/Tests/Helper.cs.meta | 3 +++ Assets/Tests/ImagingTests/ImagingTests.cs | 11 ----------- 3 files changed, 25 insertions(+), 11 deletions(-) create mode 100644 Assets/Tests/Helper.cs create mode 100644 Assets/Tests/Helper.cs.meta diff --git a/Assets/Tests/Helper.cs b/Assets/Tests/Helper.cs new file mode 100644 index 0000000..8f6620d --- /dev/null +++ b/Assets/Tests/Helper.cs @@ -0,0 +1,22 @@ +using System.IO; +using UnityEngine; + +namespace Raindrop.Tests +{ + public class Helper + { + + //easily write to a file + //filePath = fully-specified file path + public static void WriteToFile(byte[] outbytes, string filePath) + { + //create parent subfolders + var parentDir = Path.GetDirectoryName(filePath); + System.IO.Directory.CreateDirectory(parentDir); + + //write file + System.IO.File.WriteAllBytes(filePath, outbytes); + Debug.Log($"write: {filePath} "); + } + } +} \ No newline at end of file diff --git a/Assets/Tests/Helper.cs.meta b/Assets/Tests/Helper.cs.meta new file mode 100644 index 0000000..8b99876 --- /dev/null +++ b/Assets/Tests/Helper.cs.meta @@ -0,0 +1,3 @@ +fileFormatVersion: 2 +guid: 651250a02e4a4314917e0f38c7b077a8 +timeCreated: 1642607248 \ No newline at end of file diff --git a/Assets/Tests/ImagingTests/ImagingTests.cs b/Assets/Tests/ImagingTests/ImagingTests.cs index 2996ff6..e0853fb 100644 --- a/Assets/Tests/ImagingTests/ImagingTests.cs +++ b/Assets/Tests/ImagingTests/ImagingTests.cs @@ -97,17 +97,6 @@ namespace Raindrop.Tests.ImagingTests } - //filePath = fully-specified file path - private void WriteToFile(byte[] outbytes, string filePath) - { - //create parent subfolders - var parentDir = Path.GetDirectoryName(filePath); - System.IO.Directory.CreateDirectory(parentDir); - - //write file - System.IO.File.WriteAllBytes(filePath, outbytes); - Debug.Log($"write: {filePath} "); - } [Test]