<?php

declare(strict_types=1);

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

use App\Scolarite\Domain\Exception\ValeurNoteInvalideException;
use App\Scolarite\Domain\Model\Grade\GradeValue;
use PHPUnit\Framework\Attributes\Test;
use PHPUnit\Framework\TestCase;

final class GradeValueTest extends TestCase
{
    #[Test]
    public function acceptsZero(): void
    {
        self::assertSame(0.0, (new GradeValue(0))->value);
    }

    #[Test]
    public function acceptsPositiveValue(): void
    {
        self::assertSame(15.5, (new GradeValue(15.5))->value);
    }

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

        new GradeValue(-1);
    }

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

        new GradeValue(-0.5);
    }

    #[Test]
    public function equalsComparesValues(): void
    {
        $a = new GradeValue(15.0);
        $b = new GradeValue(15.0);
        $c = new GradeValue(12.0);

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