示例#1
0
    def test_Iteration_iterateForwards(self):
        """Iterating forwards advances forwards through the set"""
        fruitlist = ["apple", "banana", "cherry"]
        x = Chooser(fruitlist)

        result = x.getCurrentChoice()
        self.assert_(result == fruitlist[0], "Current choice is first item")
        result = x.getCurrentChoice()
        self.assert_(result == fruitlist[0],
                     "Current choice is still first item")

        x.gotoNext()

        result = x.getCurrentChoice()
        self.assert_(result == fruitlist[1], "Current choice is second item")
        result = x.getCurrentChoice()
        self.assert_(result == fruitlist[1],
                     "Current choice is still second item")

        x.gotoNext()

        result = x.getCurrentChoice()
        self.assert_(result == fruitlist[2], "Current choice is 3rd item")
        result = x.getCurrentChoice()
        self.assert_(result == fruitlist[2],
                     "Current choice is still 3rd item")
示例#2
0
 def test_Iterate_gotoFirst(self):
    fruitlist = ["apple","banana","cherry"]
    x=Chooser(fruitlist)
    
    x.gotoNext()
    x.gotoNext()
    self.assert_(x.getCurrentChoice() == fruitlist[2], "Current choice is correct")
    x.gotoFirst()
    self.assert_(x.getCurrentChoice() == fruitlist[0], "Current choice is correct")
示例#3
0
    def test_Iterate_gotoFirst(self):
        fruitlist = ["apple", "banana", "cherry"]
        x = Chooser(fruitlist)

        x.gotoNext()
        x.gotoNext()
        self.assert_(x.getCurrentChoice() == fruitlist[2],
                     "Current choice is correct")
        x.gotoFirst()
        self.assert_(x.getCurrentChoice() == fruitlist[0],
                     "Current choice is correct")
示例#4
0
   def test_Iteration_iteratePastEnd(self):
      """Advancing past the end of the set still returns the last item"""
      fruitlist = ["apple","banana","cherry"]
      x=Chooser(fruitlist)
      
      x.gotoNext()
      x.gotoNext()
      
      result = x.getCurrentChoice()
      self.assert_(result == fruitlist[2], "Current choice is 3rd item")

      x.gotoNext()
         
      result = x.getCurrentChoice()
      self.assert_(result == fruitlist[2], "Current choice is 3rd item")
示例#5
0
    def test_Iteration_iteratePastEnd(self):
        """Advancing past the end of the set still returns the last item"""
        fruitlist = ["apple", "banana", "cherry"]
        x = Chooser(fruitlist)

        x.gotoNext()
        x.gotoNext()

        result = x.getCurrentChoice()
        self.assert_(result == fruitlist[2], "Current choice is 3rd item")

        x.gotoNext()

        result = x.getCurrentChoice()
        self.assert_(result == fruitlist[2], "Current choice is 3rd item")
示例#6
0
 def test_Iteration_iterateForwards(self):
    """Iterating forwards advances forwards through the set"""
    fruitlist = ["apple","banana","cherry"]
    x=Chooser(fruitlist)
    
    result = x.getCurrentChoice()
    self.assert_(result == fruitlist[0], "Current choice is first item")
    result = x.getCurrentChoice()
    self.assert_(result == fruitlist[0], "Current choice is still first item")
    
    x.gotoNext()
    
    result = x.getCurrentChoice()
    self.assert_(result == fruitlist[1], "Current choice is second item")
    result = x.getCurrentChoice()
    self.assert_(result == fruitlist[1], "Current choice is still second item")
    
    x.gotoNext()
    
    result = x.getCurrentChoice()
    self.assert_(result == fruitlist[2], "Current choice is 3rd item")
    result = x.getCurrentChoice()
    self.assert_(result == fruitlist[2], "Current choice is still 3rd item")
示例#7
0
   def test_Iterate_forwardsBackwardsForwards(self):
      fruitlist = ["apple","banana","cherry"]
      x=Chooser(fruitlist)

      self.assert_(x.getCurrentChoice() == fruitlist[0], "Current choice is correct")
      x.gotoNext()
      self.assert_(x.getCurrentChoice() == fruitlist[1], "Current choice is correct")
      x.gotoNext()
      self.assert_(x.getCurrentChoice() == fruitlist[2], "Current choice is correct")
      x.gotoPrev()
      self.assert_(x.getCurrentChoice() == fruitlist[1], "Current choice is correct")
      x.gotoPrev()
      self.assert_(x.getCurrentChoice() == fruitlist[0], "Current choice is correct")
      x.gotoNext()
      self.assert_(x.getCurrentChoice() == fruitlist[1], "Current choice is correct")
示例#8
0
    def test_Iterate_forwardsBackwardsForwards(self):
        fruitlist = ["apple", "banana", "cherry"]
        x = Chooser(fruitlist)

        self.assert_(x.getCurrentChoice() == fruitlist[0],
                     "Current choice is correct")
        x.gotoNext()
        self.assert_(x.getCurrentChoice() == fruitlist[1],
                     "Current choice is correct")
        x.gotoNext()
        self.assert_(x.getCurrentChoice() == fruitlist[2],
                     "Current choice is correct")
        x.gotoPrev()
        self.assert_(x.getCurrentChoice() == fruitlist[1],
                     "Current choice is correct")
        x.gotoPrev()
        self.assert_(x.getCurrentChoice() == fruitlist[0],
                     "Current choice is correct")
        x.gotoNext()
        self.assert_(x.getCurrentChoice() == fruitlist[1],
                     "Current choice is correct")