# Test script for Outlook MCP Server on Windows
# This script tests the server functionality and provides setup verification

Write-Host "🚀 Outlook MCP Server - Windows COM Edition Test" -ForegroundColor Green
Write-Host "=================================================" -ForegroundColor Green

# Check if we're on Windows
if ($PSVersionTable.PSVersion.Major -lt 5 -or $env:OS -ne "Windows_NT") {
    Write-Host "❌ This server requires Windows OS" -ForegroundColor Red
    exit 1
}

Write-Host "✅ Running on Windows" -ForegroundColor Green

# Check if Python is available
try {
    $pythonVersion = python --version 2>&1
    Write-Host "✅ Python found: $pythonVersion" -ForegroundColor Green
} catch {
    Write-Host "❌ Python not found. Please install Python 3.8+" -ForegroundColor Red
    exit 1
}

# Check if UV is available (optional)
try {
    $uvVersion = uv --version 2>&1
    Write-Host "✅ UV found: $uvVersion" -ForegroundColor Green
    $hasUV = $true
} catch {
    Write-Host "⚠️  UV not found. Using pip instead." -ForegroundColor Yellow
    $hasUV = $false
}

# Check if Outlook is running
$outlookProcess = Get-Process "OUTLOOK" -ErrorAction SilentlyContinue
if ($outlookProcess) {
    Write-Host "✅ Microsoft Outlook is running" -ForegroundColor Green
} else {
    Write-Host "⚠️  Microsoft Outlook is not running" -ForegroundColor Yellow
    Write-Host "   Please start Outlook for full functionality" -ForegroundColor Yellow
}

# Install dependencies
Write-Host "`n🔧 Installing dependencies..." -ForegroundColor Cyan
if ($hasUV) {
    uv sync
} else {
    pip install -e .
}

# Run the test
Write-Host "`n🧪 Running functionality test..." -ForegroundColor Cyan
if ($hasUV) {
    uv run python test_client.py
} else {
    python test_client.py
}

Write-Host "`n📋 Setup Instructions:" -ForegroundColor Cyan
Write-Host "1. Ensure Microsoft Outlook is running" -ForegroundColor White
Write-Host "2. Add the server to Claude Desktop config:" -ForegroundColor White
Write-Host "   Location: %APPDATA%\Claude\claude_desktop_config.json" -ForegroundColor Gray
Write-Host "3. Use the configuration from claude_desktop_config.json" -ForegroundColor White
Write-Host "4. Restart Claude Desktop" -ForegroundColor White

Write-Host "`n🎉 Test complete!" -ForegroundColor Green
