Bio-MAGE

 view release on metacpan or  search on metacpan

t/Feature.t  view on Meta::CPAN

# test setFeatureGroup throws exception with bad argument
eval {$feature->setFeatureGroup(1)};
ok($@, 'setFeatureGroup throws exception with bad argument');


# test getFeatureGroup throws exception with argument
eval {$feature->getFeatureGroup(1)};
ok($@, 'getFeatureGroup throws exception with argument');

# test setFeatureGroup throws exception with no argument
eval {$feature->setFeatureGroup()};
ok($@, 'setFeatureGroup throws exception with no argument');

# test setFeatureGroup throws exception with too many argument
eval {$feature->setFeatureGroup(1,2)};
ok($@, 'setFeatureGroup throws exception with too many argument');

# test setFeatureGroup accepts undef
eval {$feature->setFeatureGroup(undef)};
ok((!$@ and not defined $feature->getFeatureGroup()),
   'setFeatureGroup accepts undef');

# test the meta-data for the assoication
$assn = $assns{featureGroup};
isa_ok($assn, 'Bio::MAGE::Association');
$end = $assn->other();
isa_ok($end, 'Bio::MAGE::Association::End');
ok((defined $end
   and defined $end->documentation(),
   and defined $end->cardinality(),
   and grep {$_ eq $end->cardinality} ('0..1','1','1..N','0..N'),
   and defined $end->is_ref(),
   and ($end->is_ref() == 0 or $end->is_ref() == 1),
   and defined $end->rank(),
   and $end->rank(),
   and defined $end->ordered(),
   and ($end->ordered() == 0 or $end->ordered() == 1),
   and defined $end->class_name(),
   and $end->class_name(),
   and defined $end->name(),
   and $end->name()),
   'featureGroup->other() is a valid Bio::MAGE::Association::End'
  );

$end = $assn->self();
isa_ok($end, 'Bio::MAGE::Association::End');
ok((defined $end
   and defined $end->documentation(),
   and defined $end->cardinality(),
   and grep {$_ eq $end->cardinality} ('0..1','1','1..N','0..N'),
   and defined $end->is_ref(),
   and ($end->is_ref() == 0 or $end->is_ref() == 1),
   and defined $end->class_name(),
   and $end->class_name()),
   'featureGroup->self() is a valid Bio::MAGE::Association::End'
  );



# testing association featureLocation
my $featurelocation_assn;
{
  # silence the abstract class warnings
  local $SIG{__WARN__} = sub {'IGNORE'};
  $featurelocation_assn = Bio::MAGE::DesignElement::FeatureLocation->new();
}


isa_ok($feature->getFeatureLocation, q[Bio::MAGE::DesignElement::FeatureLocation]);

is($feature->setFeatureLocation($featurelocation_assn), $featurelocation_assn,
  'setFeatureLocation returns value');

ok($feature->getFeatureLocation() == $featurelocation_assn,
   'getFeatureLocation fetches correct value');

# test setFeatureLocation throws exception with bad argument
eval {$feature->setFeatureLocation(1)};
ok($@, 'setFeatureLocation throws exception with bad argument');


# test getFeatureLocation throws exception with argument
eval {$feature->getFeatureLocation(1)};
ok($@, 'getFeatureLocation throws exception with argument');

# test setFeatureLocation throws exception with no argument
eval {$feature->setFeatureLocation()};
ok($@, 'setFeatureLocation throws exception with no argument');

# test setFeatureLocation throws exception with too many argument
eval {$feature->setFeatureLocation(1,2)};
ok($@, 'setFeatureLocation throws exception with too many argument');

# test setFeatureLocation accepts undef
eval {$feature->setFeatureLocation(undef)};
ok((!$@ and not defined $feature->getFeatureLocation()),
   'setFeatureLocation accepts undef');

# test the meta-data for the assoication
$assn = $assns{featureLocation};
isa_ok($assn, 'Bio::MAGE::Association');
$end = $assn->other();
isa_ok($end, 'Bio::MAGE::Association::End');
ok((defined $end
   and defined $end->documentation(),
   and defined $end->cardinality(),
   and grep {$_ eq $end->cardinality} ('0..1','1','1..N','0..N'),
   and defined $end->is_ref(),
   and ($end->is_ref() == 0 or $end->is_ref() == 1),
   and defined $end->rank(),
   and $end->rank(),
   and defined $end->ordered(),
   and ($end->ordered() == 0 or $end->ordered() == 1),
   and defined $end->class_name(),
   and $end->class_name(),
   and defined $end->name(),
   and $end->name()),
   'featureLocation->other() is a valid Bio::MAGE::Association::End'
  );

$end = $assn->self();
isa_ok($end, 'Bio::MAGE::Association::End');
ok((defined $end
   and defined $end->documentation(),
   and defined $end->cardinality(),
   and grep {$_ eq $end->cardinality} ('0..1','1','1..N','0..N'),
   and defined $end->is_ref(),
   and ($end->is_ref() == 0 or $end->is_ref() == 1),
   and defined $end->class_name(),
   and $end->class_name()),
   'featureLocation->self() is a valid Bio::MAGE::Association::End'
  );




( run in 1.081 second using v1.01-cache-2.11-cpan-71847e10f99 )