Files
jdescopingtool/NEW/tests/JdeScoping.Database.Tests/Procedures/StoredProcedureExistsTests.cs
T
Joseph Doherty e5fe2f06e9 feat: add startup config validation and document ConfigManager pipeline editor
Add ConfigurationValidationRunner with IConfigurationValidator interface for
validating required settings at startup. Includes SecureStore and LDAP validators.
Expand ConfigManager with pipeline editing UI, dialogs, and step editors.
Update documentation with config validation guidance.
2026-01-21 17:47:15 -05:00

94 lines
3.2 KiB
C#

using Dapper;
using FluentAssertions;
using JdeScoping.Database.Tests.Infrastructure;
namespace JdeScoping.Database.Tests.Procedures;
/// <summary>
/// Tests to verify that all required stored procedures exist in the database.
/// These tests ensure the migration scripts properly create all expected procedures.
/// </summary>
[Collection("DatabaseTests")]
public class StoredProcedureExistsTests : DatabaseTestBase
{
/// <summary>
/// Verifies that a stored procedure exists in the database.
/// </summary>
private async Task<bool> ProcedureExistsAsync(string procedureName)
{
var result = await Connection.QuerySingleOrDefaultAsync<int>(
@"SELECT COUNT(*)
FROM sys.procedures
WHERE name = @Name AND schema_id = SCHEMA_ID('dbo')",
new { Name = procedureName });
return result > 0;
}
[Fact]
public async Task usp_SubmitSearch_Exists()
{
var exists = await ProcedureExistsAsync("usp_SubmitSearch");
exists.Should().BeTrue("usp_SubmitSearch should be created by migration 040");
}
[Fact]
public async Task usp_StartSearch_Exists()
{
var exists = await ProcedureExistsAsync("usp_StartSearch");
exists.Should().BeTrue("usp_StartSearch should be created by migration 041");
}
[Fact]
public async Task usp_CompleteSearch_Exists()
{
var exists = await ProcedureExistsAsync("usp_CompleteSearch");
exists.Should().BeTrue("usp_CompleteSearch should be created by migration 042");
}
[Fact]
public async Task usp_ResetPartialSearches_Exists()
{
var exists = await ProcedureExistsAsync("usp_ResetPartialSearches");
exists.Should().BeTrue("usp_ResetPartialSearches should be created by migration 043");
}
[Fact]
public async Task usp_ValidateSearchCriteria_Exists()
{
var exists = await ProcedureExistsAsync("usp_ValidateSearchCriteria");
exists.Should().BeTrue("usp_ValidateSearchCriteria should be created by migration 048");
}
[Fact]
public async Task usp_ProcessMisStagingData_Exists()
{
var exists = await ProcedureExistsAsync("usp_ProcessMisStagingData");
exists.Should().BeTrue("usp_ProcessMisStagingData should be created by migration 049");
}
[Fact]
public async Task AllStoredProcedures_HaveExpectedCount()
{
// This test ensures we haven't accidentally dropped any procedures
var expectedProcedures = new[]
{
"usp_SubmitSearch",
"usp_StartSearch",
"usp_CompleteSearch",
"usp_ResetPartialSearches",
"usp_ValidateSearchCriteria",
"usp_ProcessMisStagingData"
};
var actualCount = await Connection.QuerySingleAsync<int>(
@"SELECT COUNT(*)
FROM sys.procedures
WHERE schema_id = SCHEMA_ID('dbo')
AND name LIKE 'usp_%'");
actualCount.Should().BeGreaterThanOrEqualTo(
expectedProcedures.Length,
$"Database should have at least {expectedProcedures.Length} stored procedures");
}
}