Sha256: 482e3824c2f0292ab32819577407a6fe85a2d8bfe32dc1d1946f46951e05fa3c

Contents?: true

Size: 1.71 KB

Versions: 2

Compression:

Stored size: 1.71 KB

Contents

require File.dirname(__FILE__) + '/../test_helper'

class ContainerTest < Test::Unit::TestCase
  fixtures :containers, :objects_in_world

  def test_all_empty
    container=Container.new
    assert(!container.valid?, "Un container vide devrait être invalide")
  end
  
  def test_container_valid
    container=Container.new
    container.container_key="9104d928-e35e-2dd6-f888-7ab766e06351"
#    container.container_key="a1af238c-9ff8-5f1b-8faf-e46b03r1ad2af7"
    container.sim="La Plaine"
    container.delay="30"
    container.position="(1,2,3)"
    container.name="ctest"
    assert(container.valid?, "Ce container est invalide")
    assert(container.save, "La sauvegarde a échoué")
  end
  
  def test_container_validation
    assert_nothing_raised {
      @container1 = Container.create(
        :container_key => "d906e900-708f-fd93-8245-79000494711e",
        :sim => "Myeon (263936, 235008)",
        :position => "(33.413044, 2.188796, 136.624924)",
        :name => "Container Test"
      )
    }
    assert_nothing_raised {
      @container2 = Container.find(@container1.id)
    }
    assert_equal "d906e900-708f-fd93-8245-79000494711e", @container2.container_key
    assert_equal "Myeon", @container2.sim
    assert_equal "33,2,136", @container2.position
    assert_equal "Container Test", @container2.name
  end

  def test_can_delete_full_container
    container = containers(:container_1)
    assert_nothing_raised { container.destroy }
  end
  
  def test_can_delete_empty_container
    container = containers(:container_1)
    assert_not_equal 0, container.objects_in_world.count
    container.objects_in_world.destroy_all
    assert_equal 0, container.objects_in_world.count
    assert_nothing_raised { container.destroy }
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
advertnet-1.0.0 test/unit/container_test.rb
advertnet-1.0.1 test/unit/container_test.rb