- WHY: align catalog contracts with protocol-agnostic integration boundaries - WHAT: add contract conventions, grpc adapter surfaces, and blueprint descriptor consumption - RULE: enforce building-block to blueprint dependency direction
58 lines
2.3 KiB
C#
58 lines
2.3 KiB
C#
using BuildingBlock.Catalog.Contracts.Conventions;
|
|
using BuildingBlock.Catalog.Contracts.Products;
|
|
using BuildingBlock.Catalog.Contracts.Responses;
|
|
using BuildingBlock.Catalog.Contracts.Tags;
|
|
using Core.Blueprint.Common.Contracts;
|
|
|
|
namespace BuildingBlock.Catalog.Contracts.UnitTests;
|
|
|
|
public class ContractShapeTests
|
|
{
|
|
[Fact]
|
|
public void ProductContract_WhenCreated_StoresTransportNeutralValues()
|
|
{
|
|
var envelope = new CatalogContractEnvelope("1.0.0", "corr-123");
|
|
var contract = new ProductContract(envelope, "PRD-001", "Chair");
|
|
|
|
Assert.Equal("1.0.0", contract.Envelope.ContractVersion);
|
|
Assert.Equal("corr-123", contract.Envelope.CorrelationId);
|
|
Assert.Equal("PRD-001", contract.ProductId);
|
|
Assert.Equal("Chair", contract.DisplayName);
|
|
}
|
|
|
|
[Fact]
|
|
public void TagOverrideContract_WhenCreated_StoresTransportNeutralValues()
|
|
{
|
|
var envelope = new CatalogContractEnvelope("1.0.0", "corr-123");
|
|
var contract = new TagOverrideContract(envelope, "TAG-001", "furniture", "featured");
|
|
|
|
Assert.Equal("1.0.0", contract.Envelope.ContractVersion);
|
|
Assert.Equal("corr-123", contract.Envelope.CorrelationId);
|
|
Assert.Equal("TAG-001", contract.TagId);
|
|
Assert.Equal("furniture", contract.TargetScope);
|
|
Assert.Equal("featured", contract.OverrideValue);
|
|
}
|
|
|
|
[Fact]
|
|
public void CatalogPackageContract_WhenCreated_UsesBlueprintDescriptorContract()
|
|
{
|
|
IBlueprintPackageContract contract = new CatalogPackageContract();
|
|
|
|
Assert.Equal("BuildingBlock.Catalog.Contracts", contract.Descriptor.PackageId);
|
|
Assert.Equal(PackageVersionPolicy.Minor, contract.Descriptor.VersionPolicy);
|
|
Assert.Contains("Core.Blueprint.Common", contract.Descriptor.DependencyPackageIds);
|
|
}
|
|
|
|
[Fact]
|
|
public void ProductContractResponse_WhenCreated_StoresTransportNeutralValues()
|
|
{
|
|
var envelope = new CatalogContractEnvelope("1.0.0", "corr-456");
|
|
var response = new ProductContractResponse(envelope, "PRD-001", "Chair");
|
|
|
|
Assert.Equal("1.0.0", response.Envelope.ContractVersion);
|
|
Assert.Equal("corr-456", response.Envelope.CorrelationId);
|
|
Assert.Equal("PRD-001", response.ProductId);
|
|
Assert.Equal("Chair", response.DisplayName);
|
|
}
|
|
}
|