Sha256: 512d3861709a152f75b1e68e53a2fb08a09d781c1cb3abf27fedbe9f597c518d

Contents?: true

Size: 1.48 KB

Versions: 1

Compression:

Stored size: 1.48 KB

Contents

#
# Testing OpenWFE
#
# John Mettraux at openwfe.org
#
# Tue Mar 11 13:44:11 JST 2008
#

require 'test/unit'

require 'rubygems'
require 'openwfe/workitem'
require 'openwfe/expressions/expressionmap'


class LookupVfTest < Test::Unit::TestCase

  #def setup
  #end

  #def teardown
  #end


  def test_0

    fexp = new_exp({
      "on-value" => "toto"
    })
    wi = new_wi({
      "toto" => "whatever"
    })

    assert_equal(
      "toto",
      fexp.lookup_vf_attribute(wi, "value", :prefix => "on"))

    fexp = new_exp({ "on-variable-value" => "toto" }, { "toto" => "surf" })

    assert_equal(
      "surf",
      fexp.lookup_vf_attribute(wi, "value", :prefix => "on"))

    fexp = new_exp({ "on-field-value" => "toto" })

    assert_equal(
      "whatever",
      fexp.lookup_vf_attribute(wi, "value", :prefix => "on"))
  end

  def test_1

    fexp = new_exp({
      "on" => "surf"
    })
    wi = new_wi

    assert_equal(
      "surf",
      fexp.lookup_vf_attribute(wi, "", :prefix => "on"))

    assert_equal(
      "surf",
      fexp.lookup_vf_attribute(wi, "", :prefix => :on))
  end

  protected

    def new_exp (atts, vars={})

      fexp = OpenWFE::ParticipantExpression.new
      fexp.attributes = atts

      fexp.instance_variable_set :@vars, vars

      class << fexp
        def lookup_variable (var_name)
          @vars[var_name]
        end
      end

      fexp
    end

    def new_wi (atts={})

      wi = OpenWFE::InFlowWorkItem.new
      wi.attributes = atts
      wi
    end

end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
ruote-0.9.19 test/lookup_vf_test.rb