<?php

declare(strict_types=1);

namespace Dalten\RuianToUir\Tests\Unit\Formatter;

use Dalten\RuianToUir\Converter\Field\Point;
use Dalten\RuianToUir\Converter\Result\AddRecord;
use Dalten\RuianToUir\Converter\Result\RemoveRecord;
use Dalten\RuianToUir\Formatter\PlainText;
use PHPUnit\Framework\Attributes\CoversClass;
use PHPUnit\Framework\TestCase;

#[CoversClass(PlainText::class)]
final class PlainTextTest extends TestCase
{
    public function testOutputsAddLineWithGeometryToString(): void
    {
        $formatter = new PlainText();
        $data = [
            'adresa_kod' => 123,
            'psc' => '110 00',
            'geom' => new Point('50.000000 14.000000'),
        ];
        $result = new AddRecord('Address', 123, $data);

        $line = $formatter->format($result);

        $this->assertSame('Address;ADD;adresa_kod=123;psc=110 00;geom=Point(50.000000 14.000000)', $line);
    }

    public function testOutputsDeleteLineWithIdentifier(): void
    {
        $formatter = new PlainText();
        $result = new RemoveRecord('Address', 42);

        $line = $formatter->format($result);

        $this->assertSame('Address;DEL;identifier=42', $line);
    }
}
