diff --git a/database/init/create-test-api-db.sql b/database/init/create-test-api-db.sql new file mode 100644 index 0000000..b672276 --- /dev/null +++ b/database/init/create-test-api-db.sql @@ -0,0 +1,30 @@ +-- create-test-api-db.sql +-- Creates test databases for integration tests (idempotent). +-- Run once per environment on TECNICA3 before executing integration tests. +-- +-- SIGCM2_Test_App -> used by SIGCM2.Application.Tests +-- SIGCM2_Test_Api -> used by SIGCM2.Api.Tests +-- SIGCM2_Test -> legacy (kept for old branches e.g. pre-merge CAT-001) +-- +-- After creating the DBs, apply V010 to both new DBs: +-- See database/README.md > "Test DBs" section for the PowerShell runbook. + +IF DB_ID(N'SIGCM2_Test_App') IS NULL +BEGIN + CREATE DATABASE [SIGCM2_Test_App] + COLLATE Modern_Spanish_CI_AS; + PRINT 'Database SIGCM2_Test_App created.'; +END +ELSE + PRINT 'Database SIGCM2_Test_App already exists -- skip.'; +GO + +IF DB_ID(N'SIGCM2_Test_Api') IS NULL +BEGIN + CREATE DATABASE [SIGCM2_Test_Api] + COLLATE Modern_Spanish_CI_AS; + PRINT 'Database SIGCM2_Test_Api created.'; +END +ELSE + PRINT 'Database SIGCM2_Test_Api already exists -- skip.'; +GO diff --git a/tests/SIGCM2.TestSupport/TestConnectionStrings.cs b/tests/SIGCM2.TestSupport/TestConnectionStrings.cs new file mode 100644 index 0000000..bf251ea --- /dev/null +++ b/tests/SIGCM2.TestSupport/TestConnectionStrings.cs @@ -0,0 +1,20 @@ +using System.Runtime.CompilerServices; + +[assembly: InternalsVisibleTo("SIGCM2.Api.Tests")] + +namespace SIGCM2.TestSupport; + +/// +/// Centralized connection string constants for integration test databases. +/// Single source of truth — change server/credentials here only. +/// +public static class TestConnectionStrings +{ + /// Used by SIGCM2.Application.Tests via SqlTestFixture (parameterless ctor). + public const string AppTestDb = + "Server=TECNICA3;Database=SIGCM2_Test_App;User Id=desarrollo;Password=desarrollo2026;TrustServerCertificate=True;"; + + /// Used by SIGCM2.Api.Tests via TestWebAppFactory. + public const string ApiTestDb = + "Server=TECNICA3;Database=SIGCM2_Test_Api;User Id=desarrollo;Password=desarrollo2026;TrustServerCertificate=True;"; +}