Sha256: c3945ce9e13780f6e65b71ca5844042b52f15f450d31fe7236e5c7e46e082e30

Contents?: true

Size: 1.88 KB

Versions: 33

Compression:

Stored size: 1.88 KB

Contents

require 'tc_helper.rb'

class TestGradientFill < Test::Unit::TestCase

  def setup
    @item = Axlsx::GradientFill.new
  end

  def teardown
  end


  def test_initialiation
    assert_equal(@item.type, :linear)
    assert_equal(@item.degree, nil)
    assert_equal(@item.left, nil)
    assert_equal(@item.right, nil)
    assert_equal(@item.top, nil)
    assert_equal(@item.bottom, nil)
    assert(@item.stop.is_a?(Axlsx::SimpleTypedList))
  end

  def test_type
    assert_raise(ArgumentError) { @item.type = 7 }
    assert_nothing_raised { @item.type = :path }
    assert_equal(@item.type, :path)
  end

  def test_degree
    assert_raise(ArgumentError) { @item.degree = -7 }
    assert_nothing_raised { @item.degree = 5.0 }
    assert_equal(@item.degree, 5.0)
  end

  def test_left
    assert_raise(ArgumentError) { @item.left = -1.1 }
    assert_nothing_raised { @item.left = 1.0 }
    assert_equal(@item.left, 1.0)
  end

  def test_right
    assert_raise(ArgumentError) { @item.right = -1.1 }
    assert_nothing_raised { @item.right = 0.5 }
    assert_equal(@item.right, 0.5)
  end

  def test_top
    assert_raise(ArgumentError) { @item.top = -1.1 }
    assert_nothing_raised { @item.top = 1.0 }
    assert_equal(@item.top, 1.0)
  end

  def test_bottom
    assert_raise(ArgumentError) { @item.bottom = -1.1 }
    assert_nothing_raised { @item.bottom = 0.0 }
    assert_equal(@item.bottom, 0.0)
  end

  def test_stop
    @item.stop << Axlsx::GradientStop.new(Axlsx::Color.new(:rgb=>"00000000"), 0.5)
    assert(@item.stop.size == 1)
    assert(@item.stop.last.is_a?(Axlsx::GradientStop))
  end

  def test_to_xml_string
    @item.stop << Axlsx::GradientStop.new(Axlsx::Color.new(:rgb => "000000"), 0.5)
    @item.stop << Axlsx::GradientStop.new(Axlsx::Color.new(:rgb => "FFFFFF"), 0.5)
    @item.type = :path
    doc = Nokogiri::XML(@item.to_xml_string)
    assert(doc.xpath("//color[@rgb='FF000000']"))
  end
end

Version data entries

33 entries across 33 versions & 6 rubygems

Version Path
caxlsx-3.1.1 test/stylesheet/tc_gradient_fill.rb
caxlsx-3.1.0 test/stylesheet/tc_gradient_fill.rb
bonio-axlsx-2.2.3 test/stylesheet/tc_gradient_fill.rb
caxlsx-3.0.4 test/stylesheet/tc_gradient_fill.rb
caxlsx-3.0.3 test/stylesheet/tc_gradient_fill.rb
caxlsx-3.0.2 test/stylesheet/tc_gradient_fill.rb
caxlsx-2.0.2 test/stylesheet/tc_gradient_fill.rb
caxlsx-3.0.1 test/stylesheet/tc_gradient_fill.rb
caxlsx-3.0.0 test/stylesheet/tc_gradient_fill.rb
axlsx-alt-3.0.1 test/stylesheet/tc_gradient_fill.rb
axlsx-alt-3.0.0 test/stylesheet/tc_gradient_fill.rb
axlsx-3.0.0.pre test/stylesheet/tc_gradient_fill.rb
bonio-axlsx-2.2.2 test/stylesheet/tc_gradient_fill.rb
bonio-axlsx-2.2.1 test/stylesheet/tc_gradient_fill.rb
dg-axlsx-2.1.0 test/stylesheet/tc_gradient_fill.rb
axlsx-2.1.0.pre test/stylesheet/tc_gradient_fill.rb
l_axlsx-2.0.1 test/stylesheet/tc_gradient_fill.rb
axlsx-2.0.1 test/stylesheet/tc_gradient_fill.rb
axlsx-2.0.0 test/stylesheet/tc_gradient_fill.rb
axlsx-1.3.6 test/stylesheet/tc_gradient_fill.rb