from unittest.case import TestCase

''' Integration tests as the Applicatino layer takes care of persisting Domain entities. '''
from tracker.application import ContestService
from tracker.domain import Participant, Fact, ContestFactory
from tracker.infrastructure import ContestRepositoryInMemoryImpl

class TestContestServiceMuurkeKlop(TestCase):
    
    def testCreateContest(self):
        service = ContestService()
        service.contestFactory = ContestFactory()
        service.contestRepository = ContestRepositoryInMemoryImpl()
        
        contest = service.createContest('Muurke Klop')
        print(contest.uuid)
        self.assertNotEqual(None, contest.uuid, 'We expect the Contest to have received a UUID as Entity ID.')
        service.addParticipant(contest, Participant('Player One'))
        service.addParticipant(contest, Participant('Player Two'))
        service.addParticipant(contest, Participant('Player Three'))
        service.addParticipant(contest, Participant('Player Four'))
        service.addParticipant(contest, Participant('Player Five'))
        service.addParticipant(contest, Participant('Player Six'))
        service.addParticipant(contest, Participant('Player Seven'))
        service.addParticipant(contest, Participant('Player Eight'))
        service.addFact(contest, Fact('Points',  1, Participant('Player One')))
        service.addFact(contest, Fact('Points',  2, Participant('Player Seven')))
        service.addFact(contest, Fact('Points',  3, Participant('Player Four')))
        service.addFact(contest, Fact('Points',  4, Participant('Player Eight')))
        service.addFact(contest, Fact('Points',  5, Participant('Player Three')))
        service.addFact(contest, Fact('Points',  6, Participant('Player Five')))
        service.addFact(contest, Fact('Points',  8, Participant('Player Six')))
        service.addFact(contest, Fact('Points', 10, Participant('Player Two')))
        contest = service.findContestByUUID(contest.uuid)
        self.assertNotEqual(None, contest)
        self.assertEqual('Muurke Klop', contest.name)
        # TODO :: make sure also Contest is immutable at this point, no?
        
        