[ next ] [ prev ] [ contents ] [ skip to Code for Story Three ] XP-Cinti TDD Workshop

More Tests for Story Three

We tested score on a simple configuration. Lets try it in a few more board configurations. To do this, the configure_score method needs to be more flexible. We enhance it by passing in the x/y coordinate pair and the player token to use.

# file: testnet.rb
...
  def test_score_simple_board
    configure_score_at(2, 2, :BLACK)
    assert_equal 1, @net.score(:BLACK)
  end

  def configure_score_at(x, y, player)
    @net[x-1,y] = player
    @net[x+1,y] = player
    @net[x,y-1] = player
    @net[x,y+1] = player
  end
...

  
And the tests pass.


[ next ] [ prev ] [ contents ] [ skip to Code for Story Three ] Copyright 2003 by Jim Weirich.
Some Rights Reserved