package risk

import "testing"

func TestEvaluateBlocksDailyLimit(t *testing.T) {
	rule := &LimitRule{
		DailyLimitCents: 10000,
	}
	got := evaluate(rule, usage{DailyAmountCents: 9000}, 1500)
	if got.Decision != DecisionBlock {
		t.Fatalf("expected block, got %q", got.Decision)
	}
	if got.Reason != "daily_amount_limit_exceeded" {
		t.Fatalf("expected daily limit reason, got %q", got.Reason)
	}
}

func TestEvaluateReviewNearLimit(t *testing.T) {
	rule := &LimitRule{
		SingleTransactionLimitCents: 10000,
	}
	got := evaluate(rule, usage{}, 9000)
	if got.Decision != DecisionReview {
		t.Fatalf("expected review, got %q", got.Decision)
	}
	if got.Reason != "near_limit_threshold" {
		t.Fatalf("expected near-limit reason, got %q", got.Reason)
	}
}

func TestEvaluateAllowsWithoutRule(t *testing.T) {
	got := evaluate(nil, usage{}, 1000)
	if got.Decision != DecisionAllow {
		t.Fatalf("expected allow, got %q", got.Decision)
	}
	if got.Reason != "no_limit_rule" {
		t.Fatalf("expected no-limit reason, got %q", got.Reason)
	}
}
