コード例 #1
0
 def setUp(self):
     self.television = Television(30, 25)
コード例 #2
0
class TestEx5(unittest.TestCase):

    def setUp(self):
        self.television = Television(30, 25)

    def test_press_power_button(self):
        self.television.status = 'on'
        self.television.press_power_button() |should| equal_to('off')

    def test_set_up_channel_from_23_should_return_24(self):
        self.television.status = 'on'
        self.television.channel = 23
        self.television.set_up_channel() 
        self.television.channel |should| equal_to(24)
        self.television.status = 'off'
        self.television.set_up_channel() 
        self.television.channel |should| equal_to(24)
 
    def test_set_up_channel_from_30_should_return_30(self):
        self.television.channel = 30
        self.television.status = 'on'
        self.television.set_up_channel() 
        self.television.channel |should| equal_to(30)

    def test_set_down_channel_from_30_should_return_29(self):
        self.television.status = 'on'
        self.television.channel = 30
        self.television.set_down_channel() 
        self.television.channel |should| equal_to(29)
        self.television.status = 'off'
        self.television.set_down_channel()
        self.television.channel |should| equal_to(29)

    def test_set_down_channel_from_1_should_return_1(self):
        self.television.status = 'on'
        self.television.channel = 1
        self.television.set_down_channel() 
        self.television.channel |should| equal_to(1)

    def test_set_up_volume_from_14_should_return_15(self):
        self.television.status = 'on'
        self.television.volume = 14
        self.television.set_up_volume() 
        self.television.volume |should| equal_to(15)
        self.television.status = 'off'
        self.television.set_up_volume() 
        self.television.volume |should| equal_to(15)

    def test_set_up_volume_from_25_should_return_25(self):
        self.television.status = 'on'
        self.television.volume = 25
        self.television.set_up_volume()
        self.television.volume |should| equal_to(25)

    def test_set_down_volume_from_12_should_return_11(self):
        self.television.status = 'on'
        self.television.volume = 12
        self.television.set_down_volume() 
        self.television.volume |should| equal_to(11)
        self.television.status = 'off'
        self.television.set_down_volume() 
        self.television.volume |should| equal_to(11)

    def test_set_down_volume_from_0_should_return_0(self):
        self.television.status = 'off' 
        self.television.volume = 0
        self.television.set_down_volume() 
        self.television.volume |should| equal_to(0)