# Copyright:: Copyright 2012 Trimble Navigation Ltd.
# License:: Apache License version 2.0
# Original Author:: Scott Lininger 
#
# Tests the SketchUp Ruby API ConstructionLine object.
#
# This file was originally generated by ourdoc.rb, an internal tool we developed
# specifically for outputting support files (documentation, unit tests, etc.)
# from the standard, doxygen-style c++ comments that are embedded into the
# Ruby implementation files. You can find ourdoc.rb alongside these
# implementation files at:
#
# googleclient/sketchup/source/sketchup/ruby
#

require 'test/unit'

# TC_ConstructionLine contains unit tests for the ConstructionLine class.
#
# API Object::       ConstructionLine
# C++ File::         rconstructionline.cpp
# Parent Class::     Drawingelement
# Version::          SketchUp 6.0
#
# The ConstructionLine class contains methods for modifying construction
# lines.  Construction lines can be infinite in length, semi-infinite (i.e.
# infinite in one direction) or finite.
#
#
class TC_ConstructionLine < Test::Unit::TestCase

  # Setup for test cases, if required.
  #
  def setup
    def UI::messagebox(params)
      puts 'TESTUP OVERRIDE: UI::messagebox > ' + params.to_s
    end

    entities_to_erase = []
    for entity in Sketchup.active_model.entities
      entities_to_erase.push entity
    end

    for entity in entities_to_erase
      if entity.valid?
        entity.erase!
      end
    end
  end

  # ----------------------------------------------------------------------------
  # @par Ruby Method:    ConstructionLine.end=
  # @file                rconstructionline.cpp
  #
  # The end= method is used to set the end point of the construction line.
  # This method will make the length finite at the end.
  #
  # Set the end to nil to make the construction line infinite at the end.
  #
  #
  # Args:
  # - point: The Point3d object to set for the end point of the
  # construction line.
  # - nil: Sets the end point to infinite.
  #
  # Returns:
  # - status: 3d point if or nil
  #

  # Test the example code that we have in the API documentation.
  def test_set_end_api_example
    assert_nothing_raised do
     # Need better examples throughout this file.
     model = Sketchup.active_model
     entities = model.active_entities
     point1 = Geom::Point3d.new(0,0,0)
     point2 = Geom::Point3d.new(20,20,20)
     point3 = Geom::Point3d.new(10,10,10)
     constline = entities.add_cline point1, point2
     endofline = constline.end = nil
     if (endofline)
	     UI.messagebox endofline.to_s
     else
	     UI.messagebox endofline.to_s
     end
    end
  end

  # Test edgecases for values passed to this method.
  #def test_set_end_edgecases
  #  raise('AUTOGENERATED STUB. Do manual review, then delete this warning.')
  #  assert_equal('expected', 'result',
  #               'Failed in test_set_end_edgecases' )
  #end

  # Test what happens when bad arguments are passed (nil, too few, etc.)
  #def test_set_end_bad_params
  #  raise('AUTOGENERATED STUB. Do manual review, then delete this warning.')
  #  assert_raise RuntimeError do
  #    # bad arguments here that should cause errors
  #  end
  #end

  # ----------------------------------------------------------------------------
  # @par Ruby Method:    ConstructionLine.position=
  # @file                rconstructionline.cpp
  #
  # Thie position= method is used to set a 3d point that the construction
  # passes through
  #
  #
  # Args:
  # - point: The Point3d object for the construction line to pass through.
  #
  # Returns:
  # - point: the new Point3d object that the construction
  # line will pass through (if successful)
  #

  # Test the example code that we have in the API documentation.
  def test_set_position_api_example
    assert_nothing_raised do
     model = Sketchup.active_model
     entities = model.active_entities
     point1 = Geom::Point3d.new(0,0,0)
     point2 = Geom::Point3d.new(20,20,20)
     point3 = Geom::Point3d.new(0,20,20)
     constline = entities.add_cline point1, point2
     position = constline.position = point3
    end
  end

  # Test edgecases for values passed to this method.
  #def test_set_position_edgecases
  #  raise('AUTOGENERATED STUB. Do manual review, then delete this warning.')
  #  assert_equal('expected', 'result',
  #               'Failed in test_set_position_edgecases' )
  #end

  # Test what happens when bad arguments are passed (nil, too few, etc.)
  #def test_set_position_bad_params
  #  raise('AUTOGENERATED STUB. Do manual review, then delete this warning.')
  #  assert_raise RuntimeError do
  #    # bad arguments here that should cause errors
  #  end
  #end

  # ----------------------------------------------------------------------------
  # @par Ruby Method:    ConstructionLine.position
  # @file                rconstructionline.cpp
  #
  # The position method is used to retrieve a 3d point used to create a
  # construction line on an infinite construction line.
  #
  #
  # Args:
  #
  # Returns:
  # - point: the Point3d object used to create the line (if
  # successful)
  #

  # Test the example code that we have in the API documentation.
  def test_position_api_example
    assert_nothing_raised do
     model = Sketchup.active_model
     entities = model.active_entities
     point1 = Geom::Point3d.new(0,0,0)
     vector = Geom::Vector3d.new(10,10,10)
     constline = entities.add_cline point1, vector
     # Returns point1 or 0,0,0
     position = constline.position
    end
  end

  # Test edgecases for values passed to this method.
  #def test_position_edgecases
  #  raise('AUTOGENERATED STUB. Do manual review, then delete this warning.')
  #  assert_equal('expected', 'result',
  #               'Failed in test_position_edgecases' )
  #end

  # Test what happens when bad arguments are passed (nil, too few, etc.)
  #def test_position_bad_params
  #  raise('AUTOGENERATED STUB. Do manual review, then delete this warning.')
  #  assert_raise RuntimeError do
  #    # bad arguments here that should cause errors
  #  end
  #end

  # ----------------------------------------------------------------------------
  # @par Ruby Method:    ConstructionLine.stipple
  # @file                rconstructionline.cpp
  #
  # The stipple method is used to retrieve the stipple pattern used to
  # display the construction line.
  #
  #
  # Args:
  #
  # Returns:
  # - pattern: the stipple pattern being used
  #

  # Test the example code that we have in the API documentation.
  def test_stipple_api_example
    assert_nothing_raised do
     model = Sketchup.active_model
     entities = model.active_entities
     point1 = Geom::Point3d.new(0,0,0)
     point2 = Geom::Point3d.new(20,20,20)
     constline = entities.add_cline point1, point2
    end
  end

  # Test edgecases for values passed to this method.
  #def test_stipple_edgecases
  #  raise('AUTOGENERATED STUB. Do manual review, then delete this warning.')
  #  assert_equal('expected', 'result',
  #               'Failed in test_stipple_edgecases' )
  #end

  # Test what happens when bad arguments are passed (nil, too few, etc.)
  #def test_stipple_bad_params
  #  raise('AUTOGENERATED STUB. Do manual review, then delete this warning.')
  #  assert_raise RuntimeError do
  #    # bad arguments here that should cause errors
  #  end
  #end

  # ----------------------------------------------------------------------------
  # @par Ruby Method:    ConstructionLine.start=
  # @file                rconstructionline.cpp
  #
  # The start= method is used to set the start point of a construction
  # line making the line's length finite at the start.
  #
  # Setting the start to nil will make the construction line infinite at
  # the start.
  #
  #
  # Args:
  # - point: The Point3d object to set for the end point of the
  # construction line.
  # - nil: Sets the end point to infinite.
  #
  # Returns:
  # - point: a Point3d object if successful or nil
  #

  # Test the example code that we have in the API documentation.
  def test_set_start_api_example
    assert_nothing_raised do
     model = Sketchup.active_model
     entities = model.active_entities
     point1 = Geom::Point3d.new(0,0,0)
     point2 = Geom::Point3d.new(20,20,20)
     point3 = Geom::Point3d.new(5,5,5)
     constline = entities.add_cline point1, point2
     startofline = constline.start = point3
    end
  end

  # Test edgecases for values passed to this method.
  #def test_set_start_edgecases
  #  raise('AUTOGENERATED STUB. Do manual review, then delete this warning.')
  #  assert_equal('expected', 'result',
  #               'Failed in test_set_start_edgecases' )
  #end

  # Test what happens when bad arguments are passed (nil, too few, etc.)
  #def test_set_start_bad_params
  #  raise('AUTOGENERATED STUB. Do manual review, then delete this warning.')
  #  assert_raise RuntimeError do
  #    # bad arguments here that should cause errors
  #  end
  #end

  # ----------------------------------------------------------------------------
  # @par Ruby Method:    ConstructionLine.direction
  # @file                rconstructionline.cpp
  #
  # The direction method retrieves a 3d vector in the direction of the
  # construction line.
  #
  #
  # Args:
  #
  # Returns:
  # - vector: a Vector3d object if successful
  #

  # Test the example code that we have in the API documentation.
  def test_direction_api_example
    assert_nothing_raised do
     model = Sketchup.active_model
     entities = model.active_entities
     point1 = Geom::Point3d.new(0,0,0)
     point2 = Geom::Point3d.new(20,20,20)
     constline = entities.add_cline point1, point2
     vector = constline.direction
     if (vector)
       UI.messagebox vector.to_s
     else
       UI.messagebox "Failure"
     end
    end
  end

  # Test edgecases for values passed to this method.
  #def test_direction_edgecases
  #  raise('AUTOGENERATED STUB. Do manual review, then delete this warning.')
  #  assert_equal('expected', 'result',
  #               'Failed in test_direction_edgecases' )
  #end

  # Test what happens when bad arguments are passed (nil, too few, etc.)
  #def test_direction_bad_params
  #  raise('AUTOGENERATED STUB. Do manual review, then delete this warning.')
  #  assert_raise RuntimeError do
  #    # bad arguments here that should cause errors
  #  end
  #end

  # ----------------------------------------------------------------------------
  # @par Ruby Method:    ConstructionLine.stipple=
  # @file                rconstructionline.cpp
  #
  # The stipple= method is used to set the stipple pattern used to display
  # the construction line. The stipple pattern can be given as a string or
  # as a number. Valid strings are:
  # ".",
  # "-",
  # "_",
  # "-.-".
  #
  #
  # Args:
  # - pattern: - the stipple pattern to use
  #
  # Returns:
  #

  # Test the example code that we have in the API documentation.
  def test_set_stipple_api_example
    assert_nothing_raised do
     model = Sketchup.active_model
     entities = model.active_entities
     point1 = Geom::Point3d.new(0,0,0)
     point2 = Geom::Point3d.new(20,20,20)
     constline = entities.add_cline point1, point2
     constline.stipple = "-.-"
    end
  end

  # Test edgecases for values passed to this method.
  #def test_set_stipple_edgecases
  #  raise('AUTOGENERATED STUB. Do manual review, then delete this warning.')
  #  assert_equal('expected', 'result',
  #               'Failed in test_set_stipple_edgecases' )
  #end

  # Test what happens when bad arguments are passed (nil, too few, etc.)
  #def test_set_stipple_bad_params
  #  raise('AUTOGENERATED STUB. Do manual review, then delete this warning.')
  #  assert_raise RuntimeError do
  #    # bad arguments here that should cause errors
  #  end
  #end

  # ----------------------------------------------------------------------------
  # @par Ruby Method:    ConstructionLine.end
  # @file                rconstructionline.cpp
  #
  # The end method retrieves the end point of a construction line in the
  # form of a 3d point.
  #
  # If the construction line is infinite at the end, this returns nil.
  #
  #
  # Args:
  #
  # Returns:
  # - point: a Point3d object representing the end of the
  # construction line
  #

  # Test the example code that we have in the API documentation.
  def test_end_api_example
    assert_nothing_raised do
     model = Sketchup.active_model
     entities = model.active_entities
     point1 = Geom::Point3d.new(0,0,0)
     point2 = Geom::Point3d.new(20,20,20)
     constline = entities.add_cline point1, point2
     endofline = constline.end
    end
  end

  # Test edgecases for values passed to this method.
  #def test_end_edgecases
  #  raise('AUTOGENERATED STUB. Do manual review, then delete this warning.')
  #  assert_equal('expected', 'result',
  #               'Failed in test_end_edgecases' )
  #end

  # Test what happens when bad arguments are passed (nil, too few, etc.)
  #def test_end_bad_params
  #  raise('AUTOGENERATED STUB. Do manual review, then delete this warning.')
  #  assert_raise RuntimeError do
  #    # bad arguments here that should cause errors
  #  end
  #end

  # ----------------------------------------------------------------------------
  # @par Ruby Method:    ConstructionLine.start
  # @file                rconstructionline.cpp
  #
  # The start method is used to retrieve the starting point of a
  # construction line.
  #
  # If the construction line is infinite at the start, this returns nil.
  #
  #
  # Args:
  #
  # Returns:
  # - point: the Poin3d object representing the starting
  # point of the construction line (if successful)
  #

  # Test the example code that we have in the API documentation.
  def test_start_api_example
    assert_nothing_raised do
     model = Sketchup.active_model
     entities = model.active_entities
     point1 = Geom::Point3d.new(0,0,0)
     point2 = Geom::Point3d.new(20,20,20)
     constline = entities.add_cline point1, point2
     startofline = constline.start
    end
  end

  # Test edgecases for values passed to this method.
  #def test_start_edgecases
  #  raise('AUTOGENERATED STUB. Do manual review, then delete this warning.')
  #  assert_equal('expected', 'result',
  #               'Failed in test_start_edgecases' )
  #end

  # Test what happens when bad arguments are passed (nil, too few, etc.)
  #def test_start_bad_params
  #  raise('AUTOGENERATED STUB. Do manual review, then delete this warning.')
  #  assert_raise RuntimeError do
  #    # bad arguments here that should cause errors
  #  end
  #end

  # ----------------------------------------------------------------------------
  # @par Ruby Method:    ConstructionLine.direction=
  # @file                rconstructionline.cpp
  #
  # The direction= method is used to set the direction of the construction
  # line to a 3d vector.
  #
  #
  # Args:
  # - vector: The Vector3d whose direction will be used to set the
  # direction of the construction line.
  #
  # Returns:
  # - vector: the new Vector3d object if successful
  #

  # Test the example code that we have in the API documentation.
  def test_set_direction_api_example
    assert_nothing_raised do
     # Need example ruby code here.
    end
  end

  # Test edgecases for values passed to this method.
  #def test_set_direction_edgecases
  #  raise('AUTOGENERATED STUB. Do manual review, then delete this warning.')
  #  assert_equal('expected', 'result',
  #               'Failed in test_set_direction_edgecases' )
  #end

  # Test what happens when bad arguments are passed (nil, too few, etc.)
  #def test_set_direction_bad_params
  #  raise('AUTOGENERATED STUB. Do manual review, then delete this warning.')
  #  assert_raise RuntimeError do
  #    # bad arguments here that should cause errors
  #  end
  #end

  # ----------------------------------------------------------------------------
  # @par Ruby Method:    ConstructionLine.reverse!
  # @file                rconstructionline.cpp
  #
  # The reverse! method is used to reverse the direction of the
  # construction line.
  #
  #
  # Args:
  #
  # Returns:
  # - : status
  #

  # Test the example code that we have in the API documentation.
  def test_reverse_inplace_api_example
    assert_nothing_raised do
     model = Sketchup.active_model
     entities = model.active_entities
     point1 = Geom::Point3d.new(0,0,0)
     point2 = Geom::Point3d.new(20,20,20)
     constline = entities.add_cline point1, point2
     status = constline.reverse!
    end
  end

  # Test edgecases for values passed to this method.
  #def test_reverse_inplace_edgecases
  #  raise('AUTOGENERATED STUB. Do manual review, then delete this warning.')
  #  assert_equal('expected', 'result',
  #               'Failed in test_reverse_inplace_edgecases' )
  #end

  # Test what happens when bad arguments are passed (nil, too few, etc.)
  #def test_reverse_inplace_bad_params
  #  raise('AUTOGENERATED STUB. Do manual review, then delete this warning.')
  #  assert_raise RuntimeError do
  #    # bad arguments here that should cause errors
  #  end
  #end

end
