# Copyright:: Copyright (c) 2005 Uttk Team. All rights reserved. # Author:: Nicolas Pouillard . # License:: LGPL # Revision:: $Id: /w/fey/uttk/trunk/test/unit/logger/to_uttk_log_test.rb 21975 2006-02-19T22:24:11.182512Z pouillar $ test_section __FILE__ do module Uttk class ToUttkLogTest < Test::Unit::TestCase include Mocks::Assertions @@ordered = { :ordered => true }.freeze def setup self.mock_object = Mocks::Observer.new @l = Logger.new(mock_object) @very_simple_tree_with_ohash = { :contents => OHash[:test1, :cmd1, :test2, :cmd2] } @very_simple_tree_with_array = { :contents => [{:test1 => :cmd1}, {:test2 => :cmd2}] } @very_simple_notifs = Logger.make_notifs [ [[[:contents, {:ordered=>true}], :test1], :cmd1], [[[:contents, {:ordered=>true}], :test2], :cmd2]] @simple_tree_with_ohash = { :contents => OHash[:test1, { :cmd => [:a] }] } @simple_notifs = Logger.make_notifs [ [[[:contents, {:ordered=>true}], :test1, :cmd], [:a]]] @complex_tree_with_array = { :root => { :strategy => [ :cmd ], :contents => [ { :test1 => { :cmd => [:a], :exit => [:aa] }, }, { :test2 => { :cmd => :b, :exit => :bb }, } ] } } @complex_tree_with_ohash = { :root => { :strategy => :cmd, :contents => OHash[ :test1, { :cmd => [:a], :exit=> [:aa] }, :test2, { :cmd => :b, :exit => :bb } ] } } @complex_notifs = Logger.make_notifs [ [[[:root, {:type=>:cmd}], [:contents, {:ordered=>true}], :test1, :cmd], [:a]], [[[:root, {:type=>:cmd}], [:contents, {:ordered=>true}], :test1, :exit], [:aa]], [[[:root, {:type=>:cmd}], [:contents, {:ordered=>true}], :test2, :cmd], :b], [[[:root, {:type=>:cmd}], [:contents, {:ordered=>true}], :test2, :exit], :bb]] end def test_very_simple_with_ohash @l << @very_simple_tree_with_ohash assert_mock @very_simple_notifs end def test_very_simple_with_array @l << @very_simple_tree_with_array assert_mock @very_simple_notifs end def test_simple @l << @simple_tree_with_ohash assert_mock @simple_notifs end def test_complex @l << @complex_tree_with_ohash args = mock_object.mock_args @complex_notifs.each do |notif| assert args.include?(notif), "args.include?(#{notif.inspect})" end test1 = [] args.each_with_index { |notif, i| test1 << i if notif.include? :test1 } max_test1 = test1.max args.each_with_index { |notif, i| assert(i > max_test1) if notif.include? :test2 } end end # class LoggerTest end # module Uttk end