1
0
mirror of https://github.com/bitwarden/server.git synced 2024-11-21 12:05:42 +01:00
bitwarden-server/test/Billing.Test/Utilities/EmbeddedResourceReader.cs

Ignoring revisions in .git-blame-ignore-revs. Click here to bypass and see the normal blame view.

23 lines
648 B
C#
Raw Permalink Normal View History

using System.Reflection;
namespace Bit.Billing.Test.Utilities;
public static class EmbeddedResourceReader
{
public static async Task<string> ReadAsync(string resourceType, string fileName)
{
var assembly = Assembly.GetExecutingAssembly();
await using var stream = assembly.GetManifestResourceStream($"Bit.Billing.Test.Resources.{resourceType}.{fileName}");
if (stream == null)
{
throw new Exception($"Failed to retrieve manifest resource stream for file: {fileName}.");
}
using var reader = new StreamReader(stream);
return await reader.ReadToEndAsync();
}
}