using Elfisa.Core;
using Xunit;

namespace Elfisa.Tests;

public class DraftTests
{
    [Fact]
    public void DraftItem_line_sum_multiplies()
    {
        var it = new DraftItem { Price = 10.5m, Qty = 3 };
        Assert.Equal(31.5m, it.LineSum);
    }

    [Fact]
    public void DraftOrder_total_and_count()
    {
        var o = new DraftOrder();
        o.Items.Add(new DraftItem { Price = 10m, Qty = 2 });   // 20
        o.Items.Add(new DraftItem { Price = 5.5m, Qty = 4 });  // 22
        Assert.Equal(42m, o.Total);
        Assert.Equal(2, o.ItemsCount);
    }

    [Fact]
    public void DraftOrder_generates_id()
        => Assert.False(string.IsNullOrWhiteSpace(new DraftOrder().Id));

    [Fact]
    public void Empty_order_totals_zero()
    {
        var o = new DraftOrder();
        Assert.Equal(0m, o.Total);
        Assert.Equal(0, o.ItemsCount);
    }
}
