Exemplo n.º 1
0
class testFizzBuzz(unittest.TestCase):

    def setUp(self):
        self.fizzbuzz = FizzBuzz()

    def test_one_should_return_one(self):
        self.fizzbuzz.set_num(1)
        expected = '1'
        actual = self.fizzbuzz.get()
        self.assertEqual(expected, actual)

    def test_two_should_return_two(self):
        self.fizzbuzz.set_num(2)
        expected = '2'
        actual = self.fizzbuzz.get()
        self.assertEqual(expected, actual)

    def test_three_should_return_fizz(self):
        self.fizzbuzz.set_num(3)
        expected = 'fizz'
        actual = self.fizzbuzz.get()
        self.assertEqual(expected, actual)

    def test_five_should_return_buzz(self):
        self.fizzbuzz.set_num(5)
        expected = 'buzz'
        actual = self.fizzbuzz.get()
        self.assertEqual(expected, actual)

    def test_fifteen_should_return_fizzbuzz(self):
        self.fizzbuzz.set_num(15)
        expected = 'fizzbuzz'
        actual = self.fizzbuzz.get()
        self.assertEqual(expected, actual)
class TestFizzBuzz(unittest.TestCase):

    def setUp(self):
        self.fizzbuzz = FizzBuzz()
 
    def test_number_three_is_fizz(self):
        self.assertEquals(self.fizzbuzz.get(1), 1, 'Number 1 is 1')
        self.assertEquals(self.fizzbuzz.get(3), 'fizz', 'Number 3 is "fizz"')
        self.assertEquals(self.fizzbuzz.get(33), 'fizz', 'Number 33 is "fizz"')

    def test_number_five_is_buzz(self):
        self.assertEquals(self.fizzbuzz.get(5), 'buzz', 'Number 5 is "buzz"')
        self.assertEquals(self.fizzbuzz.get(20), 'buzz', 'Number 20 is "buzz"')

    def test_number_three_and_five_is_fizzbuzz(self):
        self.assertEquals(self.fizzbuzz.get(15), 'fizzbuzz', 'Number 15 is "fizzbuzz"')
        self.assertEquals(self.fizzbuzz.get(30), 'fizzbuzz', 'Number 20 is "fizzbuzz"')