#region ========================================================================= USING ===================================================================================== using System; using System.Diagnostics.CodeAnalysis; using System.IO; #endregion namespace Nemera.Presentation.Api.IntegrationTests.Common.Setup; /// /// Contains integration tests for the test helper. /// [ExcludeFromCodeCoverage] public class PublishedAssemblyResourceReaderTests { /// /// The resource name of the append-only trust list of previously released bundled plugin binaries. /// 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); } }