60 lines
2.4 KiB
C#
60 lines
2.4 KiB
C#
using System.Reflection;
|
|
using Omika.Data.Repositories.Omika;
|
|
|
|
namespace Omika.Tests.Repositories.Omika;
|
|
|
|
/// <summary>
|
|
/// Tests de non-régression sur les requêtes SQL du
|
|
/// <see cref="OmikaRapportChampRepository"/> (constantes privées lues par
|
|
/// réflexion). Ils verrouillent la couverture des colonnes INTER/DOSSIER (alignée
|
|
/// sur le WINDEV Omika <c>saRQ</c>/<c>sARQDossier</c>) et les gardes contre
|
|
/// l'explosion de jointure sur clé métier vide (<c>PA_Cle = ''</c>).
|
|
/// </summary>
|
|
public class OmikaRapportChampSqlContractTests
|
|
{
|
|
[Theory]
|
|
[InlineData("InterventionSql", "IN_Titre")]
|
|
[InlineData("InterventionSql", "IN_RefInterne")]
|
|
[InlineData("InterventionSql", "IN_CreationDate")]
|
|
[InlineData("InterventionSql", "IN_NumDevis")]
|
|
[InlineData("InterventionSql", "IN_DateDevis")]
|
|
[InlineData("InterventionSql", "IN_NumFacture")]
|
|
[InlineData("InterventionSql", "IN_DateFacture")]
|
|
[InlineData("InterventionSql", "IN_RefExterne")]
|
|
[InlineData("InterventionSql", "IN_Description")]
|
|
[InlineData("InterventionSql", "IN_DureePrevue")]
|
|
[InlineData("InterventionSql", "IN_CO_Nom")]
|
|
[InlineData("InterventionSql", "IN_PA_Type")]
|
|
[InlineData("InterventionSql", "LI_CodeLieu")]
|
|
[InlineData("InterventionSql", "LI_Adresse")]
|
|
[InlineData("InterventionSql", "LI_CodeAcces")]
|
|
[InlineData("InterventionSql", "CL_Nom")]
|
|
[InlineData("InterventionSql", "AD_Presentation")]
|
|
[InlineData("InterventionSql", "SO_Nom")]
|
|
public void InterventionSql_ContientColonne(string field, string column)
|
|
=> Assert.True(ReadConst(field).Contains(column, StringComparison.OrdinalIgnoreCase),
|
|
$"{field} doit sélectionner {column}.");
|
|
|
|
[Fact]
|
|
public void DossierSql_ContientStatut()
|
|
=> Assert.True(ReadConst("DossierSql").Contains("DOSSIER_STATUT", StringComparison.OrdinalIgnoreCase));
|
|
|
|
[Theory]
|
|
[InlineData("ContactsSiteSql")]
|
|
[InlineData("ContactsDonneursSql")]
|
|
public void ContactsSql_GardeCleVide(string field)
|
|
=> Assert.Contains("IP_CleRole <> ''", ReadConst(field));
|
|
|
|
[Fact]
|
|
public void PhotosSql_GardeCleVide()
|
|
=> Assert.Contains("DC_CleCategorie <> ''", ReadConst("PhotosSql"));
|
|
|
|
private static string ReadConst(string name)
|
|
{
|
|
FieldInfo? field = typeof(OmikaRapportChampRepository).GetField(
|
|
name, BindingFlags.NonPublic | BindingFlags.Static);
|
|
Assert.NotNull(field);
|
|
return (string)field!.GetValue(null)!;
|
|
}
|
|
}
|