@@ -18,6 +18,21 @@ public class DockerComposeCollection : ICollectionFixture<DockerComposeFixture>
1818[ Collection ( "DockerComposeCollection" ) ]
1919public class IntegrationTests
2020{
21+ private readonly string _azuriteAccountKey = Environment . GetEnvironmentVariable ( "AZURITE_ACCOUNT_KEY" )
22+ ?? throw new InvalidOperationException ( $ "Environment variable 'AZURITE_ACCOUNT_KEY' is not set.") ;
23+ private readonly string _azuriteAccountName = Environment . GetEnvironmentVariable ( "AZURITE_ACCOUNT_NAME" )
24+ ?? throw new InvalidOperationException ( $ "Environment variable 'AZURITE_ACCOUNT_NAME' is not set.") ;
25+ private readonly string _azuriteBlobPort = Environment . GetEnvironmentVariable ( "AZURITE_BLOB_PORT" )
26+ ?? throw new InvalidOperationException ( $ "Environment variable 'AZURITE_BLOB_PORT' is not set.") ;
27+ private readonly string _meshIngestPort = Environment . GetEnvironmentVariable ( "MESH_INGEST_PORT" )
28+ ?? throw new InvalidOperationException ( $ "Environment variable 'MESH_INGEST_PORT' is not set.") ;
29+ private readonly string _meshSandboxPort = Environment . GetEnvironmentVariable ( "MESH_SANDBOX_PORT" )
30+ ?? throw new InvalidOperationException ( $ "Environment variable 'MESH_SANDBOX_PORT' is not set.") ;
31+ private readonly string _blobContainerName = Environment . GetEnvironmentVariable ( "BLOB_CONTAINER_NAME" )
32+ ?? throw new InvalidOperationException ( $ "Environment variable 'BLOB_CONTAINER_NAME' is not set.") ;
33+ private readonly string _databaseConnectionString = Environment . GetEnvironmentVariable ( "DATABASE_CONNECTION_STRING" )
34+ ?? throw new InvalidOperationException ( $ "Environment variable 'DATABASE_CONNECTION_STRING' is not set.") ;
35+
2136 [ Fact ]
2237 public async Task FileSentToMeshInbox_FileIsUploadedToBlobContainerAndInsertedIntoDb ( )
2338 {
@@ -36,13 +51,13 @@ public async Task FileSentToMeshInbox_FileIsUploadedToBlobContainerAndInsertedIn
3651 Assert . True ( await WasFileInsertedIntoDatabase ( fileId ) ) ;
3752 }
3853
39- private static async Task WaitForHealthyService ( )
54+ private async Task WaitForHealthyService ( )
4055 {
4156 int attemptCounter = 0 ;
4257
4358 while ( attemptCounter < 10 )
4459 {
45- var response = await HttpHelper . SendHttpRequestAsync ( HttpMethod . Get , "http://localhost:7072 /api/health" ) ;
60+ var response = await HttpHelper . SendHttpRequestAsync ( HttpMethod . Get , $ "http://localhost:{ _meshIngestPort } /api/health") ;
4661
4762 if ( response . IsSuccessStatusCode )
4863 {
@@ -59,15 +74,15 @@ private static async Task WaitForHealthyService()
5974 throw new TimeoutException ( "Timed out waiting on Mesh Ingest Service health check" ) ;
6075 }
6176
62- private static async Task < string ? > SendFileToMeshInbox ( string fileName )
77+ private async Task < string ? > SendFileToMeshInbox ( string fileName )
6378 {
6479 byte [ ] binaryData = await File . ReadAllBytesAsync ( $ "TestData/{ fileName } ") ;
6580 var content = new ByteArrayContent ( binaryData ) ;
6681 content . Headers . ContentType = new MediaTypeHeaderValue ( "application/octet-stream" ) ;
6782
6883 var response = await HttpHelper . SendHttpRequestAsync (
6984 HttpMethod . Post ,
70- "http://localhost:8700 /messageexchange/X26ABC1/outbox" ,
85+ $ "http://localhost:{ _meshSandboxPort } /messageexchange/X26ABC1/outbox",
7186 content ,
7287 headers =>
7388 {
@@ -86,11 +101,11 @@ private static async Task WaitForHealthyService()
86101 return responseObject ? . MessageID ;
87102 }
88103
89- private static async Task < bool > WasFileUploadedToBlobContainer ( string fileId )
104+ private async Task < bool > WasFileUploadedToBlobContainer ( string fileId )
90105 {
91- var blobConnectionString = "DefaultEndpointsProtocol=http;AccountName=devstoreaccount1 ;AccountKey=Eby8vdM02xNOcqFlqUwJPLlmEtlCDXJ1OUzFT50uSRZ6IFsuFq2UVErCz4I6tq/K1SZFPTOtr/KBHBeksoGMGw== ;BlobEndpoint=http://127.0.0.1:10000/devstoreaccount1 " ;
106+ var blobConnectionString = $ "DefaultEndpointsProtocol=http;AccountName={ _azuriteAccountName } ;AccountKey={ _azuriteAccountKey } ;BlobEndpoint=http://localhost: { _azuriteBlobPort } / { _azuriteAccountName } ";
92107
93- var containerClient = new BlobContainerClient ( blobConnectionString , "incoming-mesh-files" ) ;
108+ var containerClient = new BlobContainerClient ( blobConnectionString , _blobContainerName ) ;
94109
95110 try
96111 {
@@ -106,11 +121,10 @@ private static async Task<bool> WasFileUploadedToBlobContainer(string fileId)
106121 }
107122 }
108123
109- private static async Task < bool > WasFileInsertedIntoDatabase ( string fileId )
124+ private async Task < bool > WasFileInsertedIntoDatabase ( string fileId )
110125 {
111- var connectionString = "Server=localhost;Database=ServiceLayer;User Id=SA;Password=YourStrong@Passw0rd;TrustServerCertificate=True" ;
112126 var options = new DbContextOptionsBuilder < ServiceLayerDbContext > ( )
113- . UseSqlServer ( connectionString )
127+ . UseSqlServer ( _databaseConnectionString )
114128 . Options ;
115129
116130 var context = new ServiceLayerDbContext ( options ) ;
0 commit comments