<?php

namespace App\Service;

use App\Contract\Order;
use App\Contract\ProductEntry;
use PHPUnit\Framework\TestCase;
use Symfony\Component\Uid\Uuid;

class TrivialPricingStrategyTest extends TestCase
{

    public function testCalculatingSingularProductPrice()
    {
        $product = new ProductEntry(productId: 'p1', quantity: 1, price: 2.00, weight: 100);

        $sut = new TrivialPricingStrategy();

        $this->assertEquals(200, $sut->calculateTotalPriceOfProductEntry($product));
    }

    public function testCalculatingMultipleProductPrice()
    {
        $product = new ProductEntry(productId: 'p1', quantity: 5, price: 2.00, weight: 100);

        $sut = new TrivialPricingStrategy();

        $this->assertEquals(1000, $sut->calculateTotalPriceOfProductEntry($product));
    }

    public function testCalculatingOrderPrice()
    {
        $order = new Order(
            orderId: Uuid::v4(),
            clientId: Uuid::v4(),
            products: [
                new ProductEntry(productId: 'p1', quantity: 5, price: 2.00, weight: 100),
                new ProductEntry(productId: 'p2', quantity: 2, price: 1.25, weight: 100),
            ]
        );

        $sut = new TrivialPricingStrategy();

        $this->assertEquals(1250, $sut->calculateTotalPriceOfOrder($order));
    }
}