#This file was originally generated by PyScripter's unitest wizard

import unittest
from coord import Coord
from cell import Cell
from field import Field

def dummy():
    """ Dummy function for comparison of the return values """
    return

class CoordTest(unittest.TestCase):

    def setUp(self):
        self.field = Field()
        pass

    def tearDown(self):
        pass

    def testMain(self):
        self.coord = Coord()
        assert self.coord.main() == dummy(), 'Gol01.get_size() does not provide the right return value'

    def testCoordSavesItsCoordinates(self):
        coord = Coord(4,5)
        assert 4 == coord.x
        assert 5 == coord.y

    def testCreatedCellIsAlive(self):
        coord1 = Coord(4,5)
        cell = Cell(coord1)
        assert cell.isAlive() == True, 'cell.status() does not provide the right return value'

    def testCellKnowsIfItLivesInTheNextStep(self):
        cell = Cell(Coord(4,5))
        cell.nextStep(5)
        assert False == cell.isAlive()

    def addCell(self,x,y):
        self.field.add(Cell(Coord(x, y)))

    def fillExampleField(self):
        self.addCell(1,1)
        self.addCell(1,2)
        self.addCell(2,1)

    def testFieldIsWellCreated(self):
        self.fillExampleField()
        assert self.field.getNumberOfLivingCells() == 3, 'field.numberOfAliveCells does not provide the right return value'

# run all tests
if __name__ == "__main__":
    try:
        unittest.main()
    except SystemExit as inst:
        if inst.args[0] is True: # raised by sys.exit(True) when tests failed
            raise

