summaryrefslogtreecommitdiffhomepage
path: root/test/drawing/tc_bar_3D_chart.rb
blob: ff01464c934c71b9c29d7e28054c2b890107d17e (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
require 'test/unit'
require 'axlsx.rb'

class TestBar3DChart < Test::Unit::TestCase

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

  def teardown
  end

  def test_initialization    
    assert_equal(@chart.grouping, :clustered, "grouping defualt incorrect")
    assert_equal(@chart.series_type, Axlsx::BarSeries, "series type incorrect")
    assert_equal(@chart.barDir, :bar, " bar direction incorrect")
    assert(@chart.catAxis.is_a?(Axlsx::CatAxis), "category axis not created")
    assert(@chart.valAxis.is_a?(Axlsx::ValAxis), "value access not created")
  end

  def test_bar_direction
    assert_raise(ArgumentError, "require valid bar direction") { @chart.barDir = :left }
    assert_nothing_raised("allow valid bar direction") { @chart.barDir = :col }
    assert(@chart.barDir == :col)
  end

 def test_grouping
   assert_raise(ArgumentError, "require valid grouping") { @chart.grouping = :inverted }
   assert_nothing_raised("allow valid grouping") { @chart.grouping = :standard }
   assert(@chart.grouping == :standard)
 end


 def test_gapWidth
   assert_raise(ArgumentError, "require valid gap width") { @chart.gapWidth = 200 }
   assert_nothing_raised("allow valid gapWidth") { @chart.gapWidth = "200%" }
   assert(@chart.gapWidth == "200%")
 end

 def test_gapDepth
   assert_raise(ArgumentError, "require valid gapDepth") { @chart.gapDepth = 200 }
   assert_nothing_raised("allow valid gapDepth") { @chart.gapDepth = "200%" }
   assert(@chart.gapDepth == "200%")
 end

  def test_shape
    assert_raise(ArgumentError, "require valid shape") { @chart.shape = :star }
    assert_nothing_raised("allow valid shape") { @chart.shape = :cone }
    assert(@chart.shape == :cone)
  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