Add Assembler tests

This commit is contained in:
Yoshi Askharoun
2024-02-03 20:51:54 -06:00
parent d95fcab104
commit cf3419c435
6 changed files with 55 additions and 6 deletions
+6 -5
View File
@@ -5,23 +5,24 @@ namespace UIX.Test.Helpers;
internal class TempFile : IDisposable, IAsyncInit
{
private const string _defaultFileExtension = ".tmp";
private readonly Func<Task> _init;
public TempFile(System.Resources.ResourceManager resourceManager, string resourceName)
: this((byte[])resourceManager.GetObject(resourceName)!)
public TempFile(System.Resources.ResourceManager resourceManager, string resourceName, string fileExtension = _defaultFileExtension)
: this((byte[])resourceManager.GetObject(resourceName)!, fileExtension)
{
}
public TempFile(string resourceName) : this(TestResources.ResourceManager, resourceName)
public TempFile(string resourceName, string fileExtension = _defaultFileExtension) : this(TestResources.ResourceManager, resourceName, fileExtension)
{
}
public TempFile(byte[] data)
public TempFile(byte[] data, string fileExtension = _defaultFileExtension)
{
_init = async delegate
{
// Copy the test data to a temporary file because Iris can only load from a URI.
Path = System.IO.Path.GetTempFileName();
Path = System.IO.Path.ChangeExtension(System.IO.Path.GetTempFileName(), fileExtension);
await File.WriteAllBytesAsync(Path, data);
};
}