require 'test/unit' require 'ontomde-core' class TC_context_tc1 < Test::Unit::TestCase def setup @@model=Crdf_Model.new end def test_context_sur_resource res=@@model['rdf_Resource'] assert(res.context.get(:build).nil?) res.mtk_context( :build=>"c:/tmp") { #log.debug "build=#{res.context[:build]}" assert(res.context[:build]=='c:/tmp') } assert(res.context.get(:build).nil?) assert(res.context.get(:anything).nil?) end def test_ajout_retrait_context_vide assert(@@model.context.get(:build).nil?) @@model.mtk_context( :build=>"c:/tmp") { #log.debug "build=#{@@model.context[:build]}" assert(@@model.context[:build]=='c:/tmp') } assert(@@model.context.get(:build).nil?) assert(@@model.context.get(:anything).nil?) end def test_redefinition assert(@@model.context.get(:build).nil?) test_done=false @@model.mtk_context( :build=>"c:/tmp") { #log.debug "build=#{@@model.context[:build]}" assert(!@@model.context.get(:build).nil?) assert(@@model.context[:build]=='c:/tmp') @@model.mtk_context( :build=>"h:/Z") { assert(@@model.context[:build]=='h:/Z') test_done=true } assert(@@model.context[:build]=='c:/tmp') } assert(@@model.context.get(:build).nil?) assert(test_done,"Test non execute") end def test_multiple_context assert(@@model.context.get(:build).nil?) assert(@@model.context.get(:lang).nil?) test_done=false @@model.mtk_context(:build=>"d:/tmp",:lang=>"fr",:opt=>1) { assert(!@@model.context.get(:build).nil?) assert(@@model.context.get(:build)==="d:/tmp") assert(@@model.context.get(:lang)=="fr") assert(@@model.context.get(:opt)==1) @@model.mtk_context(:lang=>"en") { assert(@@model.context[:build]=="d:/tmp") assert(@@model.context[:lang]=="en") assert(@@model.context[:opt]==1) @@model.mtk_context(:lang=>"us",:ww2=>1939) { assert(@@model.context[:build]=="d:/tmp") assert(@@model.context[:lang]=="us") assert(@@model.context[:opt]==1) assert(@@model.context[:ww2]==1939) test_done=true } assert(@@model.context[:build]=="d:/tmp") assert(@@model.context[:lang]=="en") assert(@@model.context[:opt]==1) } } assert(@@model.context.get(:build).nil?) assert(@@model.context.get(:lang).nil?) assert(test_done,"Test non execute") end def test_load_simple end end require 'test/unit/ui/console/testrunner' Test::Unit::UI::Console::TestRunner.run(TC_context_tc1)