<?php

namespace Tests\Unit;

use App\Services\Bot\RegimeDetector;
use App\Services\MarketData\GreeksCalculator;
use Tests\TestCase;

class BotServicesTest extends TestCase
{
    public function test_regime_detector_trending_up(): void
    {
        $detector = new RegimeDetector;
        $this->assertSame('TRENDING_UP', $detector->detect(24500, 24400, 24480, 24400));
    }

    public function test_regime_detector_trending_down(): void
    {
        $detector = new RegimeDetector;
        $this->assertSame('TRENDING_DOWN', $detector->detect(24400, 24500, 24400, 24500));
    }

    public function test_greeks_calculator_returns_values(): void
    {
        $calc = new GreeksCalculator(0.065);
        $result = $calc->calculate(24500, 24500, 150, 7 / 365, 'CE');

        $this->assertArrayHasKey('delta', $result);
        $this->assertArrayHasKey('gamma', $result);
        $this->assertGreaterThan(0, $result['delta']);
    }

    public function test_flattrade_mock_client_returns_quotes(): void
    {
        $this->app['config']->set('flattrade.mock', true);
        $client = new \App\Services\FlatTrade\FlatTradeClient;
        $client->setSession('TEST', 'TEST', 'token');
        $quote = $client->getQuotes('NSE', '26000');

        $this->assertSame('Ok', $quote['stat']);
        $this->assertArrayHasKey('lp', $quote);
    }
}
