Sha256: c62c6e82db26beeac5abfd54d80d14b0ad9ba0f67f32f1c5f32d07234c475aaf

Contents?: true

Size: 1.99 KB

Versions: 7

Compression:

Stored size: 1.99 KB

Contents

require 'test/unit'
require 'axlsx.rb'

class TestPie3DChart < Test::Unit::TestCase

  def setup
    p = Axlsx::Package.new
    ws = p.workbook.add_worksheet
    @row = ws.add_row :values=>["one", 1, Time.now]
    @chart = ws.drawing.add_chart Axlsx::Pie3DChart, :title => "fishery"
  end

  def teardown
  end

  def test_initialization
    assert_equal(@chart.workbook.charts.last,@chart, "the chart is in the workbook")
    assert_equal(@chart.title.text, "fishery", "the title option has been applied")
    assert((@chart.series.is_a?(Axlsx::SimpleTypedList) && @chart.series.empty?), "The series is initialized and empty") 
  end

  def test_title
    @chart.title.text = 'wowzer'
    assert_equal(@chart.title.text, "wowzer", "the title text via a string")
    assert_equal(@chart.title.cell, nil, "the title cell is nil as we set the title with text.")
    @chart.title.cell = @row.cells.first
    assert_equal(@chart.title.text, "one", "the title text was set via cell reference")
    assert_equal(@chart.title.cell, @row.cells.first)
  end

  def test_add_series    
    s = @chart.add_series :data=>[0,1,2,3], :labels => ["one", 1, "anything"], :title=>"bob"
    assert_equal(@chart.series.last, s, "series has been added to chart series collection")
    assert_equal(s.title, "bob", "series title has been applied")
    assert_equal(s.data, [0,1,2,3], "data option applied")
    assert_equal(s.labels, ["one",1,"anything"], "labels option applied")    
  end  
  
  def test_create_range
    
  end

  def test_pn
    assert_equal(@chart.pn, "charts/chart1.xml")
  end

  def test_rId
    assert_equal(@chart.rId, "rId1")
  end
  
  def test_index
    assert_equal(@chart.index, @chart.workbook.charts.index(@chart))
  end

  def test_to_xml
    schema = Nokogiri::XML::Schema(File.open(Axlsx::DRAWING_XSD))
    doc = Nokogiri::XML(@chart.to_xml)
    errors = []
    schema.validate(doc).each do |error|
      errors.push error
      puts error.message
    end
    assert(errors.empty?, "error free validation")
  end  
  
end

Version data entries

7 entries across 7 versions & 1 rubygems

Version Path
axlsx-1.0.7 test/tc_pie_3D_chart.rb~
axlsx-1.0.6 test/tc_pie_3D_chart.rb~
axlsx-1.0.5 test/tc_pie_3D_chart.rb~
axlsx-1.0.4 test/tc_pie_3D_chart.rb~
axlsx-1.0.3 test/tc_pie_3D_chart.rb~
axlsx-1.0.1 test/tc_pie_3D_chart.rb~
axlsx-1.0.0 test/tc_pie_3D_chart.rb~