1e23616638
Replace FluentAssertions with Shouldly across all 6 test files (94 tests). Add ShouldlyExtensions for BeCloseTo and BeEquivalentTo patterns.
94 lines
3.2 KiB
C#
94 lines
3.2 KiB
C#
using Dapper;
|
|
using JdeScoping.Database.Tests.Infrastructure;
|
|
using Shouldly;
|
|
|
|
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.ShouldBeTrue("usp_SubmitSearch should be created by migration 040");
|
|
}
|
|
|
|
[Fact]
|
|
public async Task usp_StartSearch_Exists()
|
|
{
|
|
var exists = await ProcedureExistsAsync("usp_StartSearch");
|
|
exists.ShouldBeTrue("usp_StartSearch should be created by migration 041");
|
|
}
|
|
|
|
[Fact]
|
|
public async Task usp_CompleteSearch_Exists()
|
|
{
|
|
var exists = await ProcedureExistsAsync("usp_CompleteSearch");
|
|
exists.ShouldBeTrue("usp_CompleteSearch should be created by migration 042");
|
|
}
|
|
|
|
[Fact]
|
|
public async Task usp_ResetPartialSearches_Exists()
|
|
{
|
|
var exists = await ProcedureExistsAsync("usp_ResetPartialSearches");
|
|
exists.ShouldBeTrue("usp_ResetPartialSearches should be created by migration 043");
|
|
}
|
|
|
|
[Fact]
|
|
public async Task usp_ValidateSearchCriteria_Exists()
|
|
{
|
|
var exists = await ProcedureExistsAsync("usp_ValidateSearchCriteria");
|
|
exists.ShouldBeTrue("usp_ValidateSearchCriteria should be created by migration 048");
|
|
}
|
|
|
|
[Fact]
|
|
public async Task usp_ProcessMisStagingData_Exists()
|
|
{
|
|
var exists = await ProcedureExistsAsync("usp_ProcessMisStagingData");
|
|
exists.ShouldBeTrue("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.ShouldBeGreaterThanOrEqualTo(
|
|
expectedProcedures.Length,
|
|
$"Database should have at least {expectedProcedures.Length} stored procedures");
|
|
}
|
|
}
|