Files
2026-09-17 18:54:53 +01:00

34 lines
978 B
C#

using Domain;
namespace TestData;
/// <summary>Test data builder for an <see cref="Order"/> (TestDataBuilder pattern); the only place tests touch an order's construction, so tests survive domain evolution.</summary>
public sealed class OrderBuilder
{
private readonly Order _order = new();
/// <summary>A valid, fresh order — the neutral starting point for tests.</summary>
public static OrderBuilder ValidOrder() => new();
public OrderBuilder WithId(Guid id)
{
_order.Id = id;
return this;
}
public OrderBuilder WithDescription(string description)
{
_order.Description = description;
return this;
}
/// <summary>Sets the total in cents (<c>150_00</c> = €150.00), wrapped in <see cref="OrderMoney"/>.</summary>
public OrderBuilder WithTotal(int totalInCents)
{
_order.TotalInCents = OrderMoney.From(totalInCents);
return this;
}
public Order Build() => _order;
}