Ejemplo n.º 1
0
    def test_AnchorSearch_FindingWordsWithScript_ReturnsCorrectWords(self):

        # Arrange
        words = Words()
        selectedKeys = []
        s = Tile('S', 1, 0.09480520300163461, 3)
        c = Tile('C', 3, 0.04049934678472928, 29)
        r = Tile('R', 1, 0.07098146383333229, 11)
        i = Tile('I', 1, 0.0885545324304026, 5)
        p = Tile('P', 3, 0.029410465329100584, 41)
        t = Tile('T', 1, 0.06566549066880407, 17)
        word = Word([s, c, r, i, p, t])
        allWordsContainWord = True
        noWordsContainWord = True

        # Act
        selectedWords = words.AnchorSearch(word)
        for key in selectedWords.GetDict():
            selectedKeys.append(key)
            for element in selectedWords.GetDict().get(key):
                if word.GetString() not in element:
                    allWordsContainWord = False
        for key in words.GetDict():
            if key not in selectedKeys:
                for element in words.GetDict().get(key):
                    if word.GetString() in element:
                        noWordsContainWord = False
                        print(element, "contains the word", word.GetString())

        # Assert
        self.assertTrue(allWordsContainWord)
        self.assertTrue(noWordsContainWord)
Ejemplo n.º 2
0
    def test_Constructor_CallWithDefaultParameters_WordSetCorrectly(self):

        # Arrange
        expectedTiles = None
        expectedString = ''
        expectedScore = 0
        expectedPrime = 1

        # Act
        testWord = Word()
        actualTiles = testWord.GetTiles()
        actualString = testWord.GetString()
        actualScore = testWord.GetScore()
        actualPrime = testWord.GetPrime()

        # Assert
        self.assertEqual(expectedTiles, actualTiles)
        self.assertEqual(expectedString, actualString)
        self.assertEqual(expectedScore, actualScore)
        self.assertEqual(expectedPrime, actualPrime)
Ejemplo n.º 3
0
    def test_Constructor_CallWithTiles_WordSetCorrectly(self):

        # Arrange
        c = Tile('C', 3, 0.04049934678472928, 29)
        a = Tile('A', 1, 0.07633656680151722, 7)
        t = Tile('T', 1, 0.06566549066880407, 17)
        expectedTiles = [c, a, t]
        expectedString = 'CAT'
        expectedScore = 5
        expectedPrime = 29 * 7 * 17

        # Act
        testWord = Word(expectedTiles)
        actualTiles = testWord.GetTiles()
        actualString = testWord.GetString()
        actualScore = testWord.GetScore()
        actualPrime = testWord.GetPrime()

        # Assert
        self.assertEqual(expectedTiles, actualTiles)
        self.assertEqual(expectedString, actualString)
        self.assertEqual(expectedScore, actualScore)
        self.assertEqual(expectedPrime, actualPrime)