Sha256: 7e006f9461497313673372624e5db5180cb1d47ac0449bf45a0a2d53cc1ed4ba

Contents?: true

Size: 1.9 KB

Versions: 3

Compression:

Stored size: 1.9 KB

Contents

# coding: utf-8

require 'test_helper'

class Thinreports::Core::Shape::List::TestSectionInterface < Minitest::Test
  include Thinreports::TestHelper

  # Alias
  List = Thinreports::Core::Shape::List

  def setup
    @report = new_report 'layout_text1'
  end

  def create_interface(format_config = {})
    parent = @report.start_new_page

    List::SectionInterface.new parent,
                               List::SectionFormat.new(format_config),
                               :section
  end

  def test_internal_should_return_instance_of_SectionInternal
    assert_instance_of List::SectionInternal, create_interface.internal
  end

  def test_initialize_should_properly_set_the_specified_section_name_to_internal
    assert_equal create_interface.internal.section_name, :section
  end

  def test_initialize_should_properly_initialize_manager
    assert_instance_of Thinreports::Core::Shape::Manager::Internal,
                       create_interface.manager
  end

  def test_height_should_operate_as_delegator_of_internal
    list = create_interface('height' => 100)
    assert_same list.height, list.internal.height
  end

  def test_copied_interface_should_succeed_an_section_name_of_original
    list = create_interface
    new_parent = @report.start_new_page

    assert_same list.copy(new_parent).internal.section_name,
                list.internal.section_name
  end

  def test_copied_interface_should_have_all_the_copies_of_Shape_which_original_holds
    list = create_interface
    copied_list(list) do |new_list|
      assert_equal new_list.manager.shapes.size, 3
    end
  end

  def copied_list(list, &block)
    tblock     = Thinreports::Core::Shape::TextBlock
    new_parent = @report.start_new_page

    %w( foo bar hoge ).each do |id|
      list.manager.format.shapes[id.to_sym] = tblock::Format.new('type' => 's-tblock', 'id' => id)
      list.item(id).value(10)
    end

    block.call(list.copy(new_parent))
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
thinreports-0.8.2 test/unit/core/shape/list/test_section_interface.rb
thinreports-0.8.1 test/unit/core/shape/list/test_section_interface.rb
thinreports-0.8.0 test/unit/core/shape/list/test_section_interface.rb