Class: Mu::Xtractr::Packets::Test
- Inherits:
-
Test::Unit::TestCase
- Object
- Test::Unit::TestCase
- Mu::Xtractr::Packets::Test
- Defined in:
- lib/mu/xtractr/test/tc_packets.rb
Instance Attribute Summary collapse
-
#xtractr ⇒ Object
readonly
Returns the value of attribute xtractr.
Instance Method Summary collapse
- #setup ⇒ Object
- #test_count ⇒ Object
- #test_each ⇒ Object
- #test_first ⇒ Object
- #test_inspect ⇒ Object
- #test_Packets ⇒ Object
- #test_save ⇒ Object
- #test_sum ⇒ Object
- #test_values ⇒ Object
Instance Attribute Details
#xtractr ⇒ Object (readonly)
Returns the value of attribute xtractr.
22 23 24 |
# File 'lib/mu/xtractr/test/tc_packets.rb', line 22 def xtractr @xtractr end |
Instance Method Details
#setup ⇒ Object
24 25 26 |
# File 'lib/mu/xtractr/test/tc_packets.rb', line 24 def setup @xtractr = Xtractr.new end |
#test_count ⇒ Object
45 46 47 48 49 50 |
# File 'lib/mu/xtractr/test/tc_packets.rb', line 45 def test_count counts = xtractr.packets(1..10).count('pkt.src') assert_equal(3, counts.size) counts.each { |c| assert_kind_of(Views::Count, c) } assert_equal(true, counts[0].count > counts[-1].count) end |
#test_each ⇒ Object
32 33 34 35 36 37 |
# File 'lib/mu/xtractr/test/tc_packets.rb', line 32 def test_each pkts = xtractr.packets(1..10) pkts.each { |pkt| assert_kind_of(Packet, pkt) } pkts.each_packet { |pkt| assert_kind_of(Packet, pkt) } pkts.each_with_index { |pkt, i| assert_equal(i+1, pkt.id) } end |
#test_first ⇒ Object
39 40 41 42 43 |
# File 'lib/mu/xtractr/test/tc_packets.rb', line 39 def test_first pkt = xtractr.packets(1..10).first assert_kind_of(Packet, pkt) assert_equal(1, pkt.id) end |
#test_inspect ⇒ Object
78 79 80 |
# File 'lib/mu/xtractr/test/tc_packets.rb', line 78 def test_inspect assert_nothing_raised { xtractr.packets(1..10).inspect } end |
#test_Packets ⇒ Object
28 29 30 |
# File 'lib/mu/xtractr/test/tc_packets.rb', line 28 def test_Packets assert(Packets.ancestors.include?(Enumerable), "Packets doesn't mixin Enumerable") end |
#test_save ⇒ Object
68 69 70 71 72 73 74 75 76 |
# File 'lib/mu/xtractr/test/tc_packets.rb', line 68 def test_save filename = '/tmp/foo.pcap' pkts = xtractr.packets('pkt.service:HTTP pkt.dir:0') pkts.save filename assert_equal(true, File.exist?(filename)) assert_equal(53015, File.size(filename)) ensure File.unlink filename end |