Sha256: 09d9854ef724d35c1db98d2328d9f66a35a0247b8d020d363e3957cb22579485

Contents?: true

Size: 1.47 KB

Versions: 10

Compression:

Stored size: 1.47 KB

Contents

require File.dirname(__FILE__) + '/../test_helper'
require 'test/unit'
require 'test/unit/testcase'


class QueryResultTestCase < Test::Unit::TestCase
  

  def setup
    @api = RallyRestAPI.new
  end

  def make_result(total, page_size, start_index)
    xml = %Q(<QueryResult><TotalResultCount>#{total}</TotalResultCount><PageSize>#{page_size}</PageSize><StartIndex>#{start_index}</StartIndex><Results>)
    page_size.times { |i| xml << %Q(<RefElement ref="http" refObjectName="name#{i}"/>) }
    xml << %Q(</Results></QueryResult>)
    xml
  end
  
  def test_basic_numbers
    result_xml = make_result(20, 20, 1)
    result = QueryResult.new(nil, @api, result_xml)
    assert_equal(20, result.total_result_count)
    assert_equal(20, result.page_size)
    assert_equal(1, result.start_index)
    assert_equal(20, result.page_length)
  end

  def test_more_pages_when_enpty
    query_result_xml = make_result(0, 0, 0)
    result = QueryResult.new(nil, @api, query_result_xml)
    assert(! result.more_pages?, "No more pages when results empty")
  end

  def test_more_pages_when_no_pages
    query_result_xml = make_result(20, 20, 1)
    result = QueryResult.new(nil, @api, query_result_xml)
    assert(! result.more_pages?, "No more pages when total == page size")
  end

  def test_more_pages_when_more_pages
    query_result_xml = make_result(21, 20, 1)
    result = QueryResult.new(nil, @api, query_result_xml)
    assert(result.more_pages?, "Should have more pages when total != page size")
  end

end

Version data entries

10 entries across 10 versions & 1 rubygems

Version Path
rally_rest_api-1.1.0 spec/rally_rest_api/tc_query_result.rb
rally_rest_api-1.0.6 spec/rally_rest_api/tc_query_result.rb
rally_rest_api-1.0.5 spec/rally_rest_api/tc_query_result.rb
rally_rest_api-1.0.4 spec/rally_rest_api/tc_query_result.rb
rally_rest_api-1.0.3 spec/rally_rest_api/tc_query_result.rb
rally_rest_api-1.0.2 spec/rally_rest_api/tc_query_result.rb
rally_rest_api-1.0.1 spec/rally_rest_api/tc_query_result.rb
rally_rest_api-0.9.0 spec/rally_rest_api/tc_query_result.rb
rally_rest_api-1.0.0 spec/rally_rest_api/tc_query_result.rb
rally_rest_api-0.8.0 spec/rally_rest_api/tc_query_result.rb