70 lines
2.2 KiB
C#
70 lines
2.2 KiB
C#
using Omika.Core.Compatibility;
|
|
using Omika.Core.Domain.Entities.Clients;
|
|
using Omika.Core.Domain.ValueObjects;
|
|
|
|
namespace Omika.Tests.Domain;
|
|
|
|
/// <summary>
|
|
/// Tests de l'entité métier canonique <see cref="Client"/> : indépendance vis-à
|
|
/// vis du stockage HFSQL et portage des collections sans table de liaison.
|
|
/// </summary>
|
|
public class ClientDomainTests
|
|
{
|
|
[Fact]
|
|
public void Client_DoesNotExposePhysicalColumnNames()
|
|
{
|
|
var client = new Client();
|
|
|
|
string[] forbidden = ["CL_PKID", "CL_IDType", "CL_CleType", "CL_IDStatut", "CL_CleStatut"];
|
|
|
|
foreach (var property in client.GetType().GetProperties())
|
|
{
|
|
Assert.DoesNotContain(forbidden, f => property.Name.Contains(f, StringComparison.Ordinal));
|
|
}
|
|
}
|
|
|
|
[Fact]
|
|
public void Client_CanCarryTypeStatutAndFormeJuridiqueAsReferenceValues()
|
|
{
|
|
var client = new Client
|
|
{
|
|
Nom = "Ville de Lyon",
|
|
Type = new ReferenceValue("Collectivité") { Key = "COLLECTIVITE" },
|
|
Statut = new ReferenceValue("Actif") { LegacyId = 5 },
|
|
FormeJuridique = new ReferenceValue("Commune")
|
|
};
|
|
|
|
Assert.Equal("Collectivité", client.Type!.Label);
|
|
Assert.Equal("Actif", client.Statut!.Label);
|
|
Assert.Equal("Commune", client.FormeJuridique!.Label);
|
|
}
|
|
|
|
[Fact]
|
|
public void Client_CanCarrySourceReferenceWithoutHfSqlName()
|
|
{
|
|
var client = new Client
|
|
{
|
|
SourceReference = LegacyEntityReference.FromLegacyId(12_345)
|
|
};
|
|
|
|
Assert.Equal(DatabaseSchemaVersion.Batik, client.SourceReference!.Source);
|
|
Assert.Equal(12_345, client.SourceReference.NumericId);
|
|
}
|
|
|
|
[Fact]
|
|
public void Client_CollectionsAreControlledByAddMethods()
|
|
{
|
|
var client = new Client();
|
|
|
|
client.AddAdresse(new Adresse { Etiquette = "Mairie" });
|
|
client.AddContact(new Contact { Nom = "Dupont" });
|
|
client.AddSite(new Site { Nom = "Hôtel de ville" });
|
|
client.AddReferenceExterne(new ExternalReference("Batigest", ExternalId: "X-1"));
|
|
|
|
Assert.Single(client.Adresses);
|
|
Assert.Single(client.Contacts);
|
|
Assert.Single(client.Sites);
|
|
Assert.Single(client.ReferencesExternes);
|
|
}
|
|
}
|