import unittest
import time
from dataclasses import dataclass

@dataclass
class Event:
    """Simplified Event class for testing"""
    event_type: str
    payload: dict
    timestamp: float = None
    
    def __post_init__(self):
        if not self.event_type:
            raise ValueError("Event type cannot be empty")
        if not isinstance(self.payload, dict):
            raise ValueError("Payload must be a dictionary")
        self.timestamp = time.time()

class TestEventCore(unittest.TestCase):
    """Unit tests for core event functionality"""
    
    def test_event_creation(self):
        """Test basic event creation"""
        event = Event("test_type", {"key": "value"})
        self.assertEqual(event.event_type, "test_type")
        self.assertEqual(event.payload["key"], "value")
        self.assertIsNotNone(event.timestamp)
        
    def test_invalid_event_type(self):
        """Test event type validation"""
        with self.assertRaises(ValueError):
            Event("", {"key": "value"})  # Empty type
        with self.assertRaises(ValueError):
            Event(None, {"key": "value"})  # None type
            
    def test_payload_validation(self):
        """Test payload validation"""
        with self.assertRaises(ValueError):
            Event("test", None)  # None payload
        with self.assertRaises(ValueError):
            Event("test", "not_a_dict")  # Non-dict payload
            
    def test_large_payload(self):
        """Test handling of large payloads"""
        large_payload = {"data": "x" * 10000}  # 10KB payload
        event = Event("large_payload", large_payload)
        self.assertEqual(len(event.payload["data"]), 10000)

if __name__ == "__main__":
    unittest.main()