- WHY: align inventory capability 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
43 lines
1.6 KiB
C#
43 lines
1.6 KiB
C#
using BuildingBlock.Inventory.Contracts.Conventions;
|
|
using BuildingBlock.Inventory.Contracts.Requests;
|
|
using BuildingBlock.Inventory.Contracts.Responses;
|
|
using Core.Blueprint.Common.Contracts;
|
|
|
|
namespace BuildingBlock.Inventory.Contracts.UnitTests;
|
|
|
|
public class ContractShapeTests
|
|
{
|
|
[Fact]
|
|
public void InventoryItemLookupRequest_WhenCreated_StoresTransportNeutralData()
|
|
{
|
|
var envelope = new InventoryContractEnvelope("1.0.0", "corr-123");
|
|
var request = new InventoryItemLookupRequest(envelope, "SKU-001");
|
|
|
|
Assert.Equal("1.0.0", request.Envelope.ContractVersion);
|
|
Assert.Equal("corr-123", request.Envelope.CorrelationId);
|
|
Assert.Equal("SKU-001", request.ItemCode);
|
|
}
|
|
|
|
[Fact]
|
|
public void InventoryItemLookupResponse_WhenCreated_StoresTransportNeutralData()
|
|
{
|
|
var envelope = new InventoryContractEnvelope("1.0.0", "corr-123");
|
|
var response = new InventoryItemLookupResponse(envelope, "SKU-001", 5);
|
|
|
|
Assert.Equal("1.0.0", response.Envelope.ContractVersion);
|
|
Assert.Equal("corr-123", response.Envelope.CorrelationId);
|
|
Assert.Equal("SKU-001", response.ItemCode);
|
|
Assert.Equal(5, response.QuantityAvailable);
|
|
}
|
|
|
|
[Fact]
|
|
public void InventoryPackageContract_WhenCreated_UsesBlueprintDescriptorContract()
|
|
{
|
|
IBlueprintPackageContract contract = new InventoryPackageContract();
|
|
|
|
Assert.Equal("BuildingBlock.Inventory.Contracts", contract.Descriptor.PackageId);
|
|
Assert.Equal(PackageVersionPolicy.Minor, contract.Descriptor.VersionPolicy);
|
|
Assert.Contains("Core.Blueprint.Common", contract.Descriptor.DependencyPackageIds);
|
|
}
|
|
}
|