Class: XDelayTest

Inherits:
Test::Unit::TestCase show all
Defined in:
lib/gems/xmpp4r-0.4/test/delay/tc_xdelay.rb

Instance Method Summary collapse

Methods inherited from Test::Unit::TestCase

#assert_array_equal, expect, #run

Instance Method Details

#test_create1Object



11
12
13
14
15
16
# File 'lib/gems/xmpp4r-0.4/test/delay/tc_xdelay.rb', line 11

def test_create1
  d = Delay::XDelay.new(false)
  assert_equal(nil, d.stamp)
  assert_equal(nil, d.from)
  assert_equal('jabber:x:delay', d.namespace)
end

#test_create2Object



18
19
20
21
22
23
24
# File 'lib/gems/xmpp4r-0.4/test/delay/tc_xdelay.rb', line 18

def test_create2
  d = Delay::XDelay.new
  # Hopefully the seconds don't change here...
  assert_equal(Time.now.to_s, d.stamp.to_s)
  assert_equal(nil, d.from)
  assert_equal('jabber:x:delay', d.namespace)
end

#test_fromObject



26
27
28
29
30
31
32
33
# File 'lib/gems/xmpp4r-0.4/test/delay/tc_xdelay.rb', line 26

def test_from
  d = Delay::XDelay.new
  assert_equal(nil, d.from)
  d.from = JID.new('[email protected]')
  assert_equal(JID.new('[email protected]'), d.from)
  assert_equal(d, d.set_from(nil))
  assert_equal(nil, d.from)
end

#test_importObject



45
46
47
48
49
50
# File 'lib/gems/xmpp4r-0.4/test/delay/tc_xdelay.rb', line 45

def test_import
  x1 = X.new
  x1.add_namespace('jabber:x:delay')
  x2 = X::import(x1)
  assert_equal(Delay::XDelay, x2.class)
end

#test_stampObject



35
36
37
38
39
40
41
42
43
# File 'lib/gems/xmpp4r-0.4/test/delay/tc_xdelay.rb', line 35

def test_stamp
  d = Delay::XDelay.new(false)
  assert_equal(nil, d.stamp)
  now = Time.now
  d.stamp = now
  assert_equal(now.to_s, d.stamp.to_s)
  assert_equal(d, d.set_stamp(nil))
  assert_equal(nil, d.stamp)
end