mirror of
https://github.com/BinaryAlley/Nemera.git
synced 2026-12-01 21:01:10 +00:00
44 lines
1.9 KiB
C#
44 lines
1.9 KiB
C#
#region ========================================================================= USING =====================================================================================
|
|
using System;
|
|
using System.Diagnostics.CodeAnalysis;
|
|
using System.IO;
|
|
#endregion
|
|
|
|
namespace Nemera.Presentation.Api.IntegrationTests.Common.Setup;
|
|
|
|
/// <summary>
|
|
/// Contains integration tests for the <see cref="PublishedAssemblyResourceReader"/> test helper.
|
|
/// </summary>
|
|
[ExcludeFromCodeCoverage]
|
|
public class PublishedAssemblyResourceReaderTests
|
|
{
|
|
/// <summary>
|
|
/// The resource name of the append-only trust list of previously released bundled plugin binaries.
|
|
/// </summary>
|
|
private const string HISTORICAL_MANIFEST_RESOURCE_NAME = "Nemera.Presentation.Api.BundledPlugins.historical.manifest";
|
|
|
|
[Fact]
|
|
public void ReadEmbeddedResource_WhenReadingTheLoadedAssemblyFile_ShouldMatchTheLoadedResourceStream()
|
|
{
|
|
// Arrange
|
|
// The loaded assembly's file is read directly, which is the same path the published artifact verification uses.
|
|
string assemblyPath = typeof(Program).Assembly.Location;
|
|
byte[] expectedResourceBytes;
|
|
using (Stream resourceStream = typeof(Program).Assembly.GetManifestResourceStream(HISTORICAL_MANIFEST_RESOURCE_NAME)
|
|
?? throw new InvalidOperationException($"The embedded manifest resource '{HISTORICAL_MANIFEST_RESOURCE_NAME}' is missing."))
|
|
{
|
|
using (MemoryStream resourceBuffer = new())
|
|
{
|
|
resourceStream.CopyTo(resourceBuffer);
|
|
expectedResourceBytes = resourceBuffer.ToArray();
|
|
}
|
|
}
|
|
|
|
// Act
|
|
byte[] actualResourceBytes = PublishedAssemblyResourceReader.ReadEmbeddedResource(assemblyPath, HISTORICAL_MANIFEST_RESOURCE_NAME);
|
|
|
|
// Assert
|
|
Assert.Equal(expectedResourceBytes, actualResourceBytes);
|
|
}
|
|
}
|