Line 44... |
Line 44... |
describe SOCMaker::IfcDef, "verification" do
|
describe SOCMaker::IfcDef, "verification" do
|
|
|
tmp_port = SOCMaker::IfcPort.new( "abc" )
|
tmp_port = SOCMaker::IfcPort.new( "abc" )
|
|
|
it "should return a SOCMaker::IfcDef object when creating with new" do
|
it "should return a SOCMaker::IfcDef object when creating with new" do
|
s = SOCMaker::IfcDef.new( "myifc", "v1", 1, { test: tmp_port } )
|
s = SOCMaker::IfcDef.new( "myifc", "myifc,v1", 1, { test: tmp_port } )
|
s.class.should be SOCMaker::IfcDef
|
s.class.should be SOCMaker::IfcDef
|
end
|
end
|
|
|
it "should raise an error if the name is not a string" do
|
it "should raise an error if the name is not a string" do
|
expect{ SOCMaker::IfcDef.new( 4, "v1", 1, { test: tmp_port } ) }.
|
expect{ SOCMaker::IfcDef.new( 4, "myifc,v1", 1, { test: tmp_port } ) }.
|
to raise_error( SOCMaker::ERR::ValueError )
|
to raise_error( SOCMaker::ERR::ValueError )
|
end
|
end
|
|
|
it "should raise an error if the direction is neither 0 nor 1 " do
|
it "should raise an error if the direction is neither 0 nor 1 " do
|
expect{ SOCMaker::IfcDef.new( "myifc", "v1", 4, { test: tmp_port } ) }.
|
expect{ SOCMaker::IfcDef.new( "myifc", "myifc,v1", 4, { test: tmp_port } ) }.
|
to raise_error( SOCMaker::ERR::ValueError )
|
to raise_error( SOCMaker::ERR::ValueError )
|
end
|
end
|
|
|
|
|
it "should raise an error if no ports are given " do
|
it "should raise an error if no ports are given " do
|
expect{ SOCMaker::IfcDef.new( "myifc", "v1", 4, { } ) }.
|
expect{ SOCMaker::IfcDef.new( "myifc", "myifc,v1", 4, { } ) }.
|
to raise_error( SOCMaker::ERR::StructureError )
|
to raise_error( SOCMaker::ERR::StructureError )
|
end
|
end
|
|
|
|
|
it "should raise an error if a ports is nil " do
|
it "should raise an error if a ports is nil " do
|
expect{ SOCMaker::IfcDef.new( "myifc", "v1", 4, { a_port: nil} ) }.
|
expect{ SOCMaker::IfcDef.new( "myifc", "myifc,v1", 4, { a_port: nil} ) }.
|
to raise_error( SOCMaker::ERR::StructureError )
|
to raise_error( SOCMaker::ERR::StructureError )
|
end
|
end
|
|
|
it "should raise an error if a ports is not of type SOCMaker::IfcPort " do
|
it "should raise an error if a ports is not of type SOCMaker::IfcPort " do
|
expect{ SOCMaker::IfcDef.new( "myifc", "v1", 4, { a_port: "string-type"} ) }.
|
expect{ SOCMaker::IfcDef.new( "myifc", "myifc,v1", 4, { a_port: "string-type"} ) }.
|
to raise_error( SOCMaker::ERR::StructureError )
|
to raise_error( SOCMaker::ERR::StructureError )
|
end
|
end
|
|
|
it "should raise an error if no ports are given (nil)" do
|
it "should raise an error if no ports are given (nil)" do
|
expect{ SOCMaker::IfcDef.new( "myifc", "v1", 4, nil ) }.
|
expect{ SOCMaker::IfcDef.new( "myifc", "myifc,v1", 4, nil ) }.
|
to raise_error( SOCMaker::ERR::StructureError )
|
to raise_error( SOCMaker::ERR::StructureError )
|
end
|
end
|
|
|
it "should auto-convert a numerical version to string version" do
|
|
s = SOCMaker::IfcDef.new( "myifc", 1, 1, { test: tmp_port } )
|
|
s.version.should be == "1"
|
|
end
|
|
end
|
end
|
|
|
describe SOCMaker::IfcDef, "object handling, en-decoding:" do
|
describe SOCMaker::IfcDef, "object handling, en-decoding:" do
|
tmp_port = SOCMaker::IfcPort.new( "abc" )
|
tmp_port = SOCMaker::IfcPort.new( "abc" )
|
|
|
it "should return false for two non-equal objects" do
|
it "should return false for two non-equal objects" do
|
o1 = SOCMaker::IfcDef.new( "myifc", "v1", 1, { test: tmp_port } )
|
o1 = SOCMaker::IfcDef.new( "myifc", "myifc,v1", 1, { test: tmp_port } )
|
o2 = Marshal::load(Marshal.dump(o1))
|
o2 = Marshal::load(Marshal.dump(o1))
|
o2.version = "v2"
|
o2.id = "myifc,v2"
|
( o2 == o1 ).should be == false
|
( o2 == o1 ).should be == false
|
end
|
end
|
|
|
it "should be possible to encode and decode a interface definition" do
|
it "should be possible to encode and decode a interface definition" do
|
o1 = SOCMaker::IfcDef.new( "myifc", "v1", 1, { test: tmp_port } )
|
o1 = SOCMaker::IfcDef.new( "myifc", "myifc,v1", 1, { test: tmp_port } )
|
yaml_str = o1.to_yaml
|
yaml_str = o1.to_yaml
|
o2 = YAML::load( yaml_str )
|
o2 = YAML::load( yaml_str )
|
o1.should be == o2
|
o1.should be == o2
|
end
|
end
|
|
|