Sha256: 31dc4e25a2498846d6059cb3a5c688c0178ba30220ae9ab4004e418953a43b67

Contents?: true

Size: 1.36 KB

Versions: 1

Compression:

Stored size: 1.36 KB

Contents

require File.expand_path("../test_helper", File.dirname(__FILE__))

class CardinalityTest < ActiveSupport::TestCase
  # Cardinality order ========================================================
  test "cardinalities should be sorted in order of maniness" do
    assert_equal [Relationship::Cardinality::OneToOne, Relationship::Cardinality::OneToMany, Relationship::Cardinality::ManyToMany],
      [Relationship::Cardinality::OneToMany, Relationship::Cardinality::ManyToMany, Relationship::Cardinality::OneToOne].sort
  end
  
  # Cardinality properties ===================================================
  test "one_to_one should return true for one to one cardinalities" do
    assert_equal [true, false, false], [Relationship::Cardinality::OneToOne,
      Relationship::Cardinality::OneToMany, Relationship::Cardinality::ManyToMany].map(&:one_to_one?)
  end

  test "one_to_many should return true for one to many cardinalities" do
    assert_equal [false, true, false], [Relationship::Cardinality::OneToOne,
      Relationship::Cardinality::OneToMany, Relationship::Cardinality::ManyToMany].map(&:one_to_many?)
  end

  test "many_to_many should return true for many to many cardinalities" do
    assert_equal [false, false, true], [Relationship::Cardinality::OneToOne,
      Relationship::Cardinality::OneToMany, Relationship::Cardinality::ManyToMany].map(&:many_to_many?)
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
rails-erd-0.2.0 test/unit/cardinality_test.rb