<?php

declare(strict_types=1);

namespace App\Tests\Unit\Scolarite\Domain\Model\Evaluation;

use App\Scolarite\Domain\Exception\CoefficientInvalideException;
use App\Scolarite\Domain\Model\Evaluation\Coefficient;
use PHPUnit\Framework\Attributes\Test;
use PHPUnit\Framework\TestCase;

final class CoefficientTest extends TestCase
{
    #[Test]
    public function acceptsValidValues(): void
    {
        self::assertSame(0.1, (new Coefficient(0.1))->value);
        self::assertSame(0.5, (new Coefficient(0.5))->value);
        self::assertSame(1.0, (new Coefficient(1.0))->value);
        self::assertSame(1.5, (new Coefficient(1.5))->value);
        self::assertSame(2.0, (new Coefficient(2.0))->value);
        self::assertSame(10.0, (new Coefficient(10.0))->value);
    }

    #[Test]
    public function rejectsTooSmall(): void
    {
        $this->expectException(CoefficientInvalideException::class);

        new Coefficient(0.0);
    }

    #[Test]
    public function rejectsTooLarge(): void
    {
        $this->expectException(CoefficientInvalideException::class);

        new Coefficient(10.1);
    }

    #[Test]
    public function rejectsNegative(): void
    {
        $this->expectException(CoefficientInvalideException::class);

        new Coefficient(-1.0);
    }

    #[Test]
    public function equalsComparesValue(): void
    {
        $a = new Coefficient(1.5);
        $b = new Coefficient(1.5);
        $c = new Coefficient(2.0);

        self::assertTrue($a->equals($b));
        self::assertFalse($a->equals($c));
    }
}
